d4f2b6c2cf12a70decfe4823008b5361b3bfd746
[ldk-java] / ts / bindings.c.body
1 #include "js-wasm.h"
2 #include <stdatomic.h>
3 #include <lightning.h>
4
5 // These should be provided...somehow...
6 void *memset(void *s, int c, size_t n);
7 void *memcpy(void *dest, const void *src, size_t n);
8 int memcmp(const void *s1, const void *s2, size_t n);
9
10 extern void __attribute__((noreturn)) abort(void);
11 static inline void assert(bool expression) {
12         if (!expression) { abort(); }
13 }
14
15 uint32_t __attribute__((export_name("test_bigint_pass_deadbeef0badf00d"))) test_bigint_pass_deadbeef0badf00d(uint64_t val) {
16         return val == 0xdeadbeef0badf00dULL;
17 }
18
19
20 void *malloc(size_t size);
21 void free(void *ptr);
22
23 #define MALLOC(a, _) malloc(a)
24 #define do_MALLOC(a, _b, _c) malloc(a)
25 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
26 #define DO_ASSERT(a) (void)(a)
27 #define CHECK(a)
28 #define CHECK_ACCESS(p)
29 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
30
31 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
32 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
33 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
34 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
35
36 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
37
38 #define DECL_ARR_TYPE(ty, name) \
39         struct name##array { \
40                 uint32_t arr_len; \
41                 ty elems[]; \
42         }; \
43         typedef struct name##array * name##Array; \
44         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
45                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint32_t), #name" array init", lineno); \
46                 arr->arr_len = arr_len; \
47                 return arr; \
48         }
49
50 DECL_ARR_TYPE(int64_t, int64_t);
51 DECL_ARR_TYPE(int8_t, int8_t);
52 DECL_ARR_TYPE(uint32_t, uint32_t);
53 DECL_ARR_TYPE(void*, ptr);
54 DECL_ARR_TYPE(char, char);
55 typedef charArray jstring;
56
57 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
58         charArray arr = init_charArray(len, __LINE__);
59         memcpy(arr->elems, chars, len);
60         return arr;
61 }
62 static inline LDKStr str_ref_to_owned_c(const jstring str) {
63         char* newchars = MALLOC(str->arr_len + 1, "String chars");
64         memcpy(newchars, str->elems, str->arr_len);
65         newchars[str->arr_len] = 0;
66         LDKStr res = {
67                 .chars = newchars,
68                 .len = str->arr_len,
69                 .chars_is_owned = true
70         };
71         return res;
72 }
73
74 typedef bool jboolean;
75
76 uint32_t __attribute__((export_name("TS_malloc"))) TS_malloc(uint32_t size) {
77         return (uint32_t)MALLOC(size, "JS-Called malloc");
78 }
79 void __attribute__((export_name("TS_free"))) TS_free(uint32_t ptr) {
80         FREE((void*)ptr);
81 }
82
83 jstring __attribute__((export_name("TS_get_ldk_c_bindings_version"))) TS_get_ldk_c_bindings_version() {
84         const char *res = check_get_ldk_bindings_version();
85         if (res == NULL) return NULL;
86         return str_ref_to_ts(res, strlen(res));
87 }
88 jstring __attribute__((export_name("TS_get_ldk_version"))) get_ldk_version() {
89         const char *res = check_get_ldk_version();
90         if (res == NULL) return NULL;
91         return str_ref_to_ts(res, strlen(res));
92 }
93 #include "version.c"
94 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
95 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
96         switch (ord) {
97                 case 0: return LDKAccessError_UnknownChain;
98                 case 1: return LDKAccessError_UnknownTx;
99         }
100         abort();
101 }
102 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
103         switch (val) {
104                 case LDKAccessError_UnknownChain: return 0;
105                 case LDKAccessError_UnknownTx: return 1;
106                 default: abort();
107         }
108 }
109 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
110         switch (ord) {
111                 case 0: return LDKCOption_NoneZ_Some;
112                 case 1: return LDKCOption_NoneZ_None;
113         }
114         abort();
115 }
116 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
117         switch (val) {
118                 case LDKCOption_NoneZ_Some: return 0;
119                 case LDKCOption_NoneZ_None: return 1;
120                 default: abort();
121         }
122 }
123 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
124         switch (ord) {
125                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
126                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
127         }
128         abort();
129 }
130 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
131         switch (val) {
132                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
133                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
134                 default: abort();
135         }
136 }
137 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
138         switch (ord) {
139                 case 0: return LDKConfirmationTarget_Background;
140                 case 1: return LDKConfirmationTarget_Normal;
141                 case 2: return LDKConfirmationTarget_HighPriority;
142         }
143         abort();
144 }
145 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
146         switch (val) {
147                 case LDKConfirmationTarget_Background: return 0;
148                 case LDKConfirmationTarget_Normal: return 1;
149                 case LDKConfirmationTarget_HighPriority: return 2;
150                 default: abort();
151         }
152 }
153 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
154         switch (ord) {
155                 case 0: return LDKCreationError_DescriptionTooLong;
156                 case 1: return LDKCreationError_RouteTooLong;
157                 case 2: return LDKCreationError_TimestampOutOfBounds;
158                 case 3: return LDKCreationError_InvalidAmount;
159                 case 4: return LDKCreationError_MissingRouteHints;
160         }
161         abort();
162 }
163 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
164         switch (val) {
165                 case LDKCreationError_DescriptionTooLong: return 0;
166                 case LDKCreationError_RouteTooLong: return 1;
167                 case LDKCreationError_TimestampOutOfBounds: return 2;
168                 case LDKCreationError_InvalidAmount: return 3;
169                 case LDKCreationError_MissingRouteHints: return 4;
170                 default: abort();
171         }
172 }
173 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
174         switch (ord) {
175                 case 0: return LDKCurrency_Bitcoin;
176                 case 1: return LDKCurrency_BitcoinTestnet;
177                 case 2: return LDKCurrency_Regtest;
178                 case 3: return LDKCurrency_Simnet;
179                 case 4: return LDKCurrency_Signet;
180         }
181         abort();
182 }
183 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
184         switch (val) {
185                 case LDKCurrency_Bitcoin: return 0;
186                 case LDKCurrency_BitcoinTestnet: return 1;
187                 case LDKCurrency_Regtest: return 2;
188                 case LDKCurrency_Simnet: return 3;
189                 case LDKCurrency_Signet: return 4;
190                 default: abort();
191         }
192 }
193 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
194         switch (ord) {
195                 case 0: return LDKLevel_Gossip;
196                 case 1: return LDKLevel_Trace;
197                 case 2: return LDKLevel_Debug;
198                 case 3: return LDKLevel_Info;
199                 case 4: return LDKLevel_Warn;
200                 case 5: return LDKLevel_Error;
201         }
202         abort();
203 }
204 static inline int32_t LDKLevel_to_js(LDKLevel val) {
205         switch (val) {
206                 case LDKLevel_Gossip: return 0;
207                 case LDKLevel_Trace: return 1;
208                 case LDKLevel_Debug: return 2;
209                 case LDKLevel_Info: return 3;
210                 case LDKLevel_Warn: return 4;
211                 case LDKLevel_Error: return 5;
212                 default: abort();
213         }
214 }
215 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
216         switch (ord) {
217                 case 0: return LDKNetwork_Bitcoin;
218                 case 1: return LDKNetwork_Testnet;
219                 case 2: return LDKNetwork_Regtest;
220                 case 3: return LDKNetwork_Signet;
221         }
222         abort();
223 }
224 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
225         switch (val) {
226                 case LDKNetwork_Bitcoin: return 0;
227                 case LDKNetwork_Testnet: return 1;
228                 case LDKNetwork_Regtest: return 2;
229                 case LDKNetwork_Signet: return 3;
230                 default: abort();
231         }
232 }
233 static inline LDKRecipient LDKRecipient_from_js(int32_t ord) {
234         switch (ord) {
235                 case 0: return LDKRecipient_Node;
236                 case 1: return LDKRecipient_PhantomNode;
237         }
238         abort();
239 }
240 static inline int32_t LDKRecipient_to_js(LDKRecipient val) {
241         switch (val) {
242                 case LDKRecipient_Node: return 0;
243                 case LDKRecipient_PhantomNode: return 1;
244                 default: abort();
245         }
246 }
247 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
248         switch (ord) {
249                 case 0: return LDKSecp256k1Error_IncorrectSignature;
250                 case 1: return LDKSecp256k1Error_InvalidMessage;
251                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
252                 case 3: return LDKSecp256k1Error_InvalidSignature;
253                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
254                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
255                 case 6: return LDKSecp256k1Error_InvalidTweak;
256                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
257                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
258         }
259         abort();
260 }
261 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
262         switch (val) {
263                 case LDKSecp256k1Error_IncorrectSignature: return 0;
264                 case LDKSecp256k1Error_InvalidMessage: return 1;
265                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
266                 case LDKSecp256k1Error_InvalidSignature: return 3;
267                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
268                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
269                 case LDKSecp256k1Error_InvalidTweak: return 6;
270                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
271                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
272                 default: abort();
273         }
274 }
275 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
276         switch (ord) {
277                 case 0: return LDKSemanticError_NoPaymentHash;
278                 case 1: return LDKSemanticError_MultiplePaymentHashes;
279                 case 2: return LDKSemanticError_NoDescription;
280                 case 3: return LDKSemanticError_MultipleDescriptions;
281                 case 4: return LDKSemanticError_NoPaymentSecret;
282                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
283                 case 6: return LDKSemanticError_InvalidFeatures;
284                 case 7: return LDKSemanticError_InvalidRecoveryId;
285                 case 8: return LDKSemanticError_InvalidSignature;
286                 case 9: return LDKSemanticError_ImpreciseAmount;
287         }
288         abort();
289 }
290 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
291         switch (val) {
292                 case LDKSemanticError_NoPaymentHash: return 0;
293                 case LDKSemanticError_MultiplePaymentHashes: return 1;
294                 case LDKSemanticError_NoDescription: return 2;
295                 case LDKSemanticError_MultipleDescriptions: return 3;
296                 case LDKSemanticError_NoPaymentSecret: return 4;
297                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
298                 case LDKSemanticError_InvalidFeatures: return 6;
299                 case LDKSemanticError_InvalidRecoveryId: return 7;
300                 case LDKSemanticError_InvalidSignature: return 8;
301                 case LDKSemanticError_ImpreciseAmount: return 9;
302                 default: abort();
303         }
304 }
305 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
306         switch (ord) {
307                 case 0: return LDKSiPrefix_Milli;
308                 case 1: return LDKSiPrefix_Micro;
309                 case 2: return LDKSiPrefix_Nano;
310                 case 3: return LDKSiPrefix_Pico;
311         }
312         abort();
313 }
314 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
315         switch (val) {
316                 case LDKSiPrefix_Milli: return 0;
317                 case LDKSiPrefix_Micro: return 1;
318                 case LDKSiPrefix_Nano: return 2;
319                 case LDKSiPrefix_Pico: return 3;
320                 default: abort();
321         }
322 }
323 uint32_t __attribute__((export_name("TS_LDKBech32Error_ty_from_ptr"))) TS_LDKBech32Error_ty_from_ptr(uint32_t ptr) {
324         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
325         switch(obj->tag) {
326                 case LDKBech32Error_MissingSeparator: return 0;
327                 case LDKBech32Error_InvalidChecksum: return 1;
328                 case LDKBech32Error_InvalidLength: return 2;
329                 case LDKBech32Error_InvalidChar: return 3;
330                 case LDKBech32Error_InvalidData: return 4;
331                 case LDKBech32Error_InvalidPadding: return 5;
332                 case LDKBech32Error_MixedCase: return 6;
333                 default: abort();
334         }
335 }
336 int32_t __attribute__((export_name("TS_LDKBech32Error_InvalidChar_get_invalid_char"))) TS_LDKBech32Error_InvalidChar_get_invalid_char(uint32_t ptr) {
337         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
338         assert(obj->tag == LDKBech32Error_InvalidChar);
339         return obj->invalid_char;
340 }
341 int8_t __attribute__((export_name("TS_LDKBech32Error_InvalidData_get_invalid_data"))) TS_LDKBech32Error_InvalidData_get_invalid_data(uint32_t ptr) {
342         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
343         assert(obj->tag == LDKBech32Error_InvalidData);
344         return obj->invalid_data;
345 }
346 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
347         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
348         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
349         return ret;
350 }
351 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) {
352         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
353         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
354         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
355         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
356         CVec_u8Z_free(ret_var);
357         return ret_arr;
358 }
359
360 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) {
361         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
362         int64_t ret_val = TxOut_get_value(thing_conv);
363         return ret_val;
364 }
365
366 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
367 CHECK(owner->result_ok);
368         return *owner->contents.result;
369 }
370 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
371         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
372         CResult_NoneNoneZ_get_ok(owner_conv);
373 }
374
375 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
376 CHECK(!owner->result_ok);
377         return *owner->contents.err;
378 }
379 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
380         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
381         CResult_NoneNoneZ_get_err(owner_conv);
382 }
383
384 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
385 CHECK(owner->result_ok);
386         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
387 }
388 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(uint32_t owner) {
389         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
390         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
391         uint32_t ret_ref = 0;
392         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
393         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
395         ret_ref = (uintptr_t)ret_var.inner;
396         if (ret_var.is_owned) {
397                 ret_ref |= 1;
398         }
399         return ret_ref;
400 }
401
402 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
403 CHECK(!owner->result_ok);
404         return DecodeError_clone(&*owner->contents.err);
405 }
406 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(uint32_t owner) {
407         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
408         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
409         uint32_t ret_ref = 0;
410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
413         ret_ref = (uintptr_t)ret_var.inner;
414         if (ret_var.is_owned) {
415                 ret_ref |= 1;
416         }
417         return ret_ref;
418 }
419
420 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
421 CHECK(owner->result_ok);
422         return *owner->contents.result;
423 }
424 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
425         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
426         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
427         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
428         return ret_arr;
429 }
430
431 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
432 CHECK(!owner->result_ok);
433         return *owner->contents.err;
434 }
435 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
436         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
437         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
438         return ret_conv;
439 }
440
441 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
442 CHECK(owner->result_ok);
443         return *owner->contents.result;
444 }
445 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
446         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
447         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
448         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
449         return ret_arr;
450 }
451
452 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
453 CHECK(!owner->result_ok);
454         return *owner->contents.err;
455 }
456 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
457         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
458         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
459         return ret_conv;
460 }
461
462 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
463 CHECK(owner->result_ok);
464         return TxCreationKeys_clone(&*owner->contents.result);
465 }
466 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
467         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
468         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
469         uint32_t ret_ref = 0;
470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
473         ret_ref = (uintptr_t)ret_var.inner;
474         if (ret_var.is_owned) {
475                 ret_ref |= 1;
476         }
477         return ret_ref;
478 }
479
480 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
481 CHECK(!owner->result_ok);
482         return DecodeError_clone(&*owner->contents.err);
483 }
484 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
485         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
486         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
487         uint32_t ret_ref = 0;
488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
491         ret_ref = (uintptr_t)ret_var.inner;
492         if (ret_var.is_owned) {
493                 ret_ref |= 1;
494         }
495         return ret_ref;
496 }
497
498 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
499 CHECK(owner->result_ok);
500         return ChannelPublicKeys_clone(&*owner->contents.result);
501 }
502 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
503         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
504         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
505         uint32_t ret_ref = 0;
506         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
507         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
509         ret_ref = (uintptr_t)ret_var.inner;
510         if (ret_var.is_owned) {
511                 ret_ref |= 1;
512         }
513         return ret_ref;
514 }
515
516 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
517 CHECK(!owner->result_ok);
518         return DecodeError_clone(&*owner->contents.err);
519 }
520 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
521         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
522         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
523         uint32_t ret_ref = 0;
524         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
525         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
527         ret_ref = (uintptr_t)ret_var.inner;
528         if (ret_var.is_owned) {
529                 ret_ref |= 1;
530         }
531         return ret_ref;
532 }
533
534 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
535 CHECK(owner->result_ok);
536         return TxCreationKeys_clone(&*owner->contents.result);
537 }
538 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
539         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
540         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
541         uint32_t ret_ref = 0;
542         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
543         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
545         ret_ref = (uintptr_t)ret_var.inner;
546         if (ret_var.is_owned) {
547                 ret_ref |= 1;
548         }
549         return ret_ref;
550 }
551
552 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
553 CHECK(!owner->result_ok);
554         return *owner->contents.err;
555 }
556 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
557         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
558         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
559         return ret_conv;
560 }
561
562 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
563         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
564         switch(obj->tag) {
565                 case LDKCOption_u32Z_Some: return 0;
566                 case LDKCOption_u32Z_None: return 1;
567                 default: abort();
568         }
569 }
570 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
571         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
572         assert(obj->tag == LDKCOption_u32Z_Some);
573         return obj->some;
574 }
575 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
576 CHECK(owner->result_ok);
577         return HTLCOutputInCommitment_clone(&*owner->contents.result);
578 }
579 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
580         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
581         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
582         uint32_t ret_ref = 0;
583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
586         ret_ref = (uintptr_t)ret_var.inner;
587         if (ret_var.is_owned) {
588                 ret_ref |= 1;
589         }
590         return ret_ref;
591 }
592
593 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
594 CHECK(!owner->result_ok);
595         return DecodeError_clone(&*owner->contents.err);
596 }
597 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
598         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
599         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
600         uint32_t ret_ref = 0;
601         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
602         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
604         ret_ref = (uintptr_t)ret_var.inner;
605         if (ret_var.is_owned) {
606                 ret_ref |= 1;
607         }
608         return ret_ref;
609 }
610
611 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
612 CHECK(owner->result_ok);
613         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
614 }
615 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
616         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
617         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
618         uint32_t ret_ref = 0;
619         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
620         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
622         ret_ref = (uintptr_t)ret_var.inner;
623         if (ret_var.is_owned) {
624                 ret_ref |= 1;
625         }
626         return ret_ref;
627 }
628
629 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
630 CHECK(!owner->result_ok);
631         return DecodeError_clone(&*owner->contents.err);
632 }
633 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
634         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
635         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
636         uint32_t ret_ref = 0;
637         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
638         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
640         ret_ref = (uintptr_t)ret_var.inner;
641         if (ret_var.is_owned) {
642                 ret_ref |= 1;
643         }
644         return ret_ref;
645 }
646
647 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
648 CHECK(owner->result_ok);
649         return ChannelTransactionParameters_clone(&*owner->contents.result);
650 }
651 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
652         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
653         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
654         uint32_t ret_ref = 0;
655         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
656         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
658         ret_ref = (uintptr_t)ret_var.inner;
659         if (ret_var.is_owned) {
660                 ret_ref |= 1;
661         }
662         return ret_ref;
663 }
664
665 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
666 CHECK(!owner->result_ok);
667         return DecodeError_clone(&*owner->contents.err);
668 }
669 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
670         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
671         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
672         uint32_t ret_ref = 0;
673         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
674         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
676         ret_ref = (uintptr_t)ret_var.inner;
677         if (ret_var.is_owned) {
678                 ret_ref |= 1;
679         }
680         return ret_ref;
681 }
682
683 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
684 CHECK(owner->result_ok);
685         return HolderCommitmentTransaction_clone(&*owner->contents.result);
686 }
687 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
688         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
689         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
690         uint32_t ret_ref = 0;
691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
694         ret_ref = (uintptr_t)ret_var.inner;
695         if (ret_var.is_owned) {
696                 ret_ref |= 1;
697         }
698         return ret_ref;
699 }
700
701 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
702 CHECK(!owner->result_ok);
703         return DecodeError_clone(&*owner->contents.err);
704 }
705 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
706         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
707         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
708         uint32_t ret_ref = 0;
709         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
710         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
712         ret_ref = (uintptr_t)ret_var.inner;
713         if (ret_var.is_owned) {
714                 ret_ref |= 1;
715         }
716         return ret_ref;
717 }
718
719 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
720 CHECK(owner->result_ok);
721         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
722 }
723 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
724         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
725         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
726         uint32_t ret_ref = 0;
727         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
728         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
730         ret_ref = (uintptr_t)ret_var.inner;
731         if (ret_var.is_owned) {
732                 ret_ref |= 1;
733         }
734         return ret_ref;
735 }
736
737 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
738 CHECK(!owner->result_ok);
739         return DecodeError_clone(&*owner->contents.err);
740 }
741 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
742         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
743         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
744         uint32_t ret_ref = 0;
745         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
746         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
748         ret_ref = (uintptr_t)ret_var.inner;
749         if (ret_var.is_owned) {
750                 ret_ref |= 1;
751         }
752         return ret_ref;
753 }
754
755 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
756 CHECK(owner->result_ok);
757         return &*owner->contents.result;
758 }
759 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
760         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
761         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
762         uint32_t ret_ref = 0;
763         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
764         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
766         ret_ref = (uintptr_t)ret_var.inner & ~1;
767         return ret_ref;
768 }
769
770 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
771 CHECK(!owner->result_ok);
772         return *owner->contents.err;
773 }
774 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
775         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
776         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
777 }
778
779 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
780 CHECK(owner->result_ok);
781         return CommitmentTransaction_clone(&*owner->contents.result);
782 }
783 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
784         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
785         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
786         uint32_t ret_ref = 0;
787         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
788         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
790         ret_ref = (uintptr_t)ret_var.inner;
791         if (ret_var.is_owned) {
792                 ret_ref |= 1;
793         }
794         return ret_ref;
795 }
796
797 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
798 CHECK(!owner->result_ok);
799         return DecodeError_clone(&*owner->contents.err);
800 }
801 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
802         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
803         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
804         uint32_t ret_ref = 0;
805         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
806         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
808         ret_ref = (uintptr_t)ret_var.inner;
809         if (ret_var.is_owned) {
810                 ret_ref |= 1;
811         }
812         return ret_ref;
813 }
814
815 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
816 CHECK(owner->result_ok);
817         return &*owner->contents.result;
818 }
819 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
820         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
821         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
822         uint32_t ret_ref = 0;
823         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
824         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
826         ret_ref = (uintptr_t)ret_var.inner & ~1;
827         return ret_ref;
828 }
829
830 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
831 CHECK(!owner->result_ok);
832         return *owner->contents.err;
833 }
834 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
835         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
836         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
837 }
838
839 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
840 CHECK(owner->result_ok);
841         return *owner->contents.result;
842 }
843 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
844         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
845         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
846         ptrArray ret_arr = NULL;
847         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
848         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
849         for (size_t m = 0; m < ret_var.datalen; m++) {
850                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
851                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
852                 ret_arr_ptr[m] = ret_conv_12_arr;
853         }
854         
855         return ret_arr;
856 }
857
858 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
859 CHECK(!owner->result_ok);
860         return *owner->contents.err;
861 }
862 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
863         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
864         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
865 }
866
867 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
868 CHECK(owner->result_ok);
869         return ShutdownScript_clone(&*owner->contents.result);
870 }
871 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
872         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
873         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
874         uint32_t ret_ref = 0;
875         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
876         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
878         ret_ref = (uintptr_t)ret_var.inner;
879         if (ret_var.is_owned) {
880                 ret_ref |= 1;
881         }
882         return ret_ref;
883 }
884
885 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
886 CHECK(!owner->result_ok);
887         return DecodeError_clone(&*owner->contents.err);
888 }
889 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
890         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
891         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
892         uint32_t ret_ref = 0;
893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
896         ret_ref = (uintptr_t)ret_var.inner;
897         if (ret_var.is_owned) {
898                 ret_ref |= 1;
899         }
900         return ret_ref;
901 }
902
903 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
904 CHECK(owner->result_ok);
905         return ShutdownScript_clone(&*owner->contents.result);
906 }
907 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
908         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
909         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
910         uint32_t ret_ref = 0;
911         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
912         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
914         ret_ref = (uintptr_t)ret_var.inner;
915         if (ret_var.is_owned) {
916                 ret_ref |= 1;
917         }
918         return ret_ref;
919 }
920
921 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
922 CHECK(!owner->result_ok);
923         return InvalidShutdownScript_clone(&*owner->contents.err);
924 }
925 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
926         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
927         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
928         uint32_t ret_ref = 0;
929         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
930         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
932         ret_ref = (uintptr_t)ret_var.inner;
933         if (ret_var.is_owned) {
934                 ret_ref |= 1;
935         }
936         return ret_ref;
937 }
938
939 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
940 CHECK(owner->result_ok);
941         return RouteHop_clone(&*owner->contents.result);
942 }
943 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
944         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
945         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
946         uint32_t ret_ref = 0;
947         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
948         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
950         ret_ref = (uintptr_t)ret_var.inner;
951         if (ret_var.is_owned) {
952                 ret_ref |= 1;
953         }
954         return ret_ref;
955 }
956
957 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
958 CHECK(!owner->result_ok);
959         return DecodeError_clone(&*owner->contents.err);
960 }
961 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
962         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
963         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
964         uint32_t ret_ref = 0;
965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
968         ret_ref = (uintptr_t)ret_var.inner;
969         if (ret_var.is_owned) {
970                 ret_ref |= 1;
971         }
972         return ret_ref;
973 }
974
975 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
976         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
977         for (size_t i = 0; i < ret.datalen; i++) {
978                 ret.data[i] = RouteHop_clone(&orig->data[i]);
979         }
980         return ret;
981 }
982 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
983         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
984         for (size_t i = 0; i < ret.datalen; i++) {
985                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
986         }
987         return ret;
988 }
989 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
990 CHECK(owner->result_ok);
991         return Route_clone(&*owner->contents.result);
992 }
993 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
994         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
995         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
996         uint32_t ret_ref = 0;
997         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
998         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1000         ret_ref = (uintptr_t)ret_var.inner;
1001         if (ret_var.is_owned) {
1002                 ret_ref |= 1;
1003         }
1004         return ret_ref;
1005 }
1006
1007 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1008 CHECK(!owner->result_ok);
1009         return DecodeError_clone(&*owner->contents.err);
1010 }
1011 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
1012         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1013         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1014         uint32_t ret_ref = 0;
1015         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1016         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1018         ret_ref = (uintptr_t)ret_var.inner;
1019         if (ret_var.is_owned) {
1020                 ret_ref |= 1;
1021         }
1022         return ret_ref;
1023 }
1024
1025 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1026 CHECK(owner->result_ok);
1027         return RouteParameters_clone(&*owner->contents.result);
1028 }
1029 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
1030         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1031         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1032         uint32_t ret_ref = 0;
1033         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1034         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1036         ret_ref = (uintptr_t)ret_var.inner;
1037         if (ret_var.is_owned) {
1038                 ret_ref |= 1;
1039         }
1040         return ret_ref;
1041 }
1042
1043 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1044 CHECK(!owner->result_ok);
1045         return DecodeError_clone(&*owner->contents.err);
1046 }
1047 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
1048         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1049         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1050         uint32_t ret_ref = 0;
1051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1054         ret_ref = (uintptr_t)ret_var.inner;
1055         if (ret_var.is_owned) {
1056                 ret_ref |= 1;
1057         }
1058         return ret_ref;
1059 }
1060
1061 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1062         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1063         for (size_t i = 0; i < ret.datalen; i++) {
1064                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1065         }
1066         return ret;
1067 }
1068 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1069         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1070         switch(obj->tag) {
1071                 case LDKCOption_u64Z_Some: return 0;
1072                 case LDKCOption_u64Z_None: return 1;
1073                 default: abort();
1074         }
1075 }
1076 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1077         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1078         assert(obj->tag == LDKCOption_u64Z_Some);
1079         return obj->some;
1080 }
1081 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1082 CHECK(owner->result_ok);
1083         return PaymentParameters_clone(&*owner->contents.result);
1084 }
1085 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_get_ok(uint32_t owner) {
1086         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1087         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1088         uint32_t ret_ref = 0;
1089         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1090         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1092         ret_ref = (uintptr_t)ret_var.inner;
1093         if (ret_var.is_owned) {
1094                 ret_ref |= 1;
1095         }
1096         return ret_ref;
1097 }
1098
1099 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1100 CHECK(!owner->result_ok);
1101         return DecodeError_clone(&*owner->contents.err);
1102 }
1103 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_err"))) TS_CResult_PaymentParametersDecodeErrorZ_get_err(uint32_t owner) {
1104         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1105         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1106         uint32_t ret_ref = 0;
1107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1110         ret_ref = (uintptr_t)ret_var.inner;
1111         if (ret_var.is_owned) {
1112                 ret_ref |= 1;
1113         }
1114         return ret_ref;
1115 }
1116
1117 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1118         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1119         for (size_t i = 0; i < ret.datalen; i++) {
1120                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1121         }
1122         return ret;
1123 }
1124 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1125 CHECK(owner->result_ok);
1126         return RouteHint_clone(&*owner->contents.result);
1127 }
1128 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
1129         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1130         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1131         uint32_t ret_ref = 0;
1132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1135         ret_ref = (uintptr_t)ret_var.inner;
1136         if (ret_var.is_owned) {
1137                 ret_ref |= 1;
1138         }
1139         return ret_ref;
1140 }
1141
1142 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1143 CHECK(!owner->result_ok);
1144         return DecodeError_clone(&*owner->contents.err);
1145 }
1146 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
1147         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1148         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1149         uint32_t ret_ref = 0;
1150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1153         ret_ref = (uintptr_t)ret_var.inner;
1154         if (ret_var.is_owned) {
1155                 ret_ref |= 1;
1156         }
1157         return ret_ref;
1158 }
1159
1160 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1161 CHECK(owner->result_ok);
1162         return RouteHintHop_clone(&*owner->contents.result);
1163 }
1164 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
1165         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1166         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1167         uint32_t ret_ref = 0;
1168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1171         ret_ref = (uintptr_t)ret_var.inner;
1172         if (ret_var.is_owned) {
1173                 ret_ref |= 1;
1174         }
1175         return ret_ref;
1176 }
1177
1178 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1179 CHECK(!owner->result_ok);
1180         return DecodeError_clone(&*owner->contents.err);
1181 }
1182 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
1183         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1184         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1185         uint32_t ret_ref = 0;
1186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1189         ret_ref = (uintptr_t)ret_var.inner;
1190         if (ret_var.is_owned) {
1191                 ret_ref |= 1;
1192         }
1193         return ret_ref;
1194 }
1195
1196 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1197         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1198         for (size_t i = 0; i < ret.datalen; i++) {
1199                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1200         }
1201         return ret;
1202 }
1203 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1204 CHECK(owner->result_ok);
1205         return Route_clone(&*owner->contents.result);
1206 }
1207 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
1208         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1209         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1210         uint32_t ret_ref = 0;
1211         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1212         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1214         ret_ref = (uintptr_t)ret_var.inner;
1215         if (ret_var.is_owned) {
1216                 ret_ref |= 1;
1217         }
1218         return ret_ref;
1219 }
1220
1221 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1222 CHECK(!owner->result_ok);
1223         return LightningError_clone(&*owner->contents.err);
1224 }
1225 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
1226         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1227         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1228         uint32_t ret_ref = 0;
1229         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1230         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1232         ret_ref = (uintptr_t)ret_var.inner;
1233         if (ret_var.is_owned) {
1234                 ret_ref |= 1;
1235         }
1236         return ret_ref;
1237 }
1238
1239 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1240 CHECK(owner->result_ok);
1241         return TxOut_clone(&*owner->contents.result);
1242 }
1243 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
1244         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1245         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1246         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
1247         return (uint32_t)ret_ref;
1248 }
1249
1250 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1251 CHECK(!owner->result_ok);
1252         return AccessError_clone(&*owner->contents.err);
1253 }
1254 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
1255         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1256         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
1257         return ret_conv;
1258 }
1259
1260 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1261         return owner->a;
1262 }
1263 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
1264         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1265         uint32_t ret_val = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1266         return ret_val;
1267 }
1268
1269 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1270         return owner->b;
1271 }
1272 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
1273         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1274         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1275         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1276         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1277         return ret_arr;
1278 }
1279
1280 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1281         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1282         for (size_t i = 0; i < ret.datalen; i++) {
1283                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1284         }
1285         return ret;
1286 }
1287 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
1288         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1289         for (size_t i = 0; i < ret.datalen; i++) {
1290                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1291         }
1292         return ret;
1293 }
1294 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1295 CHECK(owner->result_ok);
1296         return *owner->contents.result;
1297 }
1298 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
1299         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1300         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
1301 }
1302
1303 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1304 CHECK(!owner->result_ok);
1305         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
1306 }
1307 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
1308         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1309         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
1310         return ret_conv;
1311 }
1312
1313 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
1314         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1315         switch(obj->tag) {
1316                 case LDKMonitorEvent_HTLCEvent: return 0;
1317                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
1318                 case LDKMonitorEvent_UpdateCompleted: return 2;
1319                 case LDKMonitorEvent_UpdateFailed: return 3;
1320                 default: abort();
1321         }
1322 }
1323 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
1324         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1325         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
1326                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1327                         uint32_t htlc_event_ref = 0;
1328                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1329                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1330                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1331                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
1332         return htlc_event_ref;
1333 }
1334 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
1335         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1336         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
1337                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1338                         uint32_t commitment_tx_confirmed_ref = 0;
1339                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1340                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1341                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1342                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
1343         return commitment_tx_confirmed_ref;
1344 }
1345 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
1346         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1347         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1348                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1349                         uint32_t funding_txo_ref = 0;
1350                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1351                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1352                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1353                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
1354         return funding_txo_ref;
1355 }
1356 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
1357         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1358         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1359         return obj->update_completed.monitor_update_id;
1360 }
1361 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
1362         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1363         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
1364                         LDKOutPoint update_failed_var = obj->update_failed;
1365                         uint32_t update_failed_ref = 0;
1366                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1367                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1368                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1369                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
1370         return update_failed_ref;
1371 }
1372 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1373         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1374         for (size_t i = 0; i < ret.datalen; i++) {
1375                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1376         }
1377         return ret;
1378 }
1379 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
1380         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1381         switch(obj->tag) {
1382                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
1383                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
1384                 default: abort();
1385         }
1386 }
1387 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
1388         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1389         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
1390                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1391                         *some_conv = obj->some;
1392                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1393         return ((uint32_t)some_conv);
1394 }
1395 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1396         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1397         switch(obj->tag) {
1398                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1399                 case LDKClosureReason_HolderForceClosed: return 1;
1400                 case LDKClosureReason_CooperativeClosure: return 2;
1401                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1402                 case LDKClosureReason_FundingTimedOut: return 4;
1403                 case LDKClosureReason_ProcessingError: return 5;
1404                 case LDKClosureReason_DisconnectedPeer: return 6;
1405                 case LDKClosureReason_OutdatedChannelManager: return 7;
1406                 default: abort();
1407         }
1408 }
1409 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1410         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1411         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1412                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1413                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1414         return peer_msg_conv;
1415 }
1416 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1417         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1418         assert(obj->tag == LDKClosureReason_ProcessingError);
1419                         LDKStr err_str = obj->processing_error.err;
1420                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1421         return err_conv;
1422 }
1423 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
1424         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1425         switch(obj->tag) {
1426                 case LDKCOption_ClosureReasonZ_Some: return 0;
1427                 case LDKCOption_ClosureReasonZ_None: return 1;
1428                 default: abort();
1429         }
1430 }
1431 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
1432         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1433         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
1434                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1435         return some_ref;
1436 }
1437 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1438 CHECK(owner->result_ok);
1439         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1440 }
1441 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
1442         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1443         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1444         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1445         uint32_t ret_ref = (uintptr_t)ret_copy;
1446         return ret_ref;
1447 }
1448
1449 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1450 CHECK(!owner->result_ok);
1451         return DecodeError_clone(&*owner->contents.err);
1452 }
1453 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
1454         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1455         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1456         uint32_t ret_ref = 0;
1457         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1458         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1460         ret_ref = (uintptr_t)ret_var.inner;
1461         if (ret_var.is_owned) {
1462                 ret_ref |= 1;
1463         }
1464         return ret_ref;
1465 }
1466
1467 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1468         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1469         switch(obj->tag) {
1470                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1471                 case LDKNetworkUpdate_ChannelClosed: return 1;
1472                 case LDKNetworkUpdate_NodeFailure: return 2;
1473                 default: abort();
1474         }
1475 }
1476 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1477         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1478         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1479                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1480                         uint32_t msg_ref = 0;
1481                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1482                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1483                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1484                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1485         return msg_ref;
1486 }
1487 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id(uint32_t ptr) {
1488         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1489         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1490         return obj->channel_closed.short_channel_id;
1491 }
1492 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent(uint32_t ptr) {
1493         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1494         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1495         return obj->channel_closed.is_permanent;
1496 }
1497 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1498         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1499         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1500                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1501                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1502         return node_id_arr;
1503 }
1504 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1505         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1506         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1507         return obj->node_failure.is_permanent;
1508 }
1509 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1510         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1511         switch(obj->tag) {
1512                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1513                 case LDKCOption_NetworkUpdateZ_None: return 1;
1514                 default: abort();
1515         }
1516 }
1517 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1518         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1519         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1520                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1521         return some_ref;
1522 }
1523 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1524         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1525         switch(obj->tag) {
1526                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1527                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1528                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1529                 default: abort();
1530         }
1531 }
1532 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1533         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1534         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1535                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1536                         uint32_t outpoint_ref = 0;
1537                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1538                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1539                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1540                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1541         return outpoint_ref;
1542 }
1543 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1544         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1545         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1546                         uint32_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1547         return (uint32_t)output_ref;
1548 }
1549 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1550         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1551         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1552                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1553                         uint32_t delayed_payment_output_ref = 0;
1554                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1555                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1556                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1557                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1558         return delayed_payment_output_ref;
1559 }
1560 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1561         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1562         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1563                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1564                         uint32_t static_payment_output_ref = 0;
1565                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1566                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1567                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1568                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1569         return static_payment_output_ref;
1570 }
1571 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1572         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1573         for (size_t i = 0; i < ret.datalen; i++) {
1574                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1575         }
1576         return ret;
1577 }
1578 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1579         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1580         switch(obj->tag) {
1581                 case LDKPaymentPurpose_InvoicePayment: return 0;
1582                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1583                 default: abort();
1584         }
1585 }
1586 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1587         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1588         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1589                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1590                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1591         return payment_preimage_arr;
1592 }
1593 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1594         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1595         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1596                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1597                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1598         return payment_secret_arr;
1599 }
1600 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1601         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1602         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1603                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1604                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1605         return spontaneous_payment_arr;
1606 }
1607 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1608         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1609         switch(obj->tag) {
1610                 case LDKEvent_FundingGenerationReady: return 0;
1611                 case LDKEvent_PaymentReceived: return 1;
1612                 case LDKEvent_PaymentSent: return 2;
1613                 case LDKEvent_PaymentPathFailed: return 3;
1614                 case LDKEvent_PaymentFailed: return 4;
1615                 case LDKEvent_PendingHTLCsForwardable: return 5;
1616                 case LDKEvent_SpendableOutputs: return 6;
1617                 case LDKEvent_PaymentForwarded: return 7;
1618                 case LDKEvent_ChannelClosed: return 8;
1619                 case LDKEvent_DiscardFunding: return 9;
1620                 case LDKEvent_PaymentPathSuccessful: return 10;
1621                 case LDKEvent_OpenChannelRequest: return 11;
1622                 default: abort();
1623         }
1624 }
1625 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1626         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1627         assert(obj->tag == LDKEvent_FundingGenerationReady);
1628                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1629                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1630         return temporary_channel_id_arr;
1631 }
1632 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1633         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1634         assert(obj->tag == LDKEvent_FundingGenerationReady);
1635         return obj->funding_generation_ready.channel_value_satoshis;
1636 }
1637 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1638         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1639         assert(obj->tag == LDKEvent_FundingGenerationReady);
1640                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1641                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1642                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1643         return output_script_arr;
1644 }
1645 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1646         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1647         assert(obj->tag == LDKEvent_FundingGenerationReady);
1648         return obj->funding_generation_ready.user_channel_id;
1649 }
1650 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1651         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1652         assert(obj->tag == LDKEvent_PaymentReceived);
1653                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1654                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1655         return payment_hash_arr;
1656 }
1657 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amt"))) TS_LDKEvent_PaymentReceived_get_amt(uint32_t ptr) {
1658         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1659         assert(obj->tag == LDKEvent_PaymentReceived);
1660         return obj->payment_received.amt;
1661 }
1662 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1663         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1664         assert(obj->tag == LDKEvent_PaymentReceived);
1665                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1666         return purpose_ref;
1667 }
1668 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1669         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1670         assert(obj->tag == LDKEvent_PaymentSent);
1671                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1672                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1673         return payment_id_arr;
1674 }
1675 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1676         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1677         assert(obj->tag == LDKEvent_PaymentSent);
1678                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1679                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1680         return payment_preimage_arr;
1681 }
1682 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1683         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1684         assert(obj->tag == LDKEvent_PaymentSent);
1685                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1686                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1687         return payment_hash_arr;
1688 }
1689 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1690         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1691         assert(obj->tag == LDKEvent_PaymentSent);
1692                         uint32_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1693         return fee_paid_msat_ref;
1694 }
1695 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1696         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1697         assert(obj->tag == LDKEvent_PaymentPathFailed);
1698                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1699                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1700         return payment_id_arr;
1701 }
1702 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1703         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1704         assert(obj->tag == LDKEvent_PaymentPathFailed);
1705                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1706                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1707         return payment_hash_arr;
1708 }
1709 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1710         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1711         assert(obj->tag == LDKEvent_PaymentPathFailed);
1712         return obj->payment_path_failed.rejected_by_dest;
1713 }
1714 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1715         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1716         assert(obj->tag == LDKEvent_PaymentPathFailed);
1717                         uint32_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1718         return network_update_ref;
1719 }
1720 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1721         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1722         assert(obj->tag == LDKEvent_PaymentPathFailed);
1723         return obj->payment_path_failed.all_paths_failed;
1724 }
1725 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1726         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1727         assert(obj->tag == LDKEvent_PaymentPathFailed);
1728                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1729                         uint32_tArray path_arr = NULL;
1730                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1731                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1732                         for (size_t k = 0; k < path_var.datalen; k++) {
1733                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1734                                 uint32_t path_conv_10_ref = 0;
1735                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1736                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1737                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1738                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1739                                 path_arr_ptr[k] = path_conv_10_ref;
1740                         }
1741                         
1742         return path_arr;
1743 }
1744 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1745         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1746         assert(obj->tag == LDKEvent_PaymentPathFailed);
1747                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1748         return short_channel_id_ref;
1749 }
1750 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1751         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1752         assert(obj->tag == LDKEvent_PaymentPathFailed);
1753                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1754                         uint32_t retry_ref = 0;
1755                         if ((uintptr_t)retry_var.inner > 4096) {
1756                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1757                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1758                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1759                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1760                         }
1761         return retry_ref;
1762 }
1763 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1764         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1765         assert(obj->tag == LDKEvent_PaymentFailed);
1766                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1767                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1768         return payment_id_arr;
1769 }
1770 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1771         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1772         assert(obj->tag == LDKEvent_PaymentFailed);
1773                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1774                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1775         return payment_hash_arr;
1776 }
1777 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1778         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1779         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1780         return obj->pending_htl_cs_forwardable.time_forwardable;
1781 }
1782 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1783         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1784         assert(obj->tag == LDKEvent_SpendableOutputs);
1785                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1786                         uint32_tArray outputs_arr = NULL;
1787                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1788                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 4);
1789                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1790                                 uint32_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1791                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1792                         }
1793                         
1794         return outputs_arr;
1795 }
1796 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1797         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1798         assert(obj->tag == LDKEvent_PaymentForwarded);
1799                         uint32_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1800         return fee_earned_msat_ref;
1801 }
1802 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1803         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1804         assert(obj->tag == LDKEvent_PaymentForwarded);
1805         return obj->payment_forwarded.claim_from_onchain_tx;
1806 }
1807 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1808         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1809         assert(obj->tag == LDKEvent_ChannelClosed);
1810                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1811                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1812         return channel_id_arr;
1813 }
1814 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1815         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1816         assert(obj->tag == LDKEvent_ChannelClosed);
1817         return obj->channel_closed.user_channel_id;
1818 }
1819 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1820         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1821         assert(obj->tag == LDKEvent_ChannelClosed);
1822                         uint32_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1823         return reason_ref;
1824 }
1825 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1826         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1827         assert(obj->tag == LDKEvent_DiscardFunding);
1828                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1829                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
1830         return channel_id_arr;
1831 }
1832 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
1833         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1834         assert(obj->tag == LDKEvent_DiscardFunding);
1835                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1836                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
1837                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
1838         return transaction_arr;
1839 }
1840 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1841         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1842         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1843                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1844                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1845         return payment_id_arr;
1846 }
1847 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1848         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1849         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1850                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1851                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1852         return payment_hash_arr;
1853 }
1854 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1855         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1856         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1857                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1858                         uint32_tArray path_arr = NULL;
1859                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1860                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1861                         for (size_t k = 0; k < path_var.datalen; k++) {
1862                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1863                                 uint32_t path_conv_10_ref = 0;
1864                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1865                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1866                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1867                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1868                                 path_arr_ptr[k] = path_conv_10_ref;
1869                         }
1870                         
1871         return path_arr;
1872 }
1873 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id"))) TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id(uint32_t ptr) {
1874         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1875         assert(obj->tag == LDKEvent_OpenChannelRequest);
1876                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1877                         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
1878         return temporary_channel_id_arr;
1879 }
1880 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id"))) TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id(uint32_t ptr) {
1881         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1882         assert(obj->tag == LDKEvent_OpenChannelRequest);
1883                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1884                         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
1885         return counterparty_node_id_arr;
1886 }
1887 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_funding_satoshis"))) TS_LDKEvent_OpenChannelRequest_get_funding_satoshis(uint32_t ptr) {
1888         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1889         assert(obj->tag == LDKEvent_OpenChannelRequest);
1890         return obj->open_channel_request.funding_satoshis;
1891 }
1892 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_push_msat"))) TS_LDKEvent_OpenChannelRequest_get_push_msat(uint32_t ptr) {
1893         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1894         assert(obj->tag == LDKEvent_OpenChannelRequest);
1895         return obj->open_channel_request.push_msat;
1896 }
1897 uint32_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_channel_type"))) TS_LDKEvent_OpenChannelRequest_get_channel_type(uint32_t ptr) {
1898         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1899         assert(obj->tag == LDKEvent_OpenChannelRequest);
1900                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
1901                         uint32_t channel_type_ref = 0;
1902                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1903                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1904                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
1905                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
1906         return channel_type_ref;
1907 }
1908 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
1909         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1910         switch(obj->tag) {
1911                 case LDKCOption_EventZ_Some: return 0;
1912                 case LDKCOption_EventZ_None: return 1;
1913                 default: abort();
1914         }
1915 }
1916 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
1917         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1918         assert(obj->tag == LDKCOption_EventZ_Some);
1919                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1920         return some_ref;
1921 }
1922 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1923 CHECK(owner->result_ok);
1924         return COption_EventZ_clone(&*owner->contents.result);
1925 }
1926 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
1927         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1928         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
1929         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
1930         uint32_t ret_ref = (uintptr_t)ret_copy;
1931         return ret_ref;
1932 }
1933
1934 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1935 CHECK(!owner->result_ok);
1936         return DecodeError_clone(&*owner->contents.err);
1937 }
1938 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
1939         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1940         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
1941         uint32_t ret_ref = 0;
1942         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1943         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1945         ret_ref = (uintptr_t)ret_var.inner;
1946         if (ret_var.is_owned) {
1947                 ret_ref |= 1;
1948         }
1949         return ret_ref;
1950 }
1951
1952 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
1953         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1954         switch(obj->tag) {
1955                 case LDKErrorAction_DisconnectPeer: return 0;
1956                 case LDKErrorAction_IgnoreError: return 1;
1957                 case LDKErrorAction_IgnoreAndLog: return 2;
1958                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
1959                 case LDKErrorAction_SendErrorMessage: return 4;
1960                 case LDKErrorAction_SendWarningMessage: return 5;
1961                 default: abort();
1962         }
1963 }
1964 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
1965         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1966         assert(obj->tag == LDKErrorAction_DisconnectPeer);
1967                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1968                         uint32_t msg_ref = 0;
1969                         if ((uintptr_t)msg_var.inner > 4096) {
1970                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1971                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1972                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1973                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
1974                         }
1975         return msg_ref;
1976 }
1977 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
1978         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1979         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
1980                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1981         return ignore_and_log_conv;
1982 }
1983 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
1984         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1985         assert(obj->tag == LDKErrorAction_SendErrorMessage);
1986                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1987                         uint32_t msg_ref = 0;
1988                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1989                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1990                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1991                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1992         return msg_ref;
1993 }
1994 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_msg"))) TS_LDKErrorAction_SendWarningMessage_get_msg(uint32_t ptr) {
1995         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1996         assert(obj->tag == LDKErrorAction_SendWarningMessage);
1997                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
1998                         uint32_t msg_ref = 0;
1999                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2000                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2001                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2002                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2003         return msg_ref;
2004 }
2005 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_log_level"))) TS_LDKErrorAction_SendWarningMessage_get_log_level(uint32_t ptr) {
2006         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2007         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2008                         uint32_t log_level_conv = LDKLevel_to_js(obj->send_warning_message.log_level);
2009         return log_level_conv;
2010 }
2011 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
2012         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2013         switch(obj->tag) {
2014                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
2015                 case LDKMessageSendEvent_SendOpenChannel: return 1;
2016                 case LDKMessageSendEvent_SendFundingCreated: return 2;
2017                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2018                 case LDKMessageSendEvent_SendFundingLocked: return 4;
2019                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2020                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2021                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2022                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2023                 case LDKMessageSendEvent_SendShutdown: return 9;
2024                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2025                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
2026                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
2027                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2028                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2029                 case LDKMessageSendEvent_HandleError: return 15;
2030                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2031                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2032                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2033                 case LDKMessageSendEvent_SendGossipTimestampFilter: return 19;
2034                 default: abort();
2035         }
2036 }
2037 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2038         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2039         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2040                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2041                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2042         return node_id_arr;
2043 }
2044 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2045         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2046         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2047                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2048                         uint32_t msg_ref = 0;
2049                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2050                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2051                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2052                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2053         return msg_ref;
2054 }
2055 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2056         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2057         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2058                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2059                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2060         return node_id_arr;
2061 }
2062 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2063         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2064         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2065                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2066                         uint32_t msg_ref = 0;
2067                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2068                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2069                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2070                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2071         return msg_ref;
2072 }
2073 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2074         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2075         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2076                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2077                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2078         return node_id_arr;
2079 }
2080 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2081         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2082         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2083                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2084                         uint32_t msg_ref = 0;
2085                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2086                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2087                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2088                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2089         return msg_ref;
2090 }
2091 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2092         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2093         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2094                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2095                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2096         return node_id_arr;
2097 }
2098 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2099         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2100         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2101                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2102                         uint32_t msg_ref = 0;
2103                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2104                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2105                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2106                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2107         return msg_ref;
2108 }
2109 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_node_id"))) TS_LDKMessageSendEvent_SendFundingLocked_get_node_id(uint32_t ptr) {
2110         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2111         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2112                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2113                         memcpy(node_id_arr->elems, obj->send_funding_locked.node_id.compressed_form, 33);
2114         return node_id_arr;
2115 }
2116 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_msg"))) TS_LDKMessageSendEvent_SendFundingLocked_get_msg(uint32_t ptr) {
2117         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2118         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2119                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2120                         uint32_t msg_ref = 0;
2121                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2122                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2123                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2124                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2125         return msg_ref;
2126 }
2127 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2128         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2129         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2130                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2131                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2132         return node_id_arr;
2133 }
2134 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
2135         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2136         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2137                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2138                         uint32_t msg_ref = 0;
2139                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2140                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2141                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2142                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2143         return msg_ref;
2144 }
2145 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
2146         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2147         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2148                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2149                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
2150         return node_id_arr;
2151 }
2152 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
2153         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2154         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2155                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2156                         uint32_t updates_ref = 0;
2157                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2158                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2159                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2160                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2161         return updates_ref;
2162 }
2163 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
2164         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2165         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2166                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2167                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
2168         return node_id_arr;
2169 }
2170 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
2171         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2172         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2173                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2174                         uint32_t msg_ref = 0;
2175                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2176                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2177                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2178                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2179         return msg_ref;
2180 }
2181 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
2182         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2183         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2184                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2185                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
2186         return node_id_arr;
2187 }
2188 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
2189         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2190         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2191                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2192                         uint32_t msg_ref = 0;
2193                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2194                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2195                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2196                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2197         return msg_ref;
2198 }
2199 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
2200         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2201         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2202                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2203                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
2204         return node_id_arr;
2205 }
2206 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
2207         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2208         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2209                         LDKShutdown msg_var = obj->send_shutdown.msg;
2210                         uint32_t msg_ref = 0;
2211                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2212                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2213                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2214                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2215         return msg_ref;
2216 }
2217 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
2218         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2219         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2220                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2221                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
2222         return node_id_arr;
2223 }
2224 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
2225         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2226         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2227                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2228                         uint32_t msg_ref = 0;
2229                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2230                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2231                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2232                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2233         return msg_ref;
2234 }
2235 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
2236         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2237         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2238                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2239                         uint32_t msg_ref = 0;
2240                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2241                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2242                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2243                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2244         return msg_ref;
2245 }
2246 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
2247         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2248         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2249                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2250                         uint32_t update_msg_ref = 0;
2251                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2252                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2253                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2254                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2255         return update_msg_ref;
2256 }
2257 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
2258         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2259         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
2260                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2261                         uint32_t msg_ref = 0;
2262                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2263                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2264                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2265                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2266         return msg_ref;
2267 }
2268 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
2269         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2270         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
2271                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2272                         uint32_t msg_ref = 0;
2273                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2274                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2275                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2276                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2277         return msg_ref;
2278 }
2279 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
2280         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2281         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2282                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2283                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
2284         return node_id_arr;
2285 }
2286 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
2287         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2288         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2289                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2290                         uint32_t msg_ref = 0;
2291                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2292                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2293                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2294                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2295         return msg_ref;
2296 }
2297 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
2298         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2299         assert(obj->tag == LDKMessageSendEvent_HandleError);
2300                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2301                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
2302         return node_id_arr;
2303 }
2304 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
2305         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2306         assert(obj->tag == LDKMessageSendEvent_HandleError);
2307                         uint32_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2308         return action_ref;
2309 }
2310 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
2311         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2312         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2313                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2314                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
2315         return node_id_arr;
2316 }
2317 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
2318         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2319         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2320                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2321                         uint32_t msg_ref = 0;
2322                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2323                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2324                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2325                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2326         return msg_ref;
2327 }
2328 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
2329         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2330         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2331                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2332                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
2333         return node_id_arr;
2334 }
2335 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
2336         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2337         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2338                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2339                         uint32_t msg_ref = 0;
2340                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2341                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2342                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2343                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2344         return msg_ref;
2345 }
2346 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
2347         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2348         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2349                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2350                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
2351         return node_id_arr;
2352 }
2353 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
2354         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2355         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2356                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2357                         uint32_t msg_ref = 0;
2358                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2359                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2360                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2361                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2362         return msg_ref;
2363 }
2364 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id(uint32_t ptr) {
2365         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2366         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2367                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2368                         memcpy(node_id_arr->elems, obj->send_gossip_timestamp_filter.node_id.compressed_form, 33);
2369         return node_id_arr;
2370 }
2371 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg(uint32_t ptr) {
2372         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2373         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2374                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
2375                         uint32_t msg_ref = 0;
2376                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2377                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2378                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2379                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2380         return msg_ref;
2381 }
2382 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2383         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2384         for (size_t i = 0; i < ret.datalen; i++) {
2385                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2386         }
2387         return ret;
2388 }
2389 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2390 CHECK(owner->result_ok);
2391         return FixedPenaltyScorer_clone(&*owner->contents.result);
2392 }
2393 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(uint32_t owner) {
2394         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2395         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
2396         uint32_t ret_ref = 0;
2397         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2398         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2400         ret_ref = (uintptr_t)ret_var.inner;
2401         if (ret_var.is_owned) {
2402                 ret_ref |= 1;
2403         }
2404         return ret_ref;
2405 }
2406
2407 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2408 CHECK(!owner->result_ok);
2409         return DecodeError_clone(&*owner->contents.err);
2410 }
2411 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(uint32_t owner) {
2412         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2413         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
2414         uint32_t ret_ref = 0;
2415         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2416         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2418         ret_ref = (uintptr_t)ret_var.inner;
2419         if (ret_var.is_owned) {
2420                 ret_ref |= 1;
2421         }
2422         return ret_ref;
2423 }
2424
2425 static inline struct LDKScoringParameters CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2426 CHECK(owner->result_ok);
2427         return ScoringParameters_clone(&*owner->contents.result);
2428 }
2429 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t owner) {
2430         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2431         LDKScoringParameters ret_var = CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
2432         uint32_t ret_ref = 0;
2433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2436         ret_ref = (uintptr_t)ret_var.inner;
2437         if (ret_var.is_owned) {
2438                 ret_ref |= 1;
2439         }
2440         return ret_ref;
2441 }
2442
2443 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2444 CHECK(!owner->result_ok);
2445         return DecodeError_clone(&*owner->contents.err);
2446 }
2447 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_err"))) TS_CResult_ScoringParametersDecodeErrorZ_get_err(uint32_t owner) {
2448         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2449         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
2450         uint32_t ret_ref = 0;
2451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2454         ret_ref = (uintptr_t)ret_var.inner;
2455         if (ret_var.is_owned) {
2456                 ret_ref |= 1;
2457         }
2458         return ret_ref;
2459 }
2460
2461 static inline struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2462 CHECK(owner->result_ok);
2463         return &*owner->contents.result;
2464 }
2465 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_get_ok"))) TS_CResult_ScorerDecodeErrorZ_get_ok(uint32_t owner) {
2466         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2467         LDKScorer ret_var = *CResult_ScorerDecodeErrorZ_get_ok(owner_conv);
2468         uint32_t ret_ref = 0;
2469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2472         ret_ref = (uintptr_t)ret_var.inner & ~1;
2473         return ret_ref;
2474 }
2475
2476 static inline struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2477 CHECK(!owner->result_ok);
2478         return DecodeError_clone(&*owner->contents.err);
2479 }
2480 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_get_err"))) TS_CResult_ScorerDecodeErrorZ_get_err(uint32_t owner) {
2481         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2482         LDKDecodeError ret_var = CResult_ScorerDecodeErrorZ_get_err(owner_conv);
2483         uint32_t ret_ref = 0;
2484         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2485         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2487         ret_ref = (uintptr_t)ret_var.inner;
2488         if (ret_var.is_owned) {
2489                 ret_ref |= 1;
2490         }
2491         return ret_ref;
2492 }
2493
2494 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2495 CHECK(owner->result_ok);
2496         return &*owner->contents.result;
2497 }
2498 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(uint32_t owner) {
2499         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2500         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
2501         uint32_t ret_ref = 0;
2502         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2503         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2505         ret_ref = (uintptr_t)ret_var.inner & ~1;
2506         return ret_ref;
2507 }
2508
2509 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2510 CHECK(!owner->result_ok);
2511         return DecodeError_clone(&*owner->contents.err);
2512 }
2513 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err(uint32_t owner) {
2514         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2515         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
2516         uint32_t ret_ref = 0;
2517         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2518         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2520         ret_ref = (uintptr_t)ret_var.inner;
2521         if (ret_var.is_owned) {
2522                 ret_ref |= 1;
2523         }
2524         return ret_ref;
2525 }
2526
2527 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2528 CHECK(owner->result_ok);
2529         return InitFeatures_clone(&*owner->contents.result);
2530 }
2531 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2532         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2533         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2534         uint32_t ret_ref = 0;
2535         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2536         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2538         ret_ref = (uintptr_t)ret_var.inner;
2539         if (ret_var.is_owned) {
2540                 ret_ref |= 1;
2541         }
2542         return ret_ref;
2543 }
2544
2545 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2546 CHECK(!owner->result_ok);
2547         return DecodeError_clone(&*owner->contents.err);
2548 }
2549 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2550         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2551         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2552         uint32_t ret_ref = 0;
2553         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2554         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2556         ret_ref = (uintptr_t)ret_var.inner;
2557         if (ret_var.is_owned) {
2558                 ret_ref |= 1;
2559         }
2560         return ret_ref;
2561 }
2562
2563 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2564 CHECK(owner->result_ok);
2565         return ChannelFeatures_clone(&*owner->contents.result);
2566 }
2567 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2568         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2569         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2570         uint32_t ret_ref = 0;
2571         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2572         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2573         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2574         ret_ref = (uintptr_t)ret_var.inner;
2575         if (ret_var.is_owned) {
2576                 ret_ref |= 1;
2577         }
2578         return ret_ref;
2579 }
2580
2581 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2582 CHECK(!owner->result_ok);
2583         return DecodeError_clone(&*owner->contents.err);
2584 }
2585 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2586         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2587         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2588         uint32_t ret_ref = 0;
2589         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2590         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2592         ret_ref = (uintptr_t)ret_var.inner;
2593         if (ret_var.is_owned) {
2594                 ret_ref |= 1;
2595         }
2596         return ret_ref;
2597 }
2598
2599 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2600 CHECK(owner->result_ok);
2601         return NodeFeatures_clone(&*owner->contents.result);
2602 }
2603 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2604         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2605         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2606         uint32_t ret_ref = 0;
2607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2610         ret_ref = (uintptr_t)ret_var.inner;
2611         if (ret_var.is_owned) {
2612                 ret_ref |= 1;
2613         }
2614         return ret_ref;
2615 }
2616
2617 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2618 CHECK(!owner->result_ok);
2619         return DecodeError_clone(&*owner->contents.err);
2620 }
2621 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2622         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2623         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
2624         uint32_t ret_ref = 0;
2625         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2626         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2628         ret_ref = (uintptr_t)ret_var.inner;
2629         if (ret_var.is_owned) {
2630                 ret_ref |= 1;
2631         }
2632         return ret_ref;
2633 }
2634
2635 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2636 CHECK(owner->result_ok);
2637         return InvoiceFeatures_clone(&*owner->contents.result);
2638 }
2639 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2640         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2641         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
2642         uint32_t ret_ref = 0;
2643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2646         ret_ref = (uintptr_t)ret_var.inner;
2647         if (ret_var.is_owned) {
2648                 ret_ref |= 1;
2649         }
2650         return ret_ref;
2651 }
2652
2653 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2654 CHECK(!owner->result_ok);
2655         return DecodeError_clone(&*owner->contents.err);
2656 }
2657 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2658         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2659         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
2660         uint32_t ret_ref = 0;
2661         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2662         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2664         ret_ref = (uintptr_t)ret_var.inner;
2665         if (ret_var.is_owned) {
2666                 ret_ref |= 1;
2667         }
2668         return ret_ref;
2669 }
2670
2671 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2672 CHECK(owner->result_ok);
2673         return ChannelTypeFeatures_clone(&*owner->contents.result);
2674 }
2675 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2676         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2677         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
2678         uint32_t ret_ref = 0;
2679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2680         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2682         ret_ref = (uintptr_t)ret_var.inner;
2683         if (ret_var.is_owned) {
2684                 ret_ref |= 1;
2685         }
2686         return ret_ref;
2687 }
2688
2689 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2690 CHECK(!owner->result_ok);
2691         return DecodeError_clone(&*owner->contents.err);
2692 }
2693 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2694         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2695         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
2696         uint32_t ret_ref = 0;
2697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2700         ret_ref = (uintptr_t)ret_var.inner;
2701         if (ret_var.is_owned) {
2702                 ret_ref |= 1;
2703         }
2704         return ret_ref;
2705 }
2706
2707 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2708 CHECK(owner->result_ok);
2709         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
2710 }
2711 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2712         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2713         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2714         uint32_t ret_ref = 0;
2715         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2716         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2718         ret_ref = (uintptr_t)ret_var.inner;
2719         if (ret_var.is_owned) {
2720                 ret_ref |= 1;
2721         }
2722         return ret_ref;
2723 }
2724
2725 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2726 CHECK(!owner->result_ok);
2727         return DecodeError_clone(&*owner->contents.err);
2728 }
2729 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2730         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2731         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2732         uint32_t ret_ref = 0;
2733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2736         ret_ref = (uintptr_t)ret_var.inner;
2737         if (ret_var.is_owned) {
2738                 ret_ref |= 1;
2739         }
2740         return ret_ref;
2741 }
2742
2743 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2744 CHECK(owner->result_ok);
2745         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
2746 }
2747 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2748         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2749         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2750         uint32_t ret_ref = 0;
2751         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2752         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2754         ret_ref = (uintptr_t)ret_var.inner;
2755         if (ret_var.is_owned) {
2756                 ret_ref |= 1;
2757         }
2758         return ret_ref;
2759 }
2760
2761 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2762 CHECK(!owner->result_ok);
2763         return DecodeError_clone(&*owner->contents.err);
2764 }
2765 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2766         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2767         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2768         uint32_t ret_ref = 0;
2769         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2770         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2772         ret_ref = (uintptr_t)ret_var.inner;
2773         if (ret_var.is_owned) {
2774                 ret_ref |= 1;
2775         }
2776         return ret_ref;
2777 }
2778
2779 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2780 CHECK(owner->result_ok);
2781         return SpendableOutputDescriptor_clone(&*owner->contents.result);
2782 }
2783 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2784         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2785         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
2786         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2787         uint32_t ret_ref = (uintptr_t)ret_copy;
2788         return ret_ref;
2789 }
2790
2791 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2792 CHECK(!owner->result_ok);
2793         return DecodeError_clone(&*owner->contents.err);
2794 }
2795 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2796         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2797         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2798         uint32_t ret_ref = 0;
2799         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2800         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2802         ret_ref = (uintptr_t)ret_var.inner;
2803         if (ret_var.is_owned) {
2804                 ret_ref |= 1;
2805         }
2806         return ret_ref;
2807 }
2808
2809 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
2810         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
2811         for (size_t i = 0; i < ret.datalen; i++) {
2812                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2813         }
2814         return ret;
2815 }
2816 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2817         return owner->a;
2818 }
2819 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
2820         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2821         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2822         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
2823         return ret_arr;
2824 }
2825
2826 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2827         return owner->b;
2828 }
2829 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
2830         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2831         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
2832         ptrArray ret_arr = NULL;
2833         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
2834         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
2835         for (size_t m = 0; m < ret_var.datalen; m++) {
2836                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
2837                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
2838                 ret_arr_ptr[m] = ret_conv_12_arr;
2839         }
2840         
2841         return ret_arr;
2842 }
2843
2844 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2845 CHECK(owner->result_ok);
2846         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
2847 }
2848 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
2849         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2850         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2851         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
2852         return ((uint32_t)ret_conv);
2853 }
2854
2855 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2856 CHECK(!owner->result_ok);
2857         return *owner->contents.err;
2858 }
2859 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
2860         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2861         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
2862 }
2863
2864 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2865 CHECK(owner->result_ok);
2866         return *owner->contents.result;
2867 }
2868 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
2869         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2870         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2871         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
2872         return ret_arr;
2873 }
2874
2875 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2876 CHECK(!owner->result_ok);
2877         return *owner->contents.err;
2878 }
2879 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
2880         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2881         CResult_SignatureNoneZ_get_err(owner_conv);
2882 }
2883
2884 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2885         return owner->a;
2886 }
2887 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint32_t owner) {
2888         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2889         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2890         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
2891         return ret_arr;
2892 }
2893
2894 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2895         return owner->b;
2896 }
2897 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint32_t owner) {
2898         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2899         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2900         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
2901         return ret_arr;
2902 }
2903
2904 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2905 CHECK(owner->result_ok);
2906         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
2907 }
2908 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint32_t owner) {
2909         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2910         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
2911         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
2912         return ((uint32_t)ret_conv);
2913 }
2914
2915 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2916 CHECK(!owner->result_ok);
2917         return *owner->contents.err;
2918 }
2919 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint32_t owner) {
2920         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2921         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
2922 }
2923
2924 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2925 CHECK(owner->result_ok);
2926         return *owner->contents.result;
2927 }
2928 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint32_t owner) {
2929         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2930         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
2931         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
2932         return ret_arr;
2933 }
2934
2935 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2936 CHECK(!owner->result_ok);
2937         return *owner->contents.err;
2938 }
2939 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint32_t owner) {
2940         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2941         CResult_SecretKeyNoneZ_get_err(owner_conv);
2942 }
2943
2944 typedef struct LDKBaseSign_JCalls {
2945         atomic_size_t refcnt;
2946         uint32_t instance_ptr;
2947 } LDKBaseSign_JCalls;
2948 static void LDKBaseSign_JCalls_free(void* this_arg) {
2949         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2950         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2951                 FREE(j_calls);
2952         }
2953 }
2954 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2955         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2956         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 0, (uint32_t)idx);
2957         LDKPublicKey ret_ref;
2958         CHECK(ret->arr_len == 33);
2959         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
2960         return ret_ref;
2961 }
2962 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2963         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2964         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 1, (uint32_t)idx);
2965         LDKThirtyTwoBytes ret_ref;
2966         CHECK(ret->arr_len == 32);
2967         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
2968         return ret_ref;
2969 }
2970 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
2971         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2972         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
2973         uint32_t holder_tx_ref = 0;
2974         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
2975         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2976         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2977         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
2978         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
2979         if (holder_tx_var.is_owned) {
2980                 holder_tx_ref |= 1;
2981         }
2982         LDKCVec_PaymentPreimageZ preimages_var = preimages;
2983         ptrArray preimages_arr = NULL;
2984         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
2985         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
2986         for (size_t m = 0; m < preimages_var.datalen; m++) {
2987                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
2988                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
2989                 preimages_arr_ptr[m] = preimages_conv_12_arr;
2990         }
2991         
2992         FREE(preimages_var.data);
2993         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 2, (uint32_t)holder_tx_ref, (uint32_t)preimages_arr);
2994         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2995         CHECK_ACCESS(ret_ptr);
2996         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2997         FREE((void*)ret);
2998         return ret_conv;
2999 }
3000 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3001         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3002         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 3);
3003         LDKThirtyTwoBytes ret_ref;
3004         CHECK(ret->arr_len == 32);
3005         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3006         return ret_ref;
3007 }
3008 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3009         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3010         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3011         uint32_t commitment_tx_ref = 0;
3012         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
3013         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3014         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3015         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3016         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3017         if (commitment_tx_var.is_owned) {
3018                 commitment_tx_ref |= 1;
3019         }
3020         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3021         ptrArray preimages_arr = NULL;
3022         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3023         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3024         for (size_t m = 0; m < preimages_var.datalen; m++) {
3025                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3026                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3027                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3028         }
3029         
3030         FREE(preimages_var.data);
3031         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 4, (uint32_t)commitment_tx_ref, (uint32_t)preimages_arr);
3032         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3033         CHECK_ACCESS(ret_ptr);
3034         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3035         FREE((void*)ret);
3036         return ret_conv;
3037 }
3038 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3039         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3040         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
3041         memcpy(secret_arr->elems, *secret, 32);
3042         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 5, (uint32_t)idx, (uint32_t)secret_arr);
3043         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3044         CHECK_ACCESS(ret_ptr);
3045         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3046         FREE((void*)ret);
3047         return ret_conv;
3048 }
3049 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3050         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3051         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3052         uint32_t commitment_tx_ref = 0;
3053         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
3054         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3055         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3056         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3057         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3058         if (commitment_tx_var.is_owned) {
3059                 commitment_tx_ref |= 1;
3060         }
3061         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 6, (uint32_t)commitment_tx_ref);
3062         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3063         CHECK_ACCESS(ret_ptr);
3064         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3065         FREE((void*)ret);
3066         return ret_conv;
3067 }
3068 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]) {
3069         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3070         LDKTransaction justice_tx_var = justice_tx;
3071         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3072         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3073         Transaction_free(justice_tx_var);
3074         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3075         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3076         uint32_t ret = js_invoke_function_4(j_calls->instance_ptr, 7, (uint32_t)justice_tx_arr, (uint32_t)input, (uint32_t)amount, (uint32_t)per_commitment_key_arr);
3077         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3078         CHECK_ACCESS(ret_ptr);
3079         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3080         FREE((void*)ret);
3081         return ret_conv;
3082 }
3083 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) {
3084         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3085         LDKTransaction justice_tx_var = justice_tx;
3086         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3087         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3088         Transaction_free(justice_tx_var);
3089         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3090         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3091         LDKHTLCOutputInCommitment htlc_var = *htlc;
3092         uint32_t htlc_ref = 0;
3093         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3094         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3095         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3096         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3097         htlc_ref = (uintptr_t)htlc_var.inner;
3098         if (htlc_var.is_owned) {
3099                 htlc_ref |= 1;
3100         }
3101         uint32_t ret = js_invoke_function_5(j_calls->instance_ptr, 8, (uint32_t)justice_tx_arr, (uint32_t)input, (uint32_t)amount, (uint32_t)per_commitment_key_arr, (uint32_t)htlc_ref);
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_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) {
3109         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3110         LDKTransaction htlc_tx_var = htlc_tx;
3111         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
3112         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
3113         Transaction_free(htlc_tx_var);
3114         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
3115         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
3116         LDKHTLCOutputInCommitment htlc_var = *htlc;
3117         uint32_t htlc_ref = 0;
3118         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3119         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3120         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3121         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3122         htlc_ref = (uintptr_t)htlc_var.inner;
3123         if (htlc_var.is_owned) {
3124                 htlc_ref |= 1;
3125         }
3126         uint32_t ret = js_invoke_function_5(j_calls->instance_ptr, 9, (uint32_t)htlc_tx_arr, (uint32_t)input, (uint32_t)amount, (uint32_t)per_commitment_point_arr, (uint32_t)htlc_ref);
3127         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3128         CHECK_ACCESS(ret_ptr);
3129         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3130         FREE((void*)ret);
3131         return ret_conv;
3132 }
3133 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3134         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3135         LDKClosingTransaction closing_tx_var = *closing_tx;
3136         uint32_t closing_tx_ref = 0;
3137         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
3138         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3139         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3140         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3141         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
3142         if (closing_tx_var.is_owned) {
3143                 closing_tx_ref |= 1;
3144         }
3145         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 10, (uint32_t)closing_tx_ref);
3146         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3147         CHECK_ACCESS(ret_ptr);
3148         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3149         FREE((void*)ret);
3150         return ret_conv;
3151 }
3152 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3153         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3154         LDKUnsignedChannelAnnouncement msg_var = *msg;
3155         uint32_t msg_ref = 0;
3156         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
3157         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3158         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3159         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3160         msg_ref = (uintptr_t)msg_var.inner;
3161         if (msg_var.is_owned) {
3162                 msg_ref |= 1;
3163         }
3164         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 11, (uint32_t)msg_ref);
3165         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3166         CHECK_ACCESS(ret_ptr);
3167         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
3168         FREE((void*)ret);
3169         return ret_conv;
3170 }
3171 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3172         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3173         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3174         uint32_t channel_parameters_ref = 0;
3175         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
3176         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3177         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3178         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
3179         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
3180         if (channel_parameters_var.is_owned) {
3181                 channel_parameters_ref |= 1;
3182         }
3183         js_invoke_function_1(j_calls->instance_ptr, 12, (uint32_t)channel_parameters_ref);
3184 }
3185 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
3186         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
3187         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3188 }
3189 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
3190         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
3191         atomic_init(&calls->refcnt, 1);
3192         calls->instance_ptr = o;
3193
3194         LDKChannelPublicKeys pubkeys_conv;
3195         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3196         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3197         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3198
3199         LDKBaseSign ret = {
3200                 .this_arg = (void*) calls,
3201                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
3202                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
3203                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
3204                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
3205                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
3206                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
3207                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
3208                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
3209                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
3210                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
3211                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
3212                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
3213                 .ready_channel = ready_channel_LDKBaseSign_jcall,
3214                 .free = LDKBaseSign_JCalls_free,
3215                 .pubkeys = pubkeys_conv,
3216                 .set_pubkeys = NULL,
3217         };
3218         return ret;
3219 }
3220 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
3221         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3222         *res_ptr = LDKBaseSign_init(o, pubkeys);
3223         return (long)res_ptr;
3224 }
3225 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
3226         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3227         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3228         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3229         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
3230         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
3231         return ret_arr;
3232 }
3233
3234 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
3235         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3236         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3237         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3238         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3239         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
3240         return ret_arr;
3241 }
3242
3243 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) {
3244         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3245         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3246         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3247         LDKHolderCommitmentTransaction holder_tx_conv;
3248         holder_tx_conv.inner = (void*)(holder_tx & (~1));
3249         holder_tx_conv.is_owned = false;
3250         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
3251         LDKCVec_PaymentPreimageZ preimages_constr;
3252         preimages_constr.datalen = preimages->arr_len;
3253         if (preimages_constr.datalen > 0)
3254                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3255         else
3256                 preimages_constr.data = NULL;
3257         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3258         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3259                 int8_tArray preimages_conv_12 = preimages_vals[m];
3260                 LDKThirtyTwoBytes preimages_conv_12_ref;
3261                 CHECK(preimages_conv_12->arr_len == 32);
3262                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3263                 preimages_constr.data[m] = preimages_conv_12_ref;
3264         }
3265         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3266         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
3267         return (uint32_t)ret_conv;
3268 }
3269
3270 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
3271         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3272         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3273         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3274         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3275         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
3276         return ret_arr;
3277 }
3278
3279 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) {
3280         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3281         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3282         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3283         LDKCommitmentTransaction commitment_tx_conv;
3284         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3285         commitment_tx_conv.is_owned = false;
3286         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3287         LDKCVec_PaymentPreimageZ preimages_constr;
3288         preimages_constr.datalen = preimages->arr_len;
3289         if (preimages_constr.datalen > 0)
3290                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3291         else
3292                 preimages_constr.data = NULL;
3293         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3294         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3295                 int8_tArray preimages_conv_12 = preimages_vals[m];
3296                 LDKThirtyTwoBytes preimages_conv_12_ref;
3297                 CHECK(preimages_conv_12->arr_len == 32);
3298                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3299                 preimages_constr.data[m] = preimages_conv_12_ref;
3300         }
3301         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3302         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
3303         return (uint32_t)ret_conv;
3304 }
3305
3306 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) {
3307         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3308         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3309         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3310         unsigned char secret_arr[32];
3311         CHECK(secret->arr_len == 32);
3312         memcpy(secret_arr, secret->elems, 32); FREE(secret);
3313         unsigned char (*secret_ref)[32] = &secret_arr;
3314         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3315         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
3316         return (uint32_t)ret_conv;
3317 }
3318
3319 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) {
3320         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3321         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3322         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3323         LDKHolderCommitmentTransaction commitment_tx_conv;
3324         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3325         commitment_tx_conv.is_owned = false;
3326         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3327         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3328         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
3329         return (uint32_t)ret_conv;
3330 }
3331
3332 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) {
3333         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3334         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3335         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3336         LDKTransaction justice_tx_ref;
3337         justice_tx_ref.datalen = justice_tx->arr_len;
3338         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3339         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3340         justice_tx_ref.data_is_owned = true;
3341         unsigned char per_commitment_key_arr[32];
3342         CHECK(per_commitment_key->arr_len == 32);
3343         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3344         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3345         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3346         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
3347         return (uint32_t)ret_conv;
3348 }
3349
3350 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) {
3351         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3352         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3353         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3354         LDKTransaction justice_tx_ref;
3355         justice_tx_ref.datalen = justice_tx->arr_len;
3356         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3357         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3358         justice_tx_ref.data_is_owned = true;
3359         unsigned char per_commitment_key_arr[32];
3360         CHECK(per_commitment_key->arr_len == 32);
3361         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3362         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3363         LDKHTLCOutputInCommitment htlc_conv;
3364         htlc_conv.inner = (void*)(htlc & (~1));
3365         htlc_conv.is_owned = false;
3366         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3367         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3368         *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);
3369         return (uint32_t)ret_conv;
3370 }
3371
3372 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) {
3373         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3374         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3375         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3376         LDKTransaction htlc_tx_ref;
3377         htlc_tx_ref.datalen = htlc_tx->arr_len;
3378         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
3379         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
3380         htlc_tx_ref.data_is_owned = true;
3381         LDKPublicKey per_commitment_point_ref;
3382         CHECK(per_commitment_point->arr_len == 33);
3383         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
3384         LDKHTLCOutputInCommitment htlc_conv;
3385         htlc_conv.inner = (void*)(htlc & (~1));
3386         htlc_conv.is_owned = false;
3387         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3388         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3389         *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);
3390         return (uint32_t)ret_conv;
3391 }
3392
3393 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
3394         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3395         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3396         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3397         LDKClosingTransaction closing_tx_conv;
3398         closing_tx_conv.inner = (void*)(closing_tx & (~1));
3399         closing_tx_conv.is_owned = false;
3400         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
3401         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3402         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
3403         return (uint32_t)ret_conv;
3404 }
3405
3406 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
3407         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3408         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3409         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3410         LDKUnsignedChannelAnnouncement msg_conv;
3411         msg_conv.inner = (void*)(msg & (~1));
3412         msg_conv.is_owned = false;
3413         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
3414         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
3415         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3416         return (uint32_t)ret_conv;
3417 }
3418
3419 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
3420         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3421         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3422         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3423         LDKChannelTransactionParameters channel_parameters_conv;
3424         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
3425         channel_parameters_conv.is_owned = false;
3426         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
3427         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
3428 }
3429
3430 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
3431         if (this_arg->set_pubkeys != NULL)
3432                 this_arg->set_pubkeys(this_arg);
3433         return this_arg->pubkeys;
3434 }
3435 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
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         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
3440         uint32_t ret_ref = 0;
3441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3444         ret_ref = (uintptr_t)ret_var.inner;
3445         if (ret_var.is_owned) {
3446                 ret_ref |= 1;
3447         }
3448         return ret_ref;
3449 }
3450
3451 typedef struct LDKSign_JCalls {
3452         atomic_size_t refcnt;
3453         uint32_t instance_ptr;
3454         LDKBaseSign_JCalls* BaseSign;
3455 } LDKSign_JCalls;
3456 static void LDKSign_JCalls_free(void* this_arg) {
3457         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3458         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3459                 FREE(j_calls);
3460         }
3461 }
3462 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
3463         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3464         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 13);
3465         LDKCVec_u8Z ret_ref;
3466         ret_ref.datalen = ret->arr_len;
3467         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3468         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
3469         return ret_ref;
3470 }
3471 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
3472         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
3473         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3474         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
3475 }
3476 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3477         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
3478         atomic_init(&calls->refcnt, 1);
3479         calls->instance_ptr = o;
3480
3481         LDKChannelPublicKeys pubkeys_conv;
3482         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3483         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3484         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3485
3486         LDKSign ret = {
3487                 .this_arg = (void*) calls,
3488                 .write = write_LDKSign_jcall,
3489                 .cloned = LDKSign_JCalls_cloned,
3490                 .free = LDKSign_JCalls_free,
3491                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
3492         };
3493         calls->BaseSign = ret.BaseSign.this_arg;
3494         return ret;
3495 }
3496 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3497         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
3498         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
3499         return (long)res_ptr;
3500 }
3501 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
3502         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3503         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3504         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
3505         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3506         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3507         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3508         CVec_u8Z_free(ret_var);
3509         return ret_arr;
3510 }
3511
3512 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3513 CHECK(owner->result_ok);
3514         return Sign_clone(&*owner->contents.result);
3515 }
3516 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
3517         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3518         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3519         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
3520         return (uint32_t)ret_ret;
3521 }
3522
3523 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3524 CHECK(!owner->result_ok);
3525         return DecodeError_clone(&*owner->contents.err);
3526 }
3527 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
3528         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3529         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
3530         uint32_t ret_ref = 0;
3531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3534         ret_ref = (uintptr_t)ret_var.inner;
3535         if (ret_var.is_owned) {
3536                 ret_ref |= 1;
3537         }
3538         return ret_ref;
3539 }
3540
3541 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3542 CHECK(owner->result_ok);
3543         return *owner->contents.result;
3544 }
3545 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
3546         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3547         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
3548         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
3549         return ret_arr;
3550 }
3551
3552 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3553 CHECK(!owner->result_ok);
3554         return *owner->contents.err;
3555 }
3556 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
3557         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3558         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
3559 }
3560
3561 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3562         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3563         for (size_t i = 0; i < ret.datalen; i++) {
3564                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3565         }
3566         return ret;
3567 }
3568 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3569 CHECK(owner->result_ok);
3570         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
3571 }
3572 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
3573         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3574         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
3575         ptrArray ret_arr = NULL;
3576         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3577         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
3578         for (size_t m = 0; m < ret_var.datalen; m++) {
3579                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
3580                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
3581                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
3582                 CVec_u8Z_free(ret_conv_12_var);
3583                 ret_arr_ptr[m] = ret_conv_12_arr;
3584         }
3585         
3586         FREE(ret_var.data);
3587         return ret_arr;
3588 }
3589
3590 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3591 CHECK(!owner->result_ok);
3592         return *owner->contents.err;
3593 }
3594 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
3595         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3596         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
3597 }
3598
3599 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3600 CHECK(owner->result_ok);
3601         return InMemorySigner_clone(&*owner->contents.result);
3602 }
3603 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
3604         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3605         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
3606         uint32_t ret_ref = 0;
3607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3610         ret_ref = (uintptr_t)ret_var.inner;
3611         if (ret_var.is_owned) {
3612                 ret_ref |= 1;
3613         }
3614         return ret_ref;
3615 }
3616
3617 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3618 CHECK(!owner->result_ok);
3619         return DecodeError_clone(&*owner->contents.err);
3620 }
3621 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
3622         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3623         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
3624         uint32_t ret_ref = 0;
3625         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3626         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3628         ret_ref = (uintptr_t)ret_var.inner;
3629         if (ret_var.is_owned) {
3630                 ret_ref |= 1;
3631         }
3632         return ret_ref;
3633 }
3634
3635 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3636         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3637         for (size_t i = 0; i < ret.datalen; i++) {
3638                 ret.data[i] = TxOut_clone(&orig->data[i]);
3639         }
3640         return ret;
3641 }
3642 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3643 CHECK(owner->result_ok);
3644         return *owner->contents.result;
3645 }
3646 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
3647         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3648         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
3649         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3650         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3651         return ret_arr;
3652 }
3653
3654 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3655 CHECK(!owner->result_ok);
3656         return *owner->contents.err;
3657 }
3658 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
3659         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3660         CResult_TransactionNoneZ_get_err(owner_conv);
3661 }
3662
3663 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
3664         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3665         switch(obj->tag) {
3666                 case LDKCOption_u16Z_Some: return 0;
3667                 case LDKCOption_u16Z_None: return 1;
3668                 default: abort();
3669         }
3670 }
3671 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
3672         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3673         assert(obj->tag == LDKCOption_u16Z_Some);
3674         return obj->some;
3675 }
3676 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
3677         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3678         switch(obj->tag) {
3679                 case LDKAPIError_APIMisuseError: return 0;
3680                 case LDKAPIError_FeeRateTooHigh: return 1;
3681                 case LDKAPIError_RouteError: return 2;
3682                 case LDKAPIError_ChannelUnavailable: return 3;
3683                 case LDKAPIError_MonitorUpdateFailed: return 4;
3684                 case LDKAPIError_IncompatibleShutdownScript: return 5;
3685                 default: abort();
3686         }
3687 }
3688 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
3689         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3690         assert(obj->tag == LDKAPIError_APIMisuseError);
3691                         LDKStr err_str = obj->api_misuse_error.err;
3692                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3693         return err_conv;
3694 }
3695 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
3696         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3697         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3698                         LDKStr err_str = obj->fee_rate_too_high.err;
3699                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3700         return err_conv;
3701 }
3702 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
3703         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3704         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3705         return obj->fee_rate_too_high.feerate;
3706 }
3707 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
3708         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3709         assert(obj->tag == LDKAPIError_RouteError);
3710                         LDKStr err_str = obj->route_error.err;
3711                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3712         return err_conv;
3713 }
3714 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
3715         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3716         assert(obj->tag == LDKAPIError_ChannelUnavailable);
3717                         LDKStr err_str = obj->channel_unavailable.err;
3718                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3719         return err_conv;
3720 }
3721 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
3722         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3723         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
3724                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3725                         uint32_t script_ref = 0;
3726                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3727                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3728                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
3729                         script_ref = (uintptr_t)script_var.inner & ~1;
3730         return script_ref;
3731 }
3732 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3733 CHECK(owner->result_ok);
3734         return *owner->contents.result;
3735 }
3736 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
3737         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3738         CResult_NoneAPIErrorZ_get_ok(owner_conv);
3739 }
3740
3741 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3742 CHECK(!owner->result_ok);
3743         return APIError_clone(&*owner->contents.err);
3744 }
3745 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
3746         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3747         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3748         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
3749         uint32_t ret_ref = (uintptr_t)ret_copy;
3750         return ret_ref;
3751 }
3752
3753 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3754         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3755         for (size_t i = 0; i < ret.datalen; i++) {
3756                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3757         }
3758         return ret;
3759 }
3760 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3761         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3762         for (size_t i = 0; i < ret.datalen; i++) {
3763                 ret.data[i] = APIError_clone(&orig->data[i]);
3764         }
3765         return ret;
3766 }
3767 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3768 CHECK(owner->result_ok);
3769         return ThirtyTwoBytes_clone(&*owner->contents.result);
3770 }
3771 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
3772         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3773         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3774         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
3775         return ret_arr;
3776 }
3777
3778 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3779 CHECK(!owner->result_ok);
3780         return APIError_clone(&*owner->contents.err);
3781 }
3782 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
3783         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3784         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3785         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
3786         uint32_t ret_ref = (uintptr_t)ret_copy;
3787         return ret_ref;
3788 }
3789
3790 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
3791         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3792         switch(obj->tag) {
3793                 case LDKPaymentSendFailure_ParameterError: return 0;
3794                 case LDKPaymentSendFailure_PathParameterError: return 1;
3795                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
3796                 case LDKPaymentSendFailure_PartialFailure: return 3;
3797                 default: abort();
3798         }
3799 }
3800 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
3801         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3802         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
3803                         uint32_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
3804         return parameter_error_ref;
3805 }
3806 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
3807         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3808         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
3809                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3810                         uint32_tArray path_parameter_error_arr = NULL;
3811                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
3812                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
3813                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3814                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3815                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3816                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3817                                 path_parameter_error_arr_ptr[w] = (uint32_t)path_parameter_error_conv_22_conv;
3818                         }
3819                         
3820         return path_parameter_error_arr;
3821 }
3822 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
3823         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3824         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
3825                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3826                         uint32_tArray all_failed_retry_safe_arr = NULL;
3827                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
3828                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
3829                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3830                                 uint32_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
3831                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3832                         }
3833                         
3834         return all_failed_retry_safe_arr;
3835 }
3836 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
3837         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3838         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3839                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
3840                         uint32_tArray results_arr = NULL;
3841                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
3842                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
3843                         for (size_t w = 0; w < results_var.datalen; w++) {
3844                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3845                                 *results_conv_22_conv = results_var.data[w];
3846                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
3847                                 results_arr_ptr[w] = (uint32_t)results_conv_22_conv;
3848                         }
3849                         
3850         return results_arr;
3851 }
3852 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
3853         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3854         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3855                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
3856                         uint32_t failed_paths_retry_ref = 0;
3857                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
3858                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3859                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3860                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
3861                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
3862                         }
3863         return failed_paths_retry_ref;
3864 }
3865 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
3866         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3867         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3868                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
3869                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
3870         return payment_id_arr;
3871 }
3872 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3873 CHECK(owner->result_ok);
3874         return ThirtyTwoBytes_clone(&*owner->contents.result);
3875 }
3876 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
3877         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3878         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3879         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
3880         return ret_arr;
3881 }
3882
3883 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3884 CHECK(!owner->result_ok);
3885         return PaymentSendFailure_clone(&*owner->contents.err);
3886 }
3887 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
3888         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3889         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3890         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
3891         uint32_t ret_ref = (uintptr_t)ret_copy;
3892         return ret_ref;
3893 }
3894
3895 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3896 CHECK(owner->result_ok);
3897         return *owner->contents.result;
3898 }
3899 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
3900         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3901         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
3902 }
3903
3904 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3905 CHECK(!owner->result_ok);
3906         return PaymentSendFailure_clone(&*owner->contents.err);
3907 }
3908 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
3909         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3910         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3911         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
3912         uint32_t ret_ref = (uintptr_t)ret_copy;
3913         return ret_ref;
3914 }
3915
3916 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3917         return ThirtyTwoBytes_clone(&owner->a);
3918 }
3919 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
3920         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3921         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3922         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
3923         return ret_arr;
3924 }
3925
3926 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3927         return ThirtyTwoBytes_clone(&owner->b);
3928 }
3929 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
3930         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3931         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3932         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
3933         return ret_arr;
3934 }
3935
3936 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3937 CHECK(owner->result_ok);
3938         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
3939 }
3940 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
3941         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3942         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
3943         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
3944         return ((uint32_t)ret_conv);
3945 }
3946
3947 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3948 CHECK(!owner->result_ok);
3949         return PaymentSendFailure_clone(&*owner->contents.err);
3950 }
3951 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
3952         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3953         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3954         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
3955         uint32_t ret_ref = (uintptr_t)ret_copy;
3956         return ret_ref;
3957 }
3958
3959 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3960         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3961         switch(obj->tag) {
3962                 case LDKNetAddress_IPv4: return 0;
3963                 case LDKNetAddress_IPv6: return 1;
3964                 case LDKNetAddress_OnionV2: return 2;
3965                 case LDKNetAddress_OnionV3: return 3;
3966                 default: abort();
3967         }
3968 }
3969 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3970         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3971         assert(obj->tag == LDKNetAddress_IPv4);
3972                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3973                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3974         return addr_arr;
3975 }
3976 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3977         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3978         assert(obj->tag == LDKNetAddress_IPv4);
3979         return obj->i_pv4.port;
3980 }
3981 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3982         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3983         assert(obj->tag == LDKNetAddress_IPv6);
3984                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
3985                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3986         return addr_arr;
3987 }
3988 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
3989         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3990         assert(obj->tag == LDKNetAddress_IPv6);
3991         return obj->i_pv6.port;
3992 }
3993 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
3994         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3995         assert(obj->tag == LDKNetAddress_OnionV2);
3996                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
3997                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
3998         return onion_v2_arr;
3999 }
4000 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
4001         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4002         assert(obj->tag == LDKNetAddress_OnionV3);
4003                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
4004                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
4005         return ed25519_pubkey_arr;
4006 }
4007 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
4008         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4009         assert(obj->tag == LDKNetAddress_OnionV3);
4010         return obj->onion_v3.checksum;
4011 }
4012 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
4013         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4014         assert(obj->tag == LDKNetAddress_OnionV3);
4015         return obj->onion_v3.version;
4016 }
4017 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
4018         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4019         assert(obj->tag == LDKNetAddress_OnionV3);
4020         return obj->onion_v3.port;
4021 }
4022 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4023         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4024         for (size_t i = 0; i < ret.datalen; i++) {
4025                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4026         }
4027         return ret;
4028 }
4029 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4030         return ThirtyTwoBytes_clone(&owner->a);
4031 }
4032 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
4033         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4034         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4035         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
4036         return ret_arr;
4037 }
4038
4039 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4040         return ThirtyTwoBytes_clone(&owner->b);
4041 }
4042 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
4043         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4044         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4045         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
4046         return ret_arr;
4047 }
4048
4049 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4050 CHECK(owner->result_ok);
4051         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4052 }
4053 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
4054         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4055         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4056         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
4057         return ((uint32_t)ret_conv);
4058 }
4059
4060 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4061 CHECK(!owner->result_ok);
4062         return *owner->contents.err;
4063 }
4064 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
4065         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4066         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
4067 }
4068
4069 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4070 CHECK(owner->result_ok);
4071         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4072 }
4073 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
4074         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4075         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4076         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
4077         return ((uint32_t)ret_conv);
4078 }
4079
4080 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4081 CHECK(!owner->result_ok);
4082         return APIError_clone(&*owner->contents.err);
4083 }
4084 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
4085         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4086         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4087         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
4088         uint32_t ret_ref = (uintptr_t)ret_copy;
4089         return ret_ref;
4090 }
4091
4092 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4093 CHECK(owner->result_ok);
4094         return ThirtyTwoBytes_clone(&*owner->contents.result);
4095 }
4096 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
4097         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4098         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4099         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
4100         return ret_arr;
4101 }
4102
4103 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4104 CHECK(!owner->result_ok);
4105         return *owner->contents.err;
4106 }
4107 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
4108         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4109         CResult_PaymentSecretNoneZ_get_err(owner_conv);
4110 }
4111
4112 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4113 CHECK(owner->result_ok);
4114         return ThirtyTwoBytes_clone(&*owner->contents.result);
4115 }
4116 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
4117         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4118         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4119         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
4120         return ret_arr;
4121 }
4122
4123 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4124 CHECK(!owner->result_ok);
4125         return APIError_clone(&*owner->contents.err);
4126 }
4127 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
4128         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4129         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4130         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
4131         uint32_t ret_ref = (uintptr_t)ret_copy;
4132         return ret_ref;
4133 }
4134
4135 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4136 CHECK(owner->result_ok);
4137         return ThirtyTwoBytes_clone(&*owner->contents.result);
4138 }
4139 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
4140         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4141         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4142         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
4143         return ret_arr;
4144 }
4145
4146 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4147 CHECK(!owner->result_ok);
4148         return APIError_clone(&*owner->contents.err);
4149 }
4150 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
4151         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4152         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4153         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
4154         uint32_t ret_ref = (uintptr_t)ret_copy;
4155         return ret_ref;
4156 }
4157
4158 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4159 CHECK(owner->result_ok);
4160         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
4161 }
4162 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint32_t owner) {
4163         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4164         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
4165         uint32_t ret_ref = 0;
4166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4169         ret_ref = (uintptr_t)ret_var.inner;
4170         if (ret_var.is_owned) {
4171                 ret_ref |= 1;
4172         }
4173         return ret_ref;
4174 }
4175
4176 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4177 CHECK(!owner->result_ok);
4178         return DecodeError_clone(&*owner->contents.err);
4179 }
4180 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint32_t owner) {
4181         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4182         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
4183         uint32_t ret_ref = 0;
4184         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4185         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4187         ret_ref = (uintptr_t)ret_var.inner;
4188         if (ret_var.is_owned) {
4189                 ret_ref |= 1;
4190         }
4191         return ret_ref;
4192 }
4193
4194 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4195 CHECK(owner->result_ok);
4196         return ChannelCounterparty_clone(&*owner->contents.result);
4197 }
4198 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint32_t owner) {
4199         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4200         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_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_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4213 CHECK(!owner->result_ok);
4214         return DecodeError_clone(&*owner->contents.err);
4215 }
4216 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint32_t owner) {
4217         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4218         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_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 LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4231 CHECK(owner->result_ok);
4232         return ChannelDetails_clone(&*owner->contents.result);
4233 }
4234 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint32_t owner) {
4235         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4236         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_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_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4249 CHECK(!owner->result_ok);
4250         return DecodeError_clone(&*owner->contents.err);
4251 }
4252 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint32_t owner) {
4253         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4254         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_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 LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4267 CHECK(owner->result_ok);
4268         return PhantomRouteHints_clone(&*owner->contents.result);
4269 }
4270 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint32_t owner) {
4271         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4272         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_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_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4285 CHECK(!owner->result_ok);
4286         return DecodeError_clone(&*owner->contents.err);
4287 }
4288 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint32_t owner) {
4289         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4290         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_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 LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4303         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4304         for (size_t i = 0; i < ret.datalen; i++) {
4305                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4306         }
4307         return ret;
4308 }
4309 typedef struct LDKWatch_JCalls {
4310         atomic_size_t refcnt;
4311         uint32_t instance_ptr;
4312 } LDKWatch_JCalls;
4313 static void LDKWatch_JCalls_free(void* this_arg) {
4314         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4315         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4316                 FREE(j_calls);
4317         }
4318 }
4319 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4320         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4321         LDKOutPoint funding_txo_var = funding_txo;
4322         uint32_t funding_txo_ref = 0;
4323         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4324         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4325         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4326         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4327         if (funding_txo_var.is_owned) {
4328                 funding_txo_ref |= 1;
4329         }
4330         LDKChannelMonitor monitor_var = monitor;
4331         uint32_t monitor_ref = 0;
4332         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4333         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4334         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
4335         monitor_ref = (uintptr_t)monitor_var.inner;
4336         if (monitor_var.is_owned) {
4337                 monitor_ref |= 1;
4338         }
4339         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 14, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
4340         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4341         CHECK_ACCESS(ret_ptr);
4342         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4343         FREE((void*)ret);
4344         return ret_conv;
4345 }
4346 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4347         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4348         LDKOutPoint funding_txo_var = funding_txo;
4349         uint32_t funding_txo_ref = 0;
4350         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4351         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4352         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4353         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4354         if (funding_txo_var.is_owned) {
4355                 funding_txo_ref |= 1;
4356         }
4357         LDKChannelMonitorUpdate update_var = update;
4358         uint32_t update_ref = 0;
4359         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4360         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4361         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
4362         update_ref = (uintptr_t)update_var.inner;
4363         if (update_var.is_owned) {
4364                 update_ref |= 1;
4365         }
4366         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 15, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
4367         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4368         CHECK_ACCESS(ret_ptr);
4369         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4370         FREE((void*)ret);
4371         return ret_conv;
4372 }
4373 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
4374         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4375         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 16);
4376         LDKCVec_MonitorEventZ ret_constr;
4377         ret_constr.datalen = ret->arr_len;
4378         if (ret_constr.datalen > 0)
4379                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4380         else
4381                 ret_constr.data = NULL;
4382         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
4383         for (size_t o = 0; o < ret_constr.datalen; o++) {
4384                 uint32_t ret_conv_14 = ret_vals[o];
4385                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
4386                 CHECK_ACCESS(ret_conv_14_ptr);
4387                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
4388                 FREE((void*)ret_conv_14);
4389                 ret_constr.data[o] = ret_conv_14_conv;
4390         }
4391         return ret_constr;
4392 }
4393 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
4394         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
4395         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4396 }
4397 static inline LDKWatch LDKWatch_init (JSValue o) {
4398         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
4399         atomic_init(&calls->refcnt, 1);
4400         calls->instance_ptr = o;
4401
4402         LDKWatch ret = {
4403                 .this_arg = (void*) calls,
4404                 .watch_channel = watch_channel_LDKWatch_jcall,
4405                 .update_channel = update_channel_LDKWatch_jcall,
4406                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
4407                 .free = LDKWatch_JCalls_free,
4408         };
4409         return ret;
4410 }
4411 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
4412         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
4413         *res_ptr = LDKWatch_init(o);
4414         return (long)res_ptr;
4415 }
4416 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
4417         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4418         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4419         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4420         LDKOutPoint funding_txo_conv;
4421         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4422         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4423         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4424         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4425         LDKChannelMonitor monitor_conv;
4426         monitor_conv.inner = (void*)(monitor & (~1));
4427         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
4428         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
4429         monitor_conv = ChannelMonitor_clone(&monitor_conv);
4430         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4431         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
4432         return (uint32_t)ret_conv;
4433 }
4434
4435 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
4436         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4437         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4438         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4439         LDKOutPoint funding_txo_conv;
4440         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4441         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4442         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4443         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4444         LDKChannelMonitorUpdate update_conv;
4445         update_conv.inner = (void*)(update & (~1));
4446         update_conv.is_owned = (update & 1) || (update == 0);
4447         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
4448         update_conv = ChannelMonitorUpdate_clone(&update_conv);
4449         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4450         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
4451         return (uint32_t)ret_conv;
4452 }
4453
4454 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
4455         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4456         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4457         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4458         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
4459         uint32_tArray ret_arr = NULL;
4460         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
4461         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
4462         for (size_t o = 0; o < ret_var.datalen; o++) {
4463                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4464                 *ret_conv_14_copy = ret_var.data[o];
4465                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
4466                 ret_arr_ptr[o] = ret_conv_14_ref;
4467         }
4468         
4469         FREE(ret_var.data);
4470         return ret_arr;
4471 }
4472
4473 typedef struct LDKBroadcasterInterface_JCalls {
4474         atomic_size_t refcnt;
4475         uint32_t instance_ptr;
4476 } LDKBroadcasterInterface_JCalls;
4477 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
4478         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4479         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4480                 FREE(j_calls);
4481         }
4482 }
4483 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
4484         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4485         LDKTransaction tx_var = tx;
4486         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
4487         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
4488         Transaction_free(tx_var);
4489         js_invoke_function_1(j_calls->instance_ptr, 17, (uint32_t)tx_arr);
4490 }
4491 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
4492         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
4493         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4494 }
4495 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
4496         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4497         atomic_init(&calls->refcnt, 1);
4498         calls->instance_ptr = o;
4499
4500         LDKBroadcasterInterface ret = {
4501                 .this_arg = (void*) calls,
4502                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4503                 .free = LDKBroadcasterInterface_JCalls_free,
4504         };
4505         return ret;
4506 }
4507 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
4508         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4509         *res_ptr = LDKBroadcasterInterface_init(o);
4510         return (long)res_ptr;
4511 }
4512 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
4513         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4514         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4515         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
4516         LDKTransaction tx_ref;
4517         tx_ref.datalen = tx->arr_len;
4518         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4519         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
4520         tx_ref.data_is_owned = true;
4521         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4522 }
4523
4524 typedef struct LDKKeysInterface_JCalls {
4525         atomic_size_t refcnt;
4526         uint32_t instance_ptr;
4527 } LDKKeysInterface_JCalls;
4528 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4529         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4530         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4531                 FREE(j_calls);
4532         }
4533 }
4534 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
4535         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4536         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
4537         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 18, (uint32_t)recipient_conv);
4538         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4539         CHECK_ACCESS(ret_ptr);
4540         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
4541         FREE((void*)ret);
4542         return ret_conv;
4543 }
4544 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4545         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4546         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 19);
4547         LDKCVec_u8Z ret_ref;
4548         ret_ref.datalen = ret->arr_len;
4549         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4550         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4551         return ret_ref;
4552 }
4553 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4554         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4555         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 20);
4556         LDKShutdownScript ret_conv;
4557         ret_conv.inner = (void*)(ret & (~1));
4558         ret_conv.is_owned = (ret & 1) || (ret == 0);
4559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
4560         return ret_conv;
4561 }
4562 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4563         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4564         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 21, (uint32_t)inbound, (uint32_t)channel_value_satoshis);
4565         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4566         CHECK_ACCESS(ret_ptr);
4567         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
4568         FREE((void*)ret);
4569         return ret_conv;
4570 }
4571 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4572         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4573         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 22);
4574         LDKThirtyTwoBytes ret_ref;
4575         CHECK(ret->arr_len == 32);
4576         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4577         return ret_ref;
4578 }
4579 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4580         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4581         LDKu8slice reader_var = reader;
4582         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
4583         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
4584         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 23, (uint32_t)reader_arr);
4585         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4586         CHECK_ACCESS(ret_ptr);
4587         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
4588         FREE((void*)ret);
4589         return ret_conv;
4590 }
4591 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
4592         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4593         LDKu8slice hrp_bytes_var = hrp_bytes;
4594         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
4595         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
4596         LDKCVec_u5Z invoice_data_var = invoice_data;
4597         ptrArray invoice_data_arr = NULL;
4598         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
4599         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 4);
4600         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
4601                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
4602                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
4603         }
4604         
4605         FREE(invoice_data_var.data);
4606         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
4607         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);
4608         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4609         CHECK_ACCESS(ret_ptr);
4610         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
4611         FREE((void*)ret);
4612         return ret_conv;
4613 }
4614 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
4615         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4616         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 25);
4617         LDKThirtyTwoBytes ret_ref;
4618         CHECK(ret->arr_len == 32);
4619         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4620         return ret_ref;
4621 }
4622 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4623         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4624         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4625 }
4626 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
4627         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4628         atomic_init(&calls->refcnt, 1);
4629         calls->instance_ptr = o;
4630
4631         LDKKeysInterface ret = {
4632                 .this_arg = (void*) calls,
4633                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4634                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4635                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4636                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4637                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4638                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4639                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4640                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
4641                 .free = LDKKeysInterface_JCalls_free,
4642         };
4643         return ret;
4644 }
4645 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
4646         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4647         *res_ptr = LDKKeysInterface_init(o);
4648         return (long)res_ptr;
4649 }
4650 uint32_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg, uint32_t recipient) {
4651         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4652         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4653         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4654         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
4655         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
4656         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
4657         return (uint32_t)ret_conv;
4658 }
4659
4660 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
4661         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4662         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4663         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4664         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4665         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4666         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4667         CVec_u8Z_free(ret_var);
4668         return ret_arr;
4669 }
4670
4671 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
4672         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4673         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4674         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4675         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4676         uint32_t ret_ref = 0;
4677         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4678         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4680         ret_ref = (uintptr_t)ret_var.inner;
4681         if (ret_var.is_owned) {
4682                 ret_ref |= 1;
4683         }
4684         return ret_ref;
4685 }
4686
4687 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) {
4688         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4689         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4690         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4691         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4692         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4693         return (uint32_t)ret_ret;
4694 }
4695
4696 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
4697         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4698         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4699         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4700         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4701         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
4702         return ret_arr;
4703 }
4704
4705 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
4706         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4707         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4708         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4709         LDKu8slice reader_ref;
4710         reader_ref.datalen = reader->arr_len;
4711         reader_ref.data = reader->elems /* XXX reader leaks */;
4712         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4713         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4714         return (uint32_t)ret_conv;
4715 }
4716
4717 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) {
4718         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4719         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4720         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4721         LDKu8slice hrp_bytes_ref;
4722         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
4723         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
4724         LDKCVec_u5Z invoice_data_constr;
4725         invoice_data_constr.datalen = invoice_data->arr_len;
4726         if (invoice_data_constr.datalen > 0)
4727                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
4728         else
4729                 invoice_data_constr.data = NULL;
4730         int8_t* invoice_data_vals = (void*) invoice_data->elems /* XXX invoice_data leaks */;
4731         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
4732                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
4733                 
4734                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
4735         }
4736         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
4737         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4738         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
4739         return (uint32_t)ret_conv;
4740 }
4741
4742 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
4743         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4744         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4745         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4746         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4747         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
4748         return ret_arr;
4749 }
4750
4751 typedef struct LDKFeeEstimator_JCalls {
4752         atomic_size_t refcnt;
4753         uint32_t instance_ptr;
4754 } LDKFeeEstimator_JCalls;
4755 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4756         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4757         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4758                 FREE(j_calls);
4759         }
4760 }
4761 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4762         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4763         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
4764         return js_invoke_function_1(j_calls->instance_ptr, 26, (uint32_t)confirmation_target_conv);
4765 }
4766 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4767         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4768         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4769 }
4770 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
4771         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4772         atomic_init(&calls->refcnt, 1);
4773         calls->instance_ptr = o;
4774
4775         LDKFeeEstimator ret = {
4776                 .this_arg = (void*) calls,
4777                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4778                 .free = LDKFeeEstimator_JCalls_free,
4779         };
4780         return ret;
4781 }
4782 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
4783         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4784         *res_ptr = LDKFeeEstimator_init(o);
4785         return (long)res_ptr;
4786 }
4787 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) {
4788         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4789         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4790         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
4791         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
4792         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4793         return ret_val;
4794 }
4795
4796 typedef struct LDKLogger_JCalls {
4797         atomic_size_t refcnt;
4798         uint32_t instance_ptr;
4799 } LDKLogger_JCalls;
4800 static void LDKLogger_JCalls_free(void* this_arg) {
4801         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4802         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4803                 FREE(j_calls);
4804         }
4805 }
4806 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4807         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4808         LDKRecord record_var = *record;
4809         uint32_t record_ref = 0;
4810         record_var = Record_clone(&record_var);
4811         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4812         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4813         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4814         record_ref = (uintptr_t)record_var.inner;
4815         if (record_var.is_owned) {
4816                 record_ref |= 1;
4817         }
4818         js_invoke_function_1(j_calls->instance_ptr, 27, (uint32_t)record_ref);
4819 }
4820 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4821         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4822         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4823 }
4824 static inline LDKLogger LDKLogger_init (JSValue o) {
4825         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4826         atomic_init(&calls->refcnt, 1);
4827         calls->instance_ptr = o;
4828
4829         LDKLogger ret = {
4830                 .this_arg = (void*) calls,
4831                 .log = log_LDKLogger_jcall,
4832                 .free = LDKLogger_JCalls_free,
4833         };
4834         return ret;
4835 }
4836 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
4837         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4838         *res_ptr = LDKLogger_init(o);
4839         return (long)res_ptr;
4840 }
4841 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4842         return ThirtyTwoBytes_clone(&owner->a);
4843 }
4844 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
4845         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4846         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4847         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
4848         return ret_arr;
4849 }
4850
4851 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4852         return &owner->b;
4853 }
4854 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
4855         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4856         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
4857         uint32_t ret_ref = 0;
4858         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4859         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4861         ret_ref = (uintptr_t)ret_var.inner & ~1;
4862         return ret_ref;
4863 }
4864
4865 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4866 CHECK(owner->result_ok);
4867         return &*owner->contents.result;
4868 }
4869 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
4870         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4871         uint32_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
4872         return ret_ret;
4873 }
4874
4875 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4876 CHECK(!owner->result_ok);
4877         return DecodeError_clone(&*owner->contents.err);
4878 }
4879 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
4880         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4881         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
4882         uint32_t ret_ref = 0;
4883         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4884         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4886         ret_ref = (uintptr_t)ret_var.inner;
4887         if (ret_var.is_owned) {
4888                 ret_ref |= 1;
4889         }
4890         return ret_ref;
4891 }
4892
4893 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4894 CHECK(owner->result_ok);
4895         return ChannelConfig_clone(&*owner->contents.result);
4896 }
4897 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
4898         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4899         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
4900         uint32_t ret_ref = 0;
4901         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4902         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4904         ret_ref = (uintptr_t)ret_var.inner;
4905         if (ret_var.is_owned) {
4906                 ret_ref |= 1;
4907         }
4908         return ret_ref;
4909 }
4910
4911 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4912 CHECK(!owner->result_ok);
4913         return DecodeError_clone(&*owner->contents.err);
4914 }
4915 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
4916         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4917         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
4918         uint32_t ret_ref = 0;
4919         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4920         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4922         ret_ref = (uintptr_t)ret_var.inner;
4923         if (ret_var.is_owned) {
4924                 ret_ref |= 1;
4925         }
4926         return ret_ref;
4927 }
4928
4929 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4930 CHECK(owner->result_ok);
4931         return OutPoint_clone(&*owner->contents.result);
4932 }
4933 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
4934         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4935         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
4936         uint32_t ret_ref = 0;
4937         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4938         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4940         ret_ref = (uintptr_t)ret_var.inner;
4941         if (ret_var.is_owned) {
4942                 ret_ref |= 1;
4943         }
4944         return ret_ref;
4945 }
4946
4947 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4948 CHECK(!owner->result_ok);
4949         return DecodeError_clone(&*owner->contents.err);
4950 }
4951 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
4952         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4953         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
4954         uint32_t ret_ref = 0;
4955         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4956         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4958         ret_ref = (uintptr_t)ret_var.inner;
4959         if (ret_var.is_owned) {
4960                 ret_ref |= 1;
4961         }
4962         return ret_ref;
4963 }
4964
4965 typedef struct LDKType_JCalls {
4966         atomic_size_t refcnt;
4967         uint32_t instance_ptr;
4968 } LDKType_JCalls;
4969 static void LDKType_JCalls_free(void* this_arg) {
4970         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4971         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4972                 FREE(j_calls);
4973         }
4974 }
4975 uint16_t type_id_LDKType_jcall(const void* this_arg) {
4976         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4977         return js_invoke_function_0(j_calls->instance_ptr, 28);
4978 }
4979 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
4980         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4981         jstring ret = (jstring)js_invoke_function_0(j_calls->instance_ptr, 29);
4982         LDKStr ret_conv = str_ref_to_owned_c(ret);
4983         return ret_conv;
4984 }
4985 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
4986         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4987         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 30);
4988         LDKCVec_u8Z ret_ref;
4989         ret_ref.datalen = ret->arr_len;
4990         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4991         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4992         return ret_ref;
4993 }
4994 static void LDKType_JCalls_cloned(LDKType* new_obj) {
4995         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
4996         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4997 }
4998 static inline LDKType LDKType_init (JSValue o) {
4999         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5000         atomic_init(&calls->refcnt, 1);
5001         calls->instance_ptr = o;
5002
5003         LDKType ret = {
5004                 .this_arg = (void*) calls,
5005                 .type_id = type_id_LDKType_jcall,
5006                 .debug_str = debug_str_LDKType_jcall,
5007                 .write = write_LDKType_jcall,
5008                 .cloned = LDKType_JCalls_cloned,
5009                 .free = LDKType_JCalls_free,
5010         };
5011         return ret;
5012 }
5013 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
5014         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5015         *res_ptr = LDKType_init(o);
5016         return (long)res_ptr;
5017 }
5018 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
5019         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5020         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5021         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5022         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5023         return ret_val;
5024 }
5025
5026 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
5027         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5028         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5029         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5030         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5031         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5032         Str_free(ret_str);
5033         return ret_conv;
5034 }
5035
5036 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
5037         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5038         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5039         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5040         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5041         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5042         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5043         CVec_u8Z_free(ret_var);
5044         return ret_arr;
5045 }
5046
5047 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
5048         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5049         switch(obj->tag) {
5050                 case LDKCOption_TypeZ_Some: return 0;
5051                 case LDKCOption_TypeZ_None: return 1;
5052                 default: abort();
5053         }
5054 }
5055 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
5056         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5057         assert(obj->tag == LDKCOption_TypeZ_Some);
5058                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5059                         *some_ret = Type_clone(&obj->some);
5060         return (uint32_t)some_ret;
5061 }
5062 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5063 CHECK(owner->result_ok);
5064         return COption_TypeZ_clone(&*owner->contents.result);
5065 }
5066 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
5067         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5068         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5069         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5070         uint32_t ret_ref = (uintptr_t)ret_copy;
5071         return ret_ref;
5072 }
5073
5074 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5075 CHECK(!owner->result_ok);
5076         return DecodeError_clone(&*owner->contents.err);
5077 }
5078 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
5079         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5080         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
5081         uint32_t ret_ref = 0;
5082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5085         ret_ref = (uintptr_t)ret_var.inner;
5086         if (ret_var.is_owned) {
5087                 ret_ref |= 1;
5088         }
5089         return ret_ref;
5090 }
5091
5092 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint32_t ptr) {
5093         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5094         switch(obj->tag) {
5095                 case LDKPaymentError_Invoice: return 0;
5096                 case LDKPaymentError_Routing: return 1;
5097                 case LDKPaymentError_Sending: return 2;
5098                 default: abort();
5099         }
5100 }
5101 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint32_t ptr) {
5102         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5103         assert(obj->tag == LDKPaymentError_Invoice);
5104                         LDKStr invoice_str = obj->invoice;
5105                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
5106         return invoice_conv;
5107 }
5108 uint32_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint32_t ptr) {
5109         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5110         assert(obj->tag == LDKPaymentError_Routing);
5111                         LDKLightningError routing_var = obj->routing;
5112                         uint32_t routing_ref = 0;
5113                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5114                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5115                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5116                         routing_ref = (uintptr_t)routing_var.inner & ~1;
5117         return routing_ref;
5118 }
5119 uint32_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint32_t ptr) {
5120         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5121         assert(obj->tag == LDKPaymentError_Sending);
5122                         uint32_t sending_ref = ((uintptr_t)&obj->sending) | 1;
5123         return sending_ref;
5124 }
5125 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5126 CHECK(owner->result_ok);
5127         return ThirtyTwoBytes_clone(&*owner->contents.result);
5128 }
5129 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint32_t owner) {
5130         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5131         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5132         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
5133         return ret_arr;
5134 }
5135
5136 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5137 CHECK(!owner->result_ok);
5138         return PaymentError_clone(&*owner->contents.err);
5139 }
5140 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint32_t owner) {
5141         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5142         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
5143         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
5144         uint32_t ret_ref = (uintptr_t)ret_copy;
5145         return ret_ref;
5146 }
5147
5148 uint32_t __attribute__((export_name("TS_LDKParseError_ty_from_ptr"))) TS_LDKParseError_ty_from_ptr(uint32_t ptr) {
5149         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5150         switch(obj->tag) {
5151                 case LDKParseError_Bech32Error: return 0;
5152                 case LDKParseError_ParseAmountError: return 1;
5153                 case LDKParseError_MalformedSignature: return 2;
5154                 case LDKParseError_BadPrefix: return 3;
5155                 case LDKParseError_UnknownCurrency: return 4;
5156                 case LDKParseError_UnknownSiPrefix: return 5;
5157                 case LDKParseError_MalformedHRP: return 6;
5158                 case LDKParseError_TooShortDataPart: return 7;
5159                 case LDKParseError_UnexpectedEndOfTaggedFields: return 8;
5160                 case LDKParseError_DescriptionDecodeError: return 9;
5161                 case LDKParseError_PaddingError: return 10;
5162                 case LDKParseError_IntegerOverflowError: return 11;
5163                 case LDKParseError_InvalidSegWitProgramLength: return 12;
5164                 case LDKParseError_InvalidPubKeyHashLength: return 13;
5165                 case LDKParseError_InvalidScriptHashLength: return 14;
5166                 case LDKParseError_InvalidRecoveryId: return 15;
5167                 case LDKParseError_InvalidSliceLength: return 16;
5168                 case LDKParseError_Skip: return 17;
5169                 default: abort();
5170         }
5171 }
5172 uint32_t __attribute__((export_name("TS_LDKParseError_Bech32Error_get_bech32_error"))) TS_LDKParseError_Bech32Error_get_bech32_error(uint32_t ptr) {
5173         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5174         assert(obj->tag == LDKParseError_Bech32Error);
5175                         uint32_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
5176         return bech32_error_ref;
5177 }
5178 int32_t __attribute__((export_name("TS_LDKParseError_ParseAmountError_get_parse_amount_error"))) TS_LDKParseError_ParseAmountError_get_parse_amount_error(uint32_t ptr) {
5179         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5180         assert(obj->tag == LDKParseError_ParseAmountError);
5181                         /*obj->parse_amount_error*/
5182         return 0;
5183 }
5184 uint32_t __attribute__((export_name("TS_LDKParseError_MalformedSignature_get_malformed_signature"))) TS_LDKParseError_MalformedSignature_get_malformed_signature(uint32_t ptr) {
5185         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5186         assert(obj->tag == LDKParseError_MalformedSignature);
5187                         uint32_t malformed_signature_conv = LDKSecp256k1Error_to_js(obj->malformed_signature);
5188         return malformed_signature_conv;
5189 }
5190 int32_t __attribute__((export_name("TS_LDKParseError_DescriptionDecodeError_get_description_decode_error"))) TS_LDKParseError_DescriptionDecodeError_get_description_decode_error(uint32_t ptr) {
5191         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5192         assert(obj->tag == LDKParseError_DescriptionDecodeError);
5193                         /*obj->description_decode_error*/
5194         return 0;
5195 }
5196 jstring __attribute__((export_name("TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length"))) TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length(uint32_t ptr) {
5197         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5198         assert(obj->tag == LDKParseError_InvalidSliceLength);
5199                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
5200                         jstring invalid_slice_length_conv = str_ref_to_ts(invalid_slice_length_str.chars, invalid_slice_length_str.len);
5201         return invalid_slice_length_conv;
5202 }
5203 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5204 CHECK(owner->result_ok);
5205         return SiPrefix_clone(&*owner->contents.result);
5206 }
5207 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_ok"))) TS_CResult_SiPrefixParseErrorZ_get_ok(uint32_t owner) {
5208         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5209         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
5210         return ret_conv;
5211 }
5212
5213 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5214 CHECK(!owner->result_ok);
5215         return ParseError_clone(&*owner->contents.err);
5216 }
5217 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_err"))) TS_CResult_SiPrefixParseErrorZ_get_err(uint32_t owner) {
5218         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5219         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5220         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
5221         uint32_t ret_ref = (uintptr_t)ret_copy;
5222         return ret_ref;
5223 }
5224
5225 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ty_from_ptr"))) TS_LDKParseOrSemanticError_ty_from_ptr(uint32_t ptr) {
5226         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5227         switch(obj->tag) {
5228                 case LDKParseOrSemanticError_ParseError: return 0;
5229                 case LDKParseOrSemanticError_SemanticError: return 1;
5230                 default: abort();
5231         }
5232 }
5233 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ParseError_get_parse_error"))) TS_LDKParseOrSemanticError_ParseError_get_parse_error(uint32_t ptr) {
5234         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5235         assert(obj->tag == LDKParseOrSemanticError_ParseError);
5236                         uint32_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
5237         return parse_error_ref;
5238 }
5239 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_SemanticError_get_semantic_error"))) TS_LDKParseOrSemanticError_SemanticError_get_semantic_error(uint32_t ptr) {
5240         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5241         assert(obj->tag == LDKParseOrSemanticError_SemanticError);
5242                         uint32_t semantic_error_conv = LDKSemanticError_to_js(obj->semantic_error);
5243         return semantic_error_conv;
5244 }
5245 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5246 CHECK(owner->result_ok);
5247         return Invoice_clone(&*owner->contents.result);
5248 }
5249 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok(uint32_t owner) {
5250         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5251         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
5252         uint32_t ret_ref = 0;
5253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5256         ret_ref = (uintptr_t)ret_var.inner;
5257         if (ret_var.is_owned) {
5258                 ret_ref |= 1;
5259         }
5260         return ret_ref;
5261 }
5262
5263 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5264 CHECK(!owner->result_ok);
5265         return ParseOrSemanticError_clone(&*owner->contents.err);
5266 }
5267 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_err(uint32_t owner) {
5268         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5269         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
5270         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
5271         uint32_t ret_ref = (uintptr_t)ret_copy;
5272         return ret_ref;
5273 }
5274
5275 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
5276 CHECK(owner->result_ok);
5277         return SignedRawInvoice_clone(&*owner->contents.result);
5278 }
5279 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_ok(uint32_t owner) {
5280         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
5281         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
5282         uint32_t ret_ref = 0;
5283         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5284         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5286         ret_ref = (uintptr_t)ret_var.inner;
5287         if (ret_var.is_owned) {
5288                 ret_ref |= 1;
5289         }
5290         return ret_ref;
5291 }
5292
5293 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
5294 CHECK(!owner->result_ok);
5295         return ParseError_clone(&*owner->contents.err);
5296 }
5297 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_err(uint32_t owner) {
5298         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
5299         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5300         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
5301         uint32_t ret_ref = (uintptr_t)ret_copy;
5302         return ret_ref;
5303 }
5304
5305 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5306         return RawInvoice_clone(&owner->a);
5307 }
5308 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t owner) {
5309         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5310         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
5311         uint32_t ret_ref = 0;
5312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5315         ret_ref = (uintptr_t)ret_var.inner;
5316         if (ret_var.is_owned) {
5317                 ret_ref |= 1;
5318         }
5319         return ret_ref;
5320 }
5321
5322 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5323         return ThirtyTwoBytes_clone(&owner->b);
5324 }
5325 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t owner) {
5326         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5327         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5328         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
5329         return ret_arr;
5330 }
5331
5332 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5333         return InvoiceSignature_clone(&owner->c);
5334 }
5335 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t owner) {
5336         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5337         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
5338         uint32_t ret_ref = 0;
5339         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5340         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5342         ret_ref = (uintptr_t)ret_var.inner;
5343         if (ret_var.is_owned) {
5344                 ret_ref |= 1;
5345         }
5346         return ret_ref;
5347 }
5348
5349 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5350 CHECK(owner->result_ok);
5351         return PayeePubKey_clone(&*owner->contents.result);
5352 }
5353 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint32_t owner) {
5354         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5355         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
5356         uint32_t ret_ref = 0;
5357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5360         ret_ref = (uintptr_t)ret_var.inner;
5361         if (ret_var.is_owned) {
5362                 ret_ref |= 1;
5363         }
5364         return ret_ref;
5365 }
5366
5367 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5368 CHECK(!owner->result_ok);
5369         return *owner->contents.err;
5370 }
5371 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint32_t owner) {
5372         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5373         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
5374         return ret_conv;
5375 }
5376
5377 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
5378         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
5379         for (size_t i = 0; i < ret.datalen; i++) {
5380                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
5381         }
5382         return ret;
5383 }
5384 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5385 CHECK(owner->result_ok);
5386         return PositiveTimestamp_clone(&*owner->contents.result);
5387 }
5388 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t owner) {
5389         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5390         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
5391         uint32_t ret_ref = 0;
5392         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5393         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5395         ret_ref = (uintptr_t)ret_var.inner;
5396         if (ret_var.is_owned) {
5397                 ret_ref |= 1;
5398         }
5399         return ret_ref;
5400 }
5401
5402 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5403 CHECK(!owner->result_ok);
5404         return CreationError_clone(&*owner->contents.err);
5405 }
5406 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint32_t owner) {
5407         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5408         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
5409         return ret_conv;
5410 }
5411
5412 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5413 CHECK(owner->result_ok);
5414         return *owner->contents.result;
5415 }
5416 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint32_t owner) {
5417         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5418         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
5419 }
5420
5421 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5422 CHECK(!owner->result_ok);
5423         return SemanticError_clone(&*owner->contents.err);
5424 }
5425 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint32_t owner) {
5426         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5427         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
5428         return ret_conv;
5429 }
5430
5431 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5432 CHECK(owner->result_ok);
5433         return Invoice_clone(&*owner->contents.result);
5434 }
5435 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint32_t owner) {
5436         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5437         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
5438         uint32_t ret_ref = 0;
5439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5442         ret_ref = (uintptr_t)ret_var.inner;
5443         if (ret_var.is_owned) {
5444                 ret_ref |= 1;
5445         }
5446         return ret_ref;
5447 }
5448
5449 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5450 CHECK(!owner->result_ok);
5451         return SemanticError_clone(&*owner->contents.err);
5452 }
5453 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint32_t owner) {
5454         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5455         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
5456         return ret_conv;
5457 }
5458
5459 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5460 CHECK(owner->result_ok);
5461         return Description_clone(&*owner->contents.result);
5462 }
5463 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint32_t owner) {
5464         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5465         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
5466         uint32_t ret_ref = 0;
5467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5470         ret_ref = (uintptr_t)ret_var.inner;
5471         if (ret_var.is_owned) {
5472                 ret_ref |= 1;
5473         }
5474         return ret_ref;
5475 }
5476
5477 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5478 CHECK(!owner->result_ok);
5479         return CreationError_clone(&*owner->contents.err);
5480 }
5481 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint32_t owner) {
5482         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5483         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
5484         return ret_conv;
5485 }
5486
5487 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5488 CHECK(owner->result_ok);
5489         return PrivateRoute_clone(&*owner->contents.result);
5490 }
5491 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint32_t owner) {
5492         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5493         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
5494         uint32_t ret_ref = 0;
5495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5498         ret_ref = (uintptr_t)ret_var.inner;
5499         if (ret_var.is_owned) {
5500                 ret_ref |= 1;
5501         }
5502         return ret_ref;
5503 }
5504
5505 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5506 CHECK(!owner->result_ok);
5507         return CreationError_clone(&*owner->contents.err);
5508 }
5509 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint32_t owner) {
5510         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5511         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
5512         return ret_conv;
5513 }
5514
5515 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5516 CHECK(owner->result_ok);
5517         return *owner->contents.result;
5518 }
5519 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
5520         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5521         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
5522         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5523         return ret_conv;
5524 }
5525
5526 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5527 CHECK(!owner->result_ok);
5528         return *owner->contents.err;
5529 }
5530 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
5531         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5532         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
5533         return ret_conv;
5534 }
5535
5536 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5537 CHECK(owner->result_ok);
5538         return ChannelMonitorUpdate_clone(&*owner->contents.result);
5539 }
5540 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5541         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5542         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
5543         uint32_t ret_ref = 0;
5544         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5545         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5547         ret_ref = (uintptr_t)ret_var.inner;
5548         if (ret_var.is_owned) {
5549                 ret_ref |= 1;
5550         }
5551         return ret_ref;
5552 }
5553
5554 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5555 CHECK(!owner->result_ok);
5556         return DecodeError_clone(&*owner->contents.err);
5557 }
5558 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
5559         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5560         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
5561         uint32_t ret_ref = 0;
5562         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5563         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5565         ret_ref = (uintptr_t)ret_var.inner;
5566         if (ret_var.is_owned) {
5567                 ret_ref |= 1;
5568         }
5569         return ret_ref;
5570 }
5571
5572 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
5573         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5574         switch(obj->tag) {
5575                 case LDKCOption_MonitorEventZ_Some: return 0;
5576                 case LDKCOption_MonitorEventZ_None: return 1;
5577                 default: abort();
5578         }
5579 }
5580 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
5581         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5582         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
5583                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
5584         return some_ref;
5585 }
5586 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5587 CHECK(owner->result_ok);
5588         return COption_MonitorEventZ_clone(&*owner->contents.result);
5589 }
5590 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
5591         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5592         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
5593         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
5594         uint32_t ret_ref = (uintptr_t)ret_copy;
5595         return ret_ref;
5596 }
5597
5598 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5599 CHECK(!owner->result_ok);
5600         return DecodeError_clone(&*owner->contents.err);
5601 }
5602 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
5603         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5604         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
5605         uint32_t ret_ref = 0;
5606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5609         ret_ref = (uintptr_t)ret_var.inner;
5610         if (ret_var.is_owned) {
5611                 ret_ref |= 1;
5612         }
5613         return ret_ref;
5614 }
5615
5616 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5617 CHECK(owner->result_ok);
5618         return HTLCUpdate_clone(&*owner->contents.result);
5619 }
5620 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5621         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5622         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
5623         uint32_t ret_ref = 0;
5624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5627         ret_ref = (uintptr_t)ret_var.inner;
5628         if (ret_var.is_owned) {
5629                 ret_ref |= 1;
5630         }
5631         return ret_ref;
5632 }
5633
5634 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5635 CHECK(!owner->result_ok);
5636         return DecodeError_clone(&*owner->contents.err);
5637 }
5638 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
5639         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5640         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
5641         uint32_t ret_ref = 0;
5642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5645         ret_ref = (uintptr_t)ret_var.inner;
5646         if (ret_var.is_owned) {
5647                 ret_ref |= 1;
5648         }
5649         return ret_ref;
5650 }
5651
5652 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5653         return OutPoint_clone(&owner->a);
5654 }
5655 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
5656         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5657         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
5658         uint32_t ret_ref = 0;
5659         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5660         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5662         ret_ref = (uintptr_t)ret_var.inner;
5663         if (ret_var.is_owned) {
5664                 ret_ref |= 1;
5665         }
5666         return ret_ref;
5667 }
5668
5669 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5670         return CVec_u8Z_clone(&owner->b);
5671 }
5672 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
5673         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5674         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
5675         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5676         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5677         CVec_u8Z_free(ret_var);
5678         return ret_arr;
5679 }
5680
5681 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5682         return owner->a;
5683 }
5684 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
5685         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5686         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
5687         return ret_val;
5688 }
5689
5690 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5691         return CVec_u8Z_clone(&owner->b);
5692 }
5693 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
5694         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5695         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
5696         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5697         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5698         CVec_u8Z_free(ret_var);
5699         return ret_arr;
5700 }
5701
5702 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5703         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5704         for (size_t i = 0; i < ret.datalen; i++) {
5705                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5706         }
5707         return ret;
5708 }
5709 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5710         return ThirtyTwoBytes_clone(&owner->a);
5711 }
5712 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
5713         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5714         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5715         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
5716         return ret_arr;
5717 }
5718
5719 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5720         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
5721 }
5722 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
5723         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5724         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
5725         uint32_tArray ret_arr = NULL;
5726         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5727         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5728         for (size_t v = 0; v < ret_var.datalen; v++) {
5729                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5730                 *ret_conv_21_conv = ret_var.data[v];
5731                 ret_arr_ptr[v] = ((uint32_t)ret_conv_21_conv);
5732         }
5733         
5734         FREE(ret_var.data);
5735         return ret_arr;
5736 }
5737
5738 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5739         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 };
5740         for (size_t i = 0; i < ret.datalen; i++) {
5741                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5742         }
5743         return ret;
5744 }
5745 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5746         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5747         for (size_t i = 0; i < ret.datalen; i++) {
5748                 ret.data[i] = Event_clone(&orig->data[i]);
5749         }
5750         return ret;
5751 }
5752 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5753         return owner->a;
5754 }
5755 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
5756         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5757         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
5758         return ret_val;
5759 }
5760
5761 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5762         return TxOut_clone(&owner->b);
5763 }
5764 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
5765         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5766         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5767         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
5768         return (uint32_t)ret_ref;
5769 }
5770
5771 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5772         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5773         for (size_t i = 0; i < ret.datalen; i++) {
5774                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5775         }
5776         return ret;
5777 }
5778 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5779         return ThirtyTwoBytes_clone(&owner->a);
5780 }
5781 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
5782         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5783         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5784         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
5785         return ret_arr;
5786 }
5787
5788 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5789         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
5790 }
5791 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
5792         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5793         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
5794         uint32_tArray ret_arr = NULL;
5795         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5796         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5797         for (size_t u = 0; u < ret_var.datalen; u++) {
5798                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5799                 *ret_conv_20_conv = ret_var.data[u];
5800                 ret_arr_ptr[u] = ((uint32_t)ret_conv_20_conv);
5801         }
5802         
5803         FREE(ret_var.data);
5804         return ret_arr;
5805 }
5806
5807 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5808         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 };
5809         for (size_t i = 0; i < ret.datalen; i++) {
5810                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5811         }
5812         return ret;
5813 }
5814 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
5815         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5816         switch(obj->tag) {
5817                 case LDKBalance_ClaimableOnChannelClose: return 0;
5818                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
5819                 case LDKBalance_ContentiousClaimable: return 2;
5820                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
5821                 default: abort();
5822         }
5823 }
5824 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
5825         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5826         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
5827         return obj->claimable_on_channel_close.claimable_amount_satoshis;
5828 }
5829 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
5830         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5831         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5832         return obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
5833 }
5834 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
5835         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5836         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5837         return obj->claimable_awaiting_confirmations.confirmation_height;
5838 }
5839 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
5840         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5841         assert(obj->tag == LDKBalance_ContentiousClaimable);
5842         return obj->contentious_claimable.claimable_amount_satoshis;
5843 }
5844 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
5845         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5846         assert(obj->tag == LDKBalance_ContentiousClaimable);
5847         return obj->contentious_claimable.timeout_height;
5848 }
5849 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
5850         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5851         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5852         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
5853 }
5854 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
5855         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5856         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5857         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
5858 }
5859 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
5860         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
5861         for (size_t i = 0; i < ret.datalen; i++) {
5862                 ret.data[i] = Balance_clone(&orig->data[i]);
5863         }
5864         return ret;
5865 }
5866 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5867         return ThirtyTwoBytes_clone(&owner->a);
5868 }
5869 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
5870         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5871         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5872         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
5873         return ret_arr;
5874 }
5875
5876 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5877         return ChannelMonitor_clone(&owner->b);
5878 }
5879 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
5880         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5881         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5882         uint32_t ret_ref = 0;
5883         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5884         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5885         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5886         ret_ref = (uintptr_t)ret_var.inner;
5887         if (ret_var.is_owned) {
5888                 ret_ref |= 1;
5889         }
5890         return ret_ref;
5891 }
5892
5893 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5894 CHECK(owner->result_ok);
5895         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
5896 }
5897 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
5898         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5899         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5900         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
5901         return ((uint32_t)ret_conv);
5902 }
5903
5904 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5905 CHECK(!owner->result_ok);
5906         return DecodeError_clone(&*owner->contents.err);
5907 }
5908 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
5909         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5910         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
5911         uint32_t ret_ref = 0;
5912         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5913         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5915         ret_ref = (uintptr_t)ret_var.inner;
5916         if (ret_var.is_owned) {
5917                 ret_ref |= 1;
5918         }
5919         return ret_ref;
5920 }
5921
5922 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5923 CHECK(owner->result_ok);
5924         return *owner->contents.result;
5925 }
5926 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
5927         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5928         CResult_NoneLightningErrorZ_get_ok(owner_conv);
5929 }
5930
5931 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5932 CHECK(!owner->result_ok);
5933         return LightningError_clone(&*owner->contents.err);
5934 }
5935 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
5936         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5937         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
5938         uint32_t ret_ref = 0;
5939         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5940         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5942         ret_ref = (uintptr_t)ret_var.inner;
5943         if (ret_var.is_owned) {
5944                 ret_ref |= 1;
5945         }
5946         return ret_ref;
5947 }
5948
5949 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
5950         return owner->a;
5951 }
5952 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
5953         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
5954         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
5955         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
5956         return ret_arr;
5957 }
5958
5959 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
5960         return Type_clone(&owner->b);
5961 }
5962 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
5963         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
5964         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
5965         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
5966         return (uint32_t)ret_ret;
5967 }
5968
5969 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
5970         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
5971         for (size_t i = 0; i < ret.datalen; i++) {
5972                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
5973         }
5974         return ret;
5975 }
5976 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5977 CHECK(owner->result_ok);
5978         return *owner->contents.result;
5979 }
5980 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
5981         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
5982         jboolean ret_val = CResult_boolLightningErrorZ_get_ok(owner_conv);
5983         return ret_val;
5984 }
5985
5986 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
5987 CHECK(!owner->result_ok);
5988         return LightningError_clone(&*owner->contents.err);
5989 }
5990 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
5991         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
5992         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
5993         uint32_t ret_ref = 0;
5994         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5995         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5997         ret_ref = (uintptr_t)ret_var.inner;
5998         if (ret_var.is_owned) {
5999                 ret_ref |= 1;
6000         }
6001         return ret_ref;
6002 }
6003
6004 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6005         return ChannelAnnouncement_clone(&owner->a);
6006 }
6007 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
6008         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
6009         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
6010         uint32_t ret_ref = 0;
6011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6014         ret_ref = (uintptr_t)ret_var.inner;
6015         if (ret_var.is_owned) {
6016                 ret_ref |= 1;
6017         }
6018         return ret_ref;
6019 }
6020
6021 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6022         return ChannelUpdate_clone(&owner->b);
6023 }
6024 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
6025         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
6026         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
6027         uint32_t ret_ref = 0;
6028         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6029         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6031         ret_ref = (uintptr_t)ret_var.inner;
6032         if (ret_var.is_owned) {
6033                 ret_ref |= 1;
6034         }
6035         return ret_ref;
6036 }
6037
6038 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6039         return ChannelUpdate_clone(&owner->c);
6040 }
6041 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
6042         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
6043         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
6044         uint32_t ret_ref = 0;
6045         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6046         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6048         ret_ref = (uintptr_t)ret_var.inner;
6049         if (ret_var.is_owned) {
6050                 ret_ref |= 1;
6051         }
6052         return ret_ref;
6053 }
6054
6055 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
6056         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
6057         for (size_t i = 0; i < ret.datalen; i++) {
6058                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
6059         }
6060         return ret;
6061 }
6062 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
6063         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
6064         for (size_t i = 0; i < ret.datalen; i++) {
6065                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
6066         }
6067         return ret;
6068 }
6069 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_ty_from_ptr"))) TS_LDKCOption_NetAddressZ_ty_from_ptr(uint32_t ptr) {
6070         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6071         switch(obj->tag) {
6072                 case LDKCOption_NetAddressZ_Some: return 0;
6073                 case LDKCOption_NetAddressZ_None: return 1;
6074                 default: abort();
6075         }
6076 }
6077 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_Some_get_some"))) TS_LDKCOption_NetAddressZ_Some_get_some(uint32_t ptr) {
6078         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6079         assert(obj->tag == LDKCOption_NetAddressZ_Some);
6080                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6081         return some_ref;
6082 }
6083 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6084 CHECK(owner->result_ok);
6085         return CVec_u8Z_clone(&*owner->contents.result);
6086 }
6087 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
6088         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6089         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
6090         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6091         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6092         CVec_u8Z_free(ret_var);
6093         return ret_arr;
6094 }
6095
6096 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6097 CHECK(!owner->result_ok);
6098         return PeerHandleError_clone(&*owner->contents.err);
6099 }
6100 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
6101         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6102         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
6103         uint32_t ret_ref = 0;
6104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6107         ret_ref = (uintptr_t)ret_var.inner;
6108         if (ret_var.is_owned) {
6109                 ret_ref |= 1;
6110         }
6111         return ret_ref;
6112 }
6113
6114 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6115 CHECK(owner->result_ok);
6116         return *owner->contents.result;
6117 }
6118 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
6119         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6120         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
6121 }
6122
6123 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6124 CHECK(!owner->result_ok);
6125         return PeerHandleError_clone(&*owner->contents.err);
6126 }
6127 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
6128         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6129         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
6130         uint32_t ret_ref = 0;
6131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6134         ret_ref = (uintptr_t)ret_var.inner;
6135         if (ret_var.is_owned) {
6136                 ret_ref |= 1;
6137         }
6138         return ret_ref;
6139 }
6140
6141 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6142 CHECK(owner->result_ok);
6143         return *owner->contents.result;
6144 }
6145 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
6146         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6147         jboolean ret_val = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6148         return ret_val;
6149 }
6150
6151 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6152 CHECK(!owner->result_ok);
6153         return PeerHandleError_clone(&*owner->contents.err);
6154 }
6155 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
6156         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6157         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6158         uint32_t ret_ref = 0;
6159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6162         ret_ref = (uintptr_t)ret_var.inner;
6163         if (ret_var.is_owned) {
6164                 ret_ref |= 1;
6165         }
6166         return ret_ref;
6167 }
6168
6169 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6170 CHECK(owner->result_ok);
6171         return NodeId_clone(&*owner->contents.result);
6172 }
6173 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
6174         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6175         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
6176         uint32_t ret_ref = 0;
6177         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6178         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6180         ret_ref = (uintptr_t)ret_var.inner;
6181         if (ret_var.is_owned) {
6182                 ret_ref |= 1;
6183         }
6184         return ret_ref;
6185 }
6186
6187 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6188 CHECK(!owner->result_ok);
6189         return DecodeError_clone(&*owner->contents.err);
6190 }
6191 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
6192         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6193         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
6194         uint32_t ret_ref = 0;
6195         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6196         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6198         ret_ref = (uintptr_t)ret_var.inner;
6199         if (ret_var.is_owned) {
6200                 ret_ref |= 1;
6201         }
6202         return ret_ref;
6203 }
6204
6205 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6206 CHECK(owner->result_ok);
6207         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
6208 }
6209 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
6210         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6211         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
6212         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
6213         uint32_t ret_ref = (uintptr_t)ret_copy;
6214         return ret_ref;
6215 }
6216
6217 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6218 CHECK(!owner->result_ok);
6219         return DecodeError_clone(&*owner->contents.err);
6220 }
6221 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
6222         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6223         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
6224         uint32_t ret_ref = 0;
6225         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6226         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6228         ret_ref = (uintptr_t)ret_var.inner;
6229         if (ret_var.is_owned) {
6230                 ret_ref |= 1;
6231         }
6232         return ret_ref;
6233 }
6234
6235 typedef struct LDKAccess_JCalls {
6236         atomic_size_t refcnt;
6237         uint32_t instance_ptr;
6238 } LDKAccess_JCalls;
6239 static void LDKAccess_JCalls_free(void* this_arg) {
6240         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6241         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6242                 FREE(j_calls);
6243         }
6244 }
6245 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6246         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6247         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
6248         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
6249         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 31, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id);
6250         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6251         CHECK_ACCESS(ret_ptr);
6252         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
6253         FREE((void*)ret);
6254         return ret_conv;
6255 }
6256 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6257         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6258         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6259 }
6260 static inline LDKAccess LDKAccess_init (JSValue o) {
6261         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6262         atomic_init(&calls->refcnt, 1);
6263         calls->instance_ptr = o;
6264
6265         LDKAccess ret = {
6266                 .this_arg = (void*) calls,
6267                 .get_utxo = get_utxo_LDKAccess_jcall,
6268                 .free = LDKAccess_JCalls_free,
6269         };
6270         return ret;
6271 }
6272 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
6273         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6274         *res_ptr = LDKAccess_init(o);
6275         return (long)res_ptr;
6276 }
6277 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) {
6278         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6279         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6280         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
6281         unsigned char genesis_hash_arr[32];
6282         CHECK(genesis_hash->arr_len == 32);
6283         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
6284         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6285         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6286         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6287         return (uint32_t)ret_conv;
6288 }
6289
6290 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
6291         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6292         switch(obj->tag) {
6293                 case LDKCOption_AccessZ_Some: return 0;
6294                 case LDKCOption_AccessZ_None: return 1;
6295                 default: abort();
6296         }
6297 }
6298 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
6299         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6300         assert(obj->tag == LDKCOption_AccessZ_Some);
6301                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
6302                         *some_ret = obj->some;
6303                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
6304                         if ((*some_ret).free == LDKAccess_JCalls_free) {
6305                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6306                                 LDKAccess_JCalls_cloned(&(*some_ret));
6307                         }
6308         return (uint32_t)some_ret;
6309 }
6310 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6311 CHECK(owner->result_ok);
6312         return ChannelUpdateInfo_clone(&*owner->contents.result);
6313 }
6314 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint32_t owner) {
6315         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6316         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
6317         uint32_t ret_ref = 0;
6318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6321         ret_ref = (uintptr_t)ret_var.inner;
6322         if (ret_var.is_owned) {
6323                 ret_ref |= 1;
6324         }
6325         return ret_ref;
6326 }
6327
6328 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6329 CHECK(!owner->result_ok);
6330         return DecodeError_clone(&*owner->contents.err);
6331 }
6332 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint32_t owner) {
6333         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6334         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
6335         uint32_t ret_ref = 0;
6336         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6337         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6339         ret_ref = (uintptr_t)ret_var.inner;
6340         if (ret_var.is_owned) {
6341                 ret_ref |= 1;
6342         }
6343         return ret_ref;
6344 }
6345
6346 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6347 CHECK(owner->result_ok);
6348         return ChannelInfo_clone(&*owner->contents.result);
6349 }
6350 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
6351         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6352         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
6353         uint32_t ret_ref = 0;
6354         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6355         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6357         ret_ref = (uintptr_t)ret_var.inner;
6358         if (ret_var.is_owned) {
6359                 ret_ref |= 1;
6360         }
6361         return ret_ref;
6362 }
6363
6364 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6365 CHECK(!owner->result_ok);
6366         return DecodeError_clone(&*owner->contents.err);
6367 }
6368 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
6369         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6370         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
6371         uint32_t ret_ref = 0;
6372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6375         ret_ref = (uintptr_t)ret_var.inner;
6376         if (ret_var.is_owned) {
6377                 ret_ref |= 1;
6378         }
6379         return ret_ref;
6380 }
6381
6382 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6383 CHECK(owner->result_ok);
6384         return RoutingFees_clone(&*owner->contents.result);
6385 }
6386 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
6387         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6388         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
6389         uint32_t ret_ref = 0;
6390         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6391         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6393         ret_ref = (uintptr_t)ret_var.inner;
6394         if (ret_var.is_owned) {
6395                 ret_ref |= 1;
6396         }
6397         return ret_ref;
6398 }
6399
6400 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6401 CHECK(!owner->result_ok);
6402         return DecodeError_clone(&*owner->contents.err);
6403 }
6404 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
6405         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6406         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
6407         uint32_t ret_ref = 0;
6408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6411         ret_ref = (uintptr_t)ret_var.inner;
6412         if (ret_var.is_owned) {
6413                 ret_ref |= 1;
6414         }
6415         return ret_ref;
6416 }
6417
6418 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6419 CHECK(owner->result_ok);
6420         return NodeAnnouncementInfo_clone(&*owner->contents.result);
6421 }
6422 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
6423         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6424         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
6425         uint32_t ret_ref = 0;
6426         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6427         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6429         ret_ref = (uintptr_t)ret_var.inner;
6430         if (ret_var.is_owned) {
6431                 ret_ref |= 1;
6432         }
6433         return ret_ref;
6434 }
6435
6436 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6437 CHECK(!owner->result_ok);
6438         return DecodeError_clone(&*owner->contents.err);
6439 }
6440 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
6441         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6442         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
6443         uint32_t ret_ref = 0;
6444         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6445         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6447         ret_ref = (uintptr_t)ret_var.inner;
6448         if (ret_var.is_owned) {
6449                 ret_ref |= 1;
6450         }
6451         return ret_ref;
6452 }
6453
6454 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6455         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6456         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6457         return ret;
6458 }
6459 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6460 CHECK(owner->result_ok);
6461         return NodeInfo_clone(&*owner->contents.result);
6462 }
6463 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
6464         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6465         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
6466         uint32_t ret_ref = 0;
6467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6470         ret_ref = (uintptr_t)ret_var.inner;
6471         if (ret_var.is_owned) {
6472                 ret_ref |= 1;
6473         }
6474         return ret_ref;
6475 }
6476
6477 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6478 CHECK(!owner->result_ok);
6479         return DecodeError_clone(&*owner->contents.err);
6480 }
6481 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
6482         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6483         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
6484         uint32_t ret_ref = 0;
6485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6488         ret_ref = (uintptr_t)ret_var.inner;
6489         if (ret_var.is_owned) {
6490                 ret_ref |= 1;
6491         }
6492         return ret_ref;
6493 }
6494
6495 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6496 CHECK(owner->result_ok);
6497         return NetworkGraph_clone(&*owner->contents.result);
6498 }
6499 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
6500         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6501         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
6502         uint32_t ret_ref = 0;
6503         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6504         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6506         ret_ref = (uintptr_t)ret_var.inner;
6507         if (ret_var.is_owned) {
6508                 ret_ref |= 1;
6509         }
6510         return ret_ref;
6511 }
6512
6513 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6514 CHECK(!owner->result_ok);
6515         return DecodeError_clone(&*owner->contents.err);
6516 }
6517 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
6518         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6519         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
6520         uint32_t ret_ref = 0;
6521         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6522         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6524         ret_ref = (uintptr_t)ret_var.inner;
6525         if (ret_var.is_owned) {
6526                 ret_ref |= 1;
6527         }
6528         return ret_ref;
6529 }
6530
6531 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
6532         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6533         switch(obj->tag) {
6534                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
6535                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
6536                 default: abort();
6537         }
6538 }
6539 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
6540         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6541         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
6542                         LDKCVec_NetAddressZ some_var = obj->some;
6543                         uint32_tArray some_arr = NULL;
6544                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
6545                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
6546                         for (size_t m = 0; m < some_var.datalen; m++) {
6547                                 uint32_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
6548                                 some_arr_ptr[m] = some_conv_12_ref;
6549                         }
6550                         
6551         return some_arr;
6552 }
6553 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6554 CHECK(owner->result_ok);
6555         return NetAddress_clone(&*owner->contents.result);
6556 }
6557 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
6558         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6559         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
6560         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
6561         uint32_t ret_ref = (uintptr_t)ret_copy;
6562         return ret_ref;
6563 }
6564
6565 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6566 CHECK(!owner->result_ok);
6567         return DecodeError_clone(&*owner->contents.err);
6568 }
6569 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
6570         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6571         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
6572         uint32_t ret_ref = 0;
6573         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6574         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6576         ret_ref = (uintptr_t)ret_var.inner;
6577         if (ret_var.is_owned) {
6578                 ret_ref |= 1;
6579         }
6580         return ret_ref;
6581 }
6582
6583 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6584         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6585         for (size_t i = 0; i < ret.datalen; i++) {
6586                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6587         }
6588         return ret;
6589 }
6590 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6591         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6592         for (size_t i = 0; i < ret.datalen; i++) {
6593                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6594         }
6595         return ret;
6596 }
6597 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6598         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6599         for (size_t i = 0; i < ret.datalen; i++) {
6600                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6601         }
6602         return ret;
6603 }
6604 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6605         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6606         for (size_t i = 0; i < ret.datalen; i++) {
6607                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6608         }
6609         return ret;
6610 }
6611 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6612 CHECK(owner->result_ok);
6613         return AcceptChannel_clone(&*owner->contents.result);
6614 }
6615 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
6616         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6617         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(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 struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6630 CHECK(!owner->result_ok);
6631         return DecodeError_clone(&*owner->contents.err);
6632 }
6633 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
6634         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6635         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
6636         uint32_t ret_ref = 0;
6637         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6638         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6640         ret_ref = (uintptr_t)ret_var.inner;
6641         if (ret_var.is_owned) {
6642                 ret_ref |= 1;
6643         }
6644         return ret_ref;
6645 }
6646
6647 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6648 CHECK(owner->result_ok);
6649         return AnnouncementSignatures_clone(&*owner->contents.result);
6650 }
6651 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
6652         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6653         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
6654         uint32_t ret_ref = 0;
6655         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6656         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6658         ret_ref = (uintptr_t)ret_var.inner;
6659         if (ret_var.is_owned) {
6660                 ret_ref |= 1;
6661         }
6662         return ret_ref;
6663 }
6664
6665 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6666 CHECK(!owner->result_ok);
6667         return DecodeError_clone(&*owner->contents.err);
6668 }
6669 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
6670         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6671         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
6672         uint32_t ret_ref = 0;
6673         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6674         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6676         ret_ref = (uintptr_t)ret_var.inner;
6677         if (ret_var.is_owned) {
6678                 ret_ref |= 1;
6679         }
6680         return ret_ref;
6681 }
6682
6683 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6684 CHECK(owner->result_ok);
6685         return ChannelReestablish_clone(&*owner->contents.result);
6686 }
6687 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
6688         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6689         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
6690         uint32_t ret_ref = 0;
6691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6694         ret_ref = (uintptr_t)ret_var.inner;
6695         if (ret_var.is_owned) {
6696                 ret_ref |= 1;
6697         }
6698         return ret_ref;
6699 }
6700
6701 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6702 CHECK(!owner->result_ok);
6703         return DecodeError_clone(&*owner->contents.err);
6704 }
6705 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
6706         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6707         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
6708         uint32_t ret_ref = 0;
6709         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6710         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6712         ret_ref = (uintptr_t)ret_var.inner;
6713         if (ret_var.is_owned) {
6714                 ret_ref |= 1;
6715         }
6716         return ret_ref;
6717 }
6718
6719 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6720 CHECK(owner->result_ok);
6721         return ClosingSigned_clone(&*owner->contents.result);
6722 }
6723 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6724         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6725         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
6726         uint32_t ret_ref = 0;
6727         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6728         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6730         ret_ref = (uintptr_t)ret_var.inner;
6731         if (ret_var.is_owned) {
6732                 ret_ref |= 1;
6733         }
6734         return ret_ref;
6735 }
6736
6737 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6738 CHECK(!owner->result_ok);
6739         return DecodeError_clone(&*owner->contents.err);
6740 }
6741 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
6742         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6743         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
6744         uint32_t ret_ref = 0;
6745         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6746         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6748         ret_ref = (uintptr_t)ret_var.inner;
6749         if (ret_var.is_owned) {
6750                 ret_ref |= 1;
6751         }
6752         return ret_ref;
6753 }
6754
6755 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6756 CHECK(owner->result_ok);
6757         return ClosingSignedFeeRange_clone(&*owner->contents.result);
6758 }
6759 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
6760         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6761         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
6762         uint32_t ret_ref = 0;
6763         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6764         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6766         ret_ref = (uintptr_t)ret_var.inner;
6767         if (ret_var.is_owned) {
6768                 ret_ref |= 1;
6769         }
6770         return ret_ref;
6771 }
6772
6773 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6774 CHECK(!owner->result_ok);
6775         return DecodeError_clone(&*owner->contents.err);
6776 }
6777 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
6778         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6779         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
6780         uint32_t ret_ref = 0;
6781         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6782         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6784         ret_ref = (uintptr_t)ret_var.inner;
6785         if (ret_var.is_owned) {
6786                 ret_ref |= 1;
6787         }
6788         return ret_ref;
6789 }
6790
6791 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6792 CHECK(owner->result_ok);
6793         return CommitmentSigned_clone(&*owner->contents.result);
6794 }
6795 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
6796         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6797         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
6798         uint32_t ret_ref = 0;
6799         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6800         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6802         ret_ref = (uintptr_t)ret_var.inner;
6803         if (ret_var.is_owned) {
6804                 ret_ref |= 1;
6805         }
6806         return ret_ref;
6807 }
6808
6809 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6810 CHECK(!owner->result_ok);
6811         return DecodeError_clone(&*owner->contents.err);
6812 }
6813 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
6814         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6815         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
6816         uint32_t ret_ref = 0;
6817         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6818         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6820         ret_ref = (uintptr_t)ret_var.inner;
6821         if (ret_var.is_owned) {
6822                 ret_ref |= 1;
6823         }
6824         return ret_ref;
6825 }
6826
6827 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6828 CHECK(owner->result_ok);
6829         return FundingCreated_clone(&*owner->contents.result);
6830 }
6831 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
6832         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6833         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
6834         uint32_t ret_ref = 0;
6835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6838         ret_ref = (uintptr_t)ret_var.inner;
6839         if (ret_var.is_owned) {
6840                 ret_ref |= 1;
6841         }
6842         return ret_ref;
6843 }
6844
6845 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6846 CHECK(!owner->result_ok);
6847         return DecodeError_clone(&*owner->contents.err);
6848 }
6849 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
6850         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6851         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
6852         uint32_t ret_ref = 0;
6853         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6854         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6856         ret_ref = (uintptr_t)ret_var.inner;
6857         if (ret_var.is_owned) {
6858                 ret_ref |= 1;
6859         }
6860         return ret_ref;
6861 }
6862
6863 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6864 CHECK(owner->result_ok);
6865         return FundingSigned_clone(&*owner->contents.result);
6866 }
6867 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6868         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6869         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
6870         uint32_t ret_ref = 0;
6871         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6872         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6874         ret_ref = (uintptr_t)ret_var.inner;
6875         if (ret_var.is_owned) {
6876                 ret_ref |= 1;
6877         }
6878         return ret_ref;
6879 }
6880
6881 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6882 CHECK(!owner->result_ok);
6883         return DecodeError_clone(&*owner->contents.err);
6884 }
6885 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
6886         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6887         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
6888         uint32_t ret_ref = 0;
6889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6892         ret_ref = (uintptr_t)ret_var.inner;
6893         if (ret_var.is_owned) {
6894                 ret_ref |= 1;
6895         }
6896         return ret_ref;
6897 }
6898
6899 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6900 CHECK(owner->result_ok);
6901         return FundingLocked_clone(&*owner->contents.result);
6902 }
6903 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_ok"))) TS_CResult_FundingLockedDecodeErrorZ_get_ok(uint32_t owner) {
6904         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6905         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
6906         uint32_t ret_ref = 0;
6907         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6908         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6909         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6910         ret_ref = (uintptr_t)ret_var.inner;
6911         if (ret_var.is_owned) {
6912                 ret_ref |= 1;
6913         }
6914         return ret_ref;
6915 }
6916
6917 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6918 CHECK(!owner->result_ok);
6919         return DecodeError_clone(&*owner->contents.err);
6920 }
6921 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_err"))) TS_CResult_FundingLockedDecodeErrorZ_get_err(uint32_t owner) {
6922         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6923         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
6924         uint32_t ret_ref = 0;
6925         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6926         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6928         ret_ref = (uintptr_t)ret_var.inner;
6929         if (ret_var.is_owned) {
6930                 ret_ref |= 1;
6931         }
6932         return ret_ref;
6933 }
6934
6935 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6936 CHECK(owner->result_ok);
6937         return Init_clone(&*owner->contents.result);
6938 }
6939 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
6940         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
6941         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
6942         uint32_t ret_ref = 0;
6943         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6944         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6946         ret_ref = (uintptr_t)ret_var.inner;
6947         if (ret_var.is_owned) {
6948                 ret_ref |= 1;
6949         }
6950         return ret_ref;
6951 }
6952
6953 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6954 CHECK(!owner->result_ok);
6955         return DecodeError_clone(&*owner->contents.err);
6956 }
6957 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
6958         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
6959         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
6960         uint32_t ret_ref = 0;
6961         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6962         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6964         ret_ref = (uintptr_t)ret_var.inner;
6965         if (ret_var.is_owned) {
6966                 ret_ref |= 1;
6967         }
6968         return ret_ref;
6969 }
6970
6971 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
6972 CHECK(owner->result_ok);
6973         return OpenChannel_clone(&*owner->contents.result);
6974 }
6975 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
6976         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
6977         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
6978         uint32_t ret_ref = 0;
6979         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6980         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6982         ret_ref = (uintptr_t)ret_var.inner;
6983         if (ret_var.is_owned) {
6984                 ret_ref |= 1;
6985         }
6986         return ret_ref;
6987 }
6988
6989 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
6990 CHECK(!owner->result_ok);
6991         return DecodeError_clone(&*owner->contents.err);
6992 }
6993 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
6994         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
6995         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
6996         uint32_t ret_ref = 0;
6997         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6998         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7000         ret_ref = (uintptr_t)ret_var.inner;
7001         if (ret_var.is_owned) {
7002                 ret_ref |= 1;
7003         }
7004         return ret_ref;
7005 }
7006
7007 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7008 CHECK(owner->result_ok);
7009         return RevokeAndACK_clone(&*owner->contents.result);
7010 }
7011 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
7012         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7013         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
7014         uint32_t ret_ref = 0;
7015         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7016         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7018         ret_ref = (uintptr_t)ret_var.inner;
7019         if (ret_var.is_owned) {
7020                 ret_ref |= 1;
7021         }
7022         return ret_ref;
7023 }
7024
7025 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7026 CHECK(!owner->result_ok);
7027         return DecodeError_clone(&*owner->contents.err);
7028 }
7029 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
7030         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7031         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
7032         uint32_t ret_ref = 0;
7033         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7034         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7036         ret_ref = (uintptr_t)ret_var.inner;
7037         if (ret_var.is_owned) {
7038                 ret_ref |= 1;
7039         }
7040         return ret_ref;
7041 }
7042
7043 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7044 CHECK(owner->result_ok);
7045         return Shutdown_clone(&*owner->contents.result);
7046 }
7047 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
7048         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7049         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
7050         uint32_t ret_ref = 0;
7051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7054         ret_ref = (uintptr_t)ret_var.inner;
7055         if (ret_var.is_owned) {
7056                 ret_ref |= 1;
7057         }
7058         return ret_ref;
7059 }
7060
7061 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7062 CHECK(!owner->result_ok);
7063         return DecodeError_clone(&*owner->contents.err);
7064 }
7065 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
7066         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7067         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
7068         uint32_t ret_ref = 0;
7069         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7070         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7072         ret_ref = (uintptr_t)ret_var.inner;
7073         if (ret_var.is_owned) {
7074                 ret_ref |= 1;
7075         }
7076         return ret_ref;
7077 }
7078
7079 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7080 CHECK(owner->result_ok);
7081         return UpdateFailHTLC_clone(&*owner->contents.result);
7082 }
7083 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7084         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7085         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
7086         uint32_t ret_ref = 0;
7087         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7088         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7090         ret_ref = (uintptr_t)ret_var.inner;
7091         if (ret_var.is_owned) {
7092                 ret_ref |= 1;
7093         }
7094         return ret_ref;
7095 }
7096
7097 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7098 CHECK(!owner->result_ok);
7099         return DecodeError_clone(&*owner->contents.err);
7100 }
7101 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
7102         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7103         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
7104         uint32_t ret_ref = 0;
7105         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7106         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7108         ret_ref = (uintptr_t)ret_var.inner;
7109         if (ret_var.is_owned) {
7110                 ret_ref |= 1;
7111         }
7112         return ret_ref;
7113 }
7114
7115 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7116 CHECK(owner->result_ok);
7117         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
7118 }
7119 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7120         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7121         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
7122         uint32_t ret_ref = 0;
7123         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7124         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7126         ret_ref = (uintptr_t)ret_var.inner;
7127         if (ret_var.is_owned) {
7128                 ret_ref |= 1;
7129         }
7130         return ret_ref;
7131 }
7132
7133 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7134 CHECK(!owner->result_ok);
7135         return DecodeError_clone(&*owner->contents.err);
7136 }
7137 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
7138         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7139         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
7140         uint32_t ret_ref = 0;
7141         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7142         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7144         ret_ref = (uintptr_t)ret_var.inner;
7145         if (ret_var.is_owned) {
7146                 ret_ref |= 1;
7147         }
7148         return ret_ref;
7149 }
7150
7151 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7152 CHECK(owner->result_ok);
7153         return UpdateFee_clone(&*owner->contents.result);
7154 }
7155 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
7156         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7157         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
7158         uint32_t ret_ref = 0;
7159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7162         ret_ref = (uintptr_t)ret_var.inner;
7163         if (ret_var.is_owned) {
7164                 ret_ref |= 1;
7165         }
7166         return ret_ref;
7167 }
7168
7169 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7170 CHECK(!owner->result_ok);
7171         return DecodeError_clone(&*owner->contents.err);
7172 }
7173 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
7174         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7175         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
7176         uint32_t ret_ref = 0;
7177         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7178         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7180         ret_ref = (uintptr_t)ret_var.inner;
7181         if (ret_var.is_owned) {
7182                 ret_ref |= 1;
7183         }
7184         return ret_ref;
7185 }
7186
7187 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7188 CHECK(owner->result_ok);
7189         return UpdateFulfillHTLC_clone(&*owner->contents.result);
7190 }
7191 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7192         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7193         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
7194         uint32_t ret_ref = 0;
7195         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7196         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7198         ret_ref = (uintptr_t)ret_var.inner;
7199         if (ret_var.is_owned) {
7200                 ret_ref |= 1;
7201         }
7202         return ret_ref;
7203 }
7204
7205 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7206 CHECK(!owner->result_ok);
7207         return DecodeError_clone(&*owner->contents.err);
7208 }
7209 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
7210         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7211         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
7212         uint32_t ret_ref = 0;
7213         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7214         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7216         ret_ref = (uintptr_t)ret_var.inner;
7217         if (ret_var.is_owned) {
7218                 ret_ref |= 1;
7219         }
7220         return ret_ref;
7221 }
7222
7223 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7224 CHECK(owner->result_ok);
7225         return UpdateAddHTLC_clone(&*owner->contents.result);
7226 }
7227 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7228         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7229         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
7230         uint32_t ret_ref = 0;
7231         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7232         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7234         ret_ref = (uintptr_t)ret_var.inner;
7235         if (ret_var.is_owned) {
7236                 ret_ref |= 1;
7237         }
7238         return ret_ref;
7239 }
7240
7241 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7242 CHECK(!owner->result_ok);
7243         return DecodeError_clone(&*owner->contents.err);
7244 }
7245 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
7246         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7247         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
7248         uint32_t ret_ref = 0;
7249         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7250         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7252         ret_ref = (uintptr_t)ret_var.inner;
7253         if (ret_var.is_owned) {
7254                 ret_ref |= 1;
7255         }
7256         return ret_ref;
7257 }
7258
7259 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7260 CHECK(owner->result_ok);
7261         return Ping_clone(&*owner->contents.result);
7262 }
7263 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
7264         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7265         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
7266         uint32_t ret_ref = 0;
7267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7270         ret_ref = (uintptr_t)ret_var.inner;
7271         if (ret_var.is_owned) {
7272                 ret_ref |= 1;
7273         }
7274         return ret_ref;
7275 }
7276
7277 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7278 CHECK(!owner->result_ok);
7279         return DecodeError_clone(&*owner->contents.err);
7280 }
7281 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
7282         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7283         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
7284         uint32_t ret_ref = 0;
7285         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7286         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7288         ret_ref = (uintptr_t)ret_var.inner;
7289         if (ret_var.is_owned) {
7290                 ret_ref |= 1;
7291         }
7292         return ret_ref;
7293 }
7294
7295 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7296 CHECK(owner->result_ok);
7297         return Pong_clone(&*owner->contents.result);
7298 }
7299 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
7300         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7301         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
7302         uint32_t ret_ref = 0;
7303         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7304         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7306         ret_ref = (uintptr_t)ret_var.inner;
7307         if (ret_var.is_owned) {
7308                 ret_ref |= 1;
7309         }
7310         return ret_ref;
7311 }
7312
7313 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7314 CHECK(!owner->result_ok);
7315         return DecodeError_clone(&*owner->contents.err);
7316 }
7317 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
7318         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7319         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
7320         uint32_t ret_ref = 0;
7321         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7322         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7324         ret_ref = (uintptr_t)ret_var.inner;
7325         if (ret_var.is_owned) {
7326                 ret_ref |= 1;
7327         }
7328         return ret_ref;
7329 }
7330
7331 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7332 CHECK(owner->result_ok);
7333         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
7334 }
7335 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7336         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7337         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7338         uint32_t ret_ref = 0;
7339         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7340         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7342         ret_ref = (uintptr_t)ret_var.inner;
7343         if (ret_var.is_owned) {
7344                 ret_ref |= 1;
7345         }
7346         return ret_ref;
7347 }
7348
7349 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7350 CHECK(!owner->result_ok);
7351         return DecodeError_clone(&*owner->contents.err);
7352 }
7353 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7354         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7355         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7356         uint32_t ret_ref = 0;
7357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7360         ret_ref = (uintptr_t)ret_var.inner;
7361         if (ret_var.is_owned) {
7362                 ret_ref |= 1;
7363         }
7364         return ret_ref;
7365 }
7366
7367 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7368 CHECK(owner->result_ok);
7369         return ChannelAnnouncement_clone(&*owner->contents.result);
7370 }
7371 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7372         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7373         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7374         uint32_t ret_ref = 0;
7375         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7376         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7378         ret_ref = (uintptr_t)ret_var.inner;
7379         if (ret_var.is_owned) {
7380                 ret_ref |= 1;
7381         }
7382         return ret_ref;
7383 }
7384
7385 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7386 CHECK(!owner->result_ok);
7387         return DecodeError_clone(&*owner->contents.err);
7388 }
7389 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7390         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7391         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7392         uint32_t ret_ref = 0;
7393         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7394         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7396         ret_ref = (uintptr_t)ret_var.inner;
7397         if (ret_var.is_owned) {
7398                 ret_ref |= 1;
7399         }
7400         return ret_ref;
7401 }
7402
7403 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7404 CHECK(owner->result_ok);
7405         return UnsignedChannelUpdate_clone(&*owner->contents.result);
7406 }
7407 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7408         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7409         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7410         uint32_t ret_ref = 0;
7411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7414         ret_ref = (uintptr_t)ret_var.inner;
7415         if (ret_var.is_owned) {
7416                 ret_ref |= 1;
7417         }
7418         return ret_ref;
7419 }
7420
7421 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7422 CHECK(!owner->result_ok);
7423         return DecodeError_clone(&*owner->contents.err);
7424 }
7425 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7426         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7427         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
7428         uint32_t ret_ref = 0;
7429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7432         ret_ref = (uintptr_t)ret_var.inner;
7433         if (ret_var.is_owned) {
7434                 ret_ref |= 1;
7435         }
7436         return ret_ref;
7437 }
7438
7439 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7440 CHECK(owner->result_ok);
7441         return ChannelUpdate_clone(&*owner->contents.result);
7442 }
7443 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7444         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7445         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7446         uint32_t ret_ref = 0;
7447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7450         ret_ref = (uintptr_t)ret_var.inner;
7451         if (ret_var.is_owned) {
7452                 ret_ref |= 1;
7453         }
7454         return ret_ref;
7455 }
7456
7457 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7458 CHECK(!owner->result_ok);
7459         return DecodeError_clone(&*owner->contents.err);
7460 }
7461 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7462         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7463         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
7464         uint32_t ret_ref = 0;
7465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7468         ret_ref = (uintptr_t)ret_var.inner;
7469         if (ret_var.is_owned) {
7470                 ret_ref |= 1;
7471         }
7472         return ret_ref;
7473 }
7474
7475 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7476 CHECK(owner->result_ok);
7477         return ErrorMessage_clone(&*owner->contents.result);
7478 }
7479 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
7480         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7481         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
7482         uint32_t ret_ref = 0;
7483         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7484         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7486         ret_ref = (uintptr_t)ret_var.inner;
7487         if (ret_var.is_owned) {
7488                 ret_ref |= 1;
7489         }
7490         return ret_ref;
7491 }
7492
7493 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7494 CHECK(!owner->result_ok);
7495         return DecodeError_clone(&*owner->contents.err);
7496 }
7497 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
7498         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7499         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
7500         uint32_t ret_ref = 0;
7501         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7502         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7504         ret_ref = (uintptr_t)ret_var.inner;
7505         if (ret_var.is_owned) {
7506                 ret_ref |= 1;
7507         }
7508         return ret_ref;
7509 }
7510
7511 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7512 CHECK(owner->result_ok);
7513         return WarningMessage_clone(&*owner->contents.result);
7514 }
7515 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint32_t owner) {
7516         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7517         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
7518         uint32_t ret_ref = 0;
7519         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7520         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7522         ret_ref = (uintptr_t)ret_var.inner;
7523         if (ret_var.is_owned) {
7524                 ret_ref |= 1;
7525         }
7526         return ret_ref;
7527 }
7528
7529 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7530 CHECK(!owner->result_ok);
7531         return DecodeError_clone(&*owner->contents.err);
7532 }
7533 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint32_t owner) {
7534         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7535         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
7536         uint32_t ret_ref = 0;
7537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7540         ret_ref = (uintptr_t)ret_var.inner;
7541         if (ret_var.is_owned) {
7542                 ret_ref |= 1;
7543         }
7544         return ret_ref;
7545 }
7546
7547 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7548 CHECK(owner->result_ok);
7549         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
7550 }
7551 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7552         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7553         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7554         uint32_t ret_ref = 0;
7555         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7556         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7558         ret_ref = (uintptr_t)ret_var.inner;
7559         if (ret_var.is_owned) {
7560                 ret_ref |= 1;
7561         }
7562         return ret_ref;
7563 }
7564
7565 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7566 CHECK(!owner->result_ok);
7567         return DecodeError_clone(&*owner->contents.err);
7568 }
7569 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7570         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7571         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7572         uint32_t ret_ref = 0;
7573         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7574         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7576         ret_ref = (uintptr_t)ret_var.inner;
7577         if (ret_var.is_owned) {
7578                 ret_ref |= 1;
7579         }
7580         return ret_ref;
7581 }
7582
7583 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7584 CHECK(owner->result_ok);
7585         return NodeAnnouncement_clone(&*owner->contents.result);
7586 }
7587 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7588         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7589         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7590         uint32_t ret_ref = 0;
7591         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7592         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7594         ret_ref = (uintptr_t)ret_var.inner;
7595         if (ret_var.is_owned) {
7596                 ret_ref |= 1;
7597         }
7598         return ret_ref;
7599 }
7600
7601 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7602 CHECK(!owner->result_ok);
7603         return DecodeError_clone(&*owner->contents.err);
7604 }
7605 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7606         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7607         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7608         uint32_t ret_ref = 0;
7609         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7610         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7612         ret_ref = (uintptr_t)ret_var.inner;
7613         if (ret_var.is_owned) {
7614                 ret_ref |= 1;
7615         }
7616         return ret_ref;
7617 }
7618
7619 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7620 CHECK(owner->result_ok);
7621         return QueryShortChannelIds_clone(&*owner->contents.result);
7622 }
7623 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
7624         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7625         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
7626         uint32_t ret_ref = 0;
7627         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7628         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7630         ret_ref = (uintptr_t)ret_var.inner;
7631         if (ret_var.is_owned) {
7632                 ret_ref |= 1;
7633         }
7634         return ret_ref;
7635 }
7636
7637 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7638 CHECK(!owner->result_ok);
7639         return DecodeError_clone(&*owner->contents.err);
7640 }
7641 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
7642         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7643         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
7644         uint32_t ret_ref = 0;
7645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7648         ret_ref = (uintptr_t)ret_var.inner;
7649         if (ret_var.is_owned) {
7650                 ret_ref |= 1;
7651         }
7652         return ret_ref;
7653 }
7654
7655 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7656 CHECK(owner->result_ok);
7657         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
7658 }
7659 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
7660         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7661         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
7662         uint32_t ret_ref = 0;
7663         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7664         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7666         ret_ref = (uintptr_t)ret_var.inner;
7667         if (ret_var.is_owned) {
7668                 ret_ref |= 1;
7669         }
7670         return ret_ref;
7671 }
7672
7673 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7674 CHECK(!owner->result_ok);
7675         return DecodeError_clone(&*owner->contents.err);
7676 }
7677 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
7678         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7679         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
7680         uint32_t ret_ref = 0;
7681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7684         ret_ref = (uintptr_t)ret_var.inner;
7685         if (ret_var.is_owned) {
7686                 ret_ref |= 1;
7687         }
7688         return ret_ref;
7689 }
7690
7691 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7692 CHECK(owner->result_ok);
7693         return QueryChannelRange_clone(&*owner->contents.result);
7694 }
7695 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7696         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7697         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
7698         uint32_t ret_ref = 0;
7699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7702         ret_ref = (uintptr_t)ret_var.inner;
7703         if (ret_var.is_owned) {
7704                 ret_ref |= 1;
7705         }
7706         return ret_ref;
7707 }
7708
7709 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7710 CHECK(!owner->result_ok);
7711         return DecodeError_clone(&*owner->contents.err);
7712 }
7713 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7714         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7715         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
7716         uint32_t ret_ref = 0;
7717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7720         ret_ref = (uintptr_t)ret_var.inner;
7721         if (ret_var.is_owned) {
7722                 ret_ref |= 1;
7723         }
7724         return ret_ref;
7725 }
7726
7727 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7728 CHECK(owner->result_ok);
7729         return ReplyChannelRange_clone(&*owner->contents.result);
7730 }
7731 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7732         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7733         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
7734         uint32_t ret_ref = 0;
7735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7738         ret_ref = (uintptr_t)ret_var.inner;
7739         if (ret_var.is_owned) {
7740                 ret_ref |= 1;
7741         }
7742         return ret_ref;
7743 }
7744
7745 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7746 CHECK(!owner->result_ok);
7747         return DecodeError_clone(&*owner->contents.err);
7748 }
7749 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7750         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7751         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
7752         uint32_t ret_ref = 0;
7753         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7754         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7756         ret_ref = (uintptr_t)ret_var.inner;
7757         if (ret_var.is_owned) {
7758                 ret_ref |= 1;
7759         }
7760         return ret_ref;
7761 }
7762
7763 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7764 CHECK(owner->result_ok);
7765         return GossipTimestampFilter_clone(&*owner->contents.result);
7766 }
7767 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
7768         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7769         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
7770         uint32_t ret_ref = 0;
7771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7774         ret_ref = (uintptr_t)ret_var.inner;
7775         if (ret_var.is_owned) {
7776                 ret_ref |= 1;
7777         }
7778         return ret_ref;
7779 }
7780
7781 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7782 CHECK(!owner->result_ok);
7783         return DecodeError_clone(&*owner->contents.err);
7784 }
7785 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
7786         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7787         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
7788         uint32_t ret_ref = 0;
7789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7792         ret_ref = (uintptr_t)ret_var.inner;
7793         if (ret_var.is_owned) {
7794                 ret_ref |= 1;
7795         }
7796         return ret_ref;
7797 }
7798
7799 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint32_t ptr) {
7800         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7801         switch(obj->tag) {
7802                 case LDKSignOrCreationError_SignError: return 0;
7803                 case LDKSignOrCreationError_CreationError: return 1;
7804                 default: abort();
7805         }
7806 }
7807 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint32_t ptr) {
7808         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7809         assert(obj->tag == LDKSignOrCreationError_CreationError);
7810                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
7811         return creation_error_conv;
7812 }
7813 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7814 CHECK(owner->result_ok);
7815         return Invoice_clone(&*owner->contents.result);
7816 }
7817 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t owner) {
7818         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7819         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
7820         uint32_t ret_ref = 0;
7821         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7822         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7824         ret_ref = (uintptr_t)ret_var.inner;
7825         if (ret_var.is_owned) {
7826                 ret_ref |= 1;
7827         }
7828         return ret_ref;
7829 }
7830
7831 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7832 CHECK(!owner->result_ok);
7833         return SignOrCreationError_clone(&*owner->contents.err);
7834 }
7835 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t owner) {
7836         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7837         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
7838         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
7839         uint32_t ret_ref = (uintptr_t)ret_copy;
7840         return ret_ref;
7841 }
7842
7843 typedef struct LDKFilter_JCalls {
7844         atomic_size_t refcnt;
7845         uint32_t instance_ptr;
7846 } LDKFilter_JCalls;
7847 static void LDKFilter_JCalls_free(void* this_arg) {
7848         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7849         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7850                 FREE(j_calls);
7851         }
7852 }
7853 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7854         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7855         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
7856         memcpy(txid_arr->elems, *txid, 32);
7857         LDKu8slice script_pubkey_var = script_pubkey;
7858         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
7859         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
7860         js_invoke_function_2(j_calls->instance_ptr, 32, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
7861 }
7862 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7863         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7864         LDKWatchedOutput output_var = output;
7865         uint32_t output_ref = 0;
7866         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7867         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7868         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
7869         output_ref = (uintptr_t)output_var.inner;
7870         if (output_var.is_owned) {
7871                 output_ref |= 1;
7872         }
7873         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 33, (uint32_t)output_ref);
7874         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7875         CHECK_ACCESS(ret_ptr);
7876         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
7877         FREE((void*)ret);
7878         return ret_conv;
7879 }
7880 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7881         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7882         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7883 }
7884 static inline LDKFilter LDKFilter_init (JSValue o) {
7885         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7886         atomic_init(&calls->refcnt, 1);
7887         calls->instance_ptr = o;
7888
7889         LDKFilter ret = {
7890                 .this_arg = (void*) calls,
7891                 .register_tx = register_tx_LDKFilter_jcall,
7892                 .register_output = register_output_LDKFilter_jcall,
7893                 .free = LDKFilter_JCalls_free,
7894         };
7895         return ret;
7896 }
7897 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
7898         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7899         *res_ptr = LDKFilter_init(o);
7900         return (long)res_ptr;
7901 }
7902 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
7903         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7904         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7905         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7906         unsigned char txid_arr[32];
7907         CHECK(txid->arr_len == 32);
7908         memcpy(txid_arr, txid->elems, 32); FREE(txid);
7909         unsigned char (*txid_ref)[32] = &txid_arr;
7910         LDKu8slice script_pubkey_ref;
7911         script_pubkey_ref.datalen = script_pubkey->arr_len;
7912         script_pubkey_ref.data = script_pubkey->elems /* XXX script_pubkey leaks */;
7913         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7914 }
7915
7916 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
7917         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7918         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7919         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7920         LDKWatchedOutput output_conv;
7921         output_conv.inner = (void*)(output & (~1));
7922         output_conv.is_owned = (output & 1) || (output == 0);
7923         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
7924         output_conv = WatchedOutput_clone(&output_conv);
7925         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7926         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7927         uint32_t ret_ref = (uintptr_t)ret_copy;
7928         return ret_ref;
7929 }
7930
7931 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
7932         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7933         switch(obj->tag) {
7934                 case LDKCOption_FilterZ_Some: return 0;
7935                 case LDKCOption_FilterZ_None: return 1;
7936                 default: abort();
7937         }
7938 }
7939 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
7940         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7941         assert(obj->tag == LDKCOption_FilterZ_Some);
7942                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
7943                         *some_ret = obj->some;
7944                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
7945                         if ((*some_ret).free == LDKFilter_JCalls_free) {
7946                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7947                                 LDKFilter_JCalls_cloned(&(*some_ret));
7948                         }
7949         return (uint32_t)some_ret;
7950 }
7951 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7952 CHECK(owner->result_ok);
7953         return &*owner->contents.result;
7954 }
7955 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
7956         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
7957         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
7958         uint32_t ret_ref = 0;
7959         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7960         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7962         ret_ref = (uintptr_t)ret_var.inner & ~1;
7963         return ret_ref;
7964 }
7965
7966 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7967 CHECK(!owner->result_ok);
7968         return *owner->contents.err;
7969 }
7970 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
7971         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
7972         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
7973 }
7974
7975 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
7976         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
7977         for (size_t i = 0; i < ret.datalen; i++) {
7978                 ret.data[i] = OutPoint_clone(&orig->data[i]);
7979         }
7980         return ret;
7981 }
7982 typedef struct LDKMessageSendEventsProvider_JCalls {
7983         atomic_size_t refcnt;
7984         uint32_t instance_ptr;
7985 } LDKMessageSendEventsProvider_JCalls;
7986 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
7987         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7988         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7989                 FREE(j_calls);
7990         }
7991 }
7992 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
7993         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7994         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 34);
7995         LDKCVec_MessageSendEventZ ret_constr;
7996         ret_constr.datalen = ret->arr_len;
7997         if (ret_constr.datalen > 0)
7998                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7999         else
8000                 ret_constr.data = NULL;
8001         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
8002         for (size_t s = 0; s < ret_constr.datalen; s++) {
8003                 uint32_t ret_conv_18 = ret_vals[s];
8004                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
8005                 CHECK_ACCESS(ret_conv_18_ptr);
8006                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
8007                 FREE((void*)ret_conv_18);
8008                 ret_constr.data[s] = ret_conv_18_conv;
8009         }
8010         return ret_constr;
8011 }
8012 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
8013         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
8014         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8015 }
8016 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
8017         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
8018         atomic_init(&calls->refcnt, 1);
8019         calls->instance_ptr = o;
8020
8021         LDKMessageSendEventsProvider ret = {
8022                 .this_arg = (void*) calls,
8023                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
8024                 .free = LDKMessageSendEventsProvider_JCalls_free,
8025         };
8026         return ret;
8027 }
8028 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
8029         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
8030         *res_ptr = LDKMessageSendEventsProvider_init(o);
8031         return (long)res_ptr;
8032 }
8033 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) {
8034         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8035         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8036         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
8037         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
8038         uint32_tArray ret_arr = NULL;
8039         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8040         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8041         for (size_t s = 0; s < ret_var.datalen; s++) {
8042                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
8043                 *ret_conv_18_copy = ret_var.data[s];
8044                 uint32_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
8045                 ret_arr_ptr[s] = ret_conv_18_ref;
8046         }
8047         
8048         FREE(ret_var.data);
8049         return ret_arr;
8050 }
8051
8052 typedef struct LDKEventHandler_JCalls {
8053         atomic_size_t refcnt;
8054         uint32_t instance_ptr;
8055 } LDKEventHandler_JCalls;
8056 static void LDKEventHandler_JCalls_free(void* this_arg) {
8057         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8058         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8059                 FREE(j_calls);
8060         }
8061 }
8062 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
8063         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8064         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
8065         *ret_event = Event_clone(event);
8066         js_invoke_function_1(j_calls->instance_ptr, 35, (uint32_t)(uint32_t)ret_event);
8067 }
8068 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
8069         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
8070         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8071 }
8072 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
8073         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
8074         atomic_init(&calls->refcnt, 1);
8075         calls->instance_ptr = o;
8076
8077         LDKEventHandler ret = {
8078                 .this_arg = (void*) calls,
8079                 .handle_event = handle_event_LDKEventHandler_jcall,
8080                 .free = LDKEventHandler_JCalls_free,
8081         };
8082         return ret;
8083 }
8084 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
8085         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8086         *res_ptr = LDKEventHandler_init(o);
8087         return (long)res_ptr;
8088 }
8089 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
8090         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8091         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8092         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
8093         LDKEvent* event_conv = (LDKEvent*)event;
8094         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
8095 }
8096
8097 typedef struct LDKEventsProvider_JCalls {
8098         atomic_size_t refcnt;
8099         uint32_t instance_ptr;
8100 } LDKEventsProvider_JCalls;
8101 static void LDKEventsProvider_JCalls_free(void* this_arg) {
8102         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8103         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8104                 FREE(j_calls);
8105         }
8106 }
8107 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
8108         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8109         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8110         *handler_ret = handler;
8111         js_invoke_function_1(j_calls->instance_ptr, 36, (uint32_t)(uint32_t)handler_ret);
8112 }
8113 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
8114         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
8115         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8116 }
8117 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
8118         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
8119         atomic_init(&calls->refcnt, 1);
8120         calls->instance_ptr = o;
8121
8122         LDKEventsProvider ret = {
8123                 .this_arg = (void*) calls,
8124                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
8125                 .free = LDKEventsProvider_JCalls_free,
8126         };
8127         return ret;
8128 }
8129 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
8130         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8131         *res_ptr = LDKEventsProvider_init(o);
8132         return (long)res_ptr;
8133 }
8134 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
8135         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8136         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8137         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
8138         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
8139         CHECK_ACCESS(handler_ptr);
8140         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
8141         if (handler_conv.free == LDKEventHandler_JCalls_free) {
8142                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8143                 LDKEventHandler_JCalls_cloned(&handler_conv);
8144         }
8145         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
8146 }
8147
8148 typedef struct LDKListen_JCalls {
8149         atomic_size_t refcnt;
8150         uint32_t instance_ptr;
8151 } LDKListen_JCalls;
8152 static void LDKListen_JCalls_free(void* this_arg) {
8153         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8154         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8155                 FREE(j_calls);
8156         }
8157 }
8158 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
8159         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8160         LDKu8slice block_var = block;
8161         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
8162         memcpy(block_arr->elems, block_var.data, block_var.datalen);
8163         js_invoke_function_2(j_calls->instance_ptr, 37, (uint32_t)block_arr, (uint32_t)height);
8164 }
8165 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8166         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8167         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8168         memcpy(header_arr->elems, *header, 80);
8169         js_invoke_function_2(j_calls->instance_ptr, 38, (uint32_t)header_arr, (uint32_t)height);
8170 }
8171 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
8172         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
8173         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8174 }
8175 static inline LDKListen LDKListen_init (JSValue o) {
8176         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
8177         atomic_init(&calls->refcnt, 1);
8178         calls->instance_ptr = o;
8179
8180         LDKListen ret = {
8181                 .this_arg = (void*) calls,
8182                 .block_connected = block_connected_LDKListen_jcall,
8183                 .block_disconnected = block_disconnected_LDKListen_jcall,
8184                 .free = LDKListen_JCalls_free,
8185         };
8186         return ret;
8187 }
8188 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
8189         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
8190         *res_ptr = LDKListen_init(o);
8191         return (long)res_ptr;
8192 }
8193 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
8194         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8195         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8196         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8197         LDKu8slice block_ref;
8198         block_ref.datalen = block->arr_len;
8199         block_ref.data = block->elems /* XXX block leaks */;
8200         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
8201 }
8202
8203 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
8204         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8205         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8206         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8207         unsigned char header_arr[80];
8208         CHECK(header->arr_len == 80);
8209         memcpy(header_arr, header->elems, 80); FREE(header);
8210         unsigned char (*header_ref)[80] = &header_arr;
8211         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
8212 }
8213
8214 typedef struct LDKConfirm_JCalls {
8215         atomic_size_t refcnt;
8216         uint32_t instance_ptr;
8217 } LDKConfirm_JCalls;
8218 static void LDKConfirm_JCalls_free(void* this_arg) {
8219         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8220         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8221                 FREE(j_calls);
8222         }
8223 }
8224 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8225         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8226         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8227         memcpy(header_arr->elems, *header, 80);
8228         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8229         uint32_tArray txdata_arr = NULL;
8230         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
8231         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
8232         for (size_t c = 0; c < txdata_var.datalen; c++) {
8233                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8234                 *txdata_conv_28_conv = txdata_var.data[c];
8235                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
8236         }
8237         
8238         FREE(txdata_var.data);
8239         js_invoke_function_3(j_calls->instance_ptr, 39, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height);
8240 }
8241 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
8242         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8243         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8244         memcpy(txid_arr->elems, *txid, 32);
8245         js_invoke_function_1(j_calls->instance_ptr, 40, (uint32_t)txid_arr);
8246 }
8247 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8248         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8249         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8250         memcpy(header_arr->elems, *header, 80);
8251         js_invoke_function_2(j_calls->instance_ptr, 41, (uint32_t)header_arr, (uint32_t)height);
8252 }
8253 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
8254         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8255         ptrArray ret = (ptrArray)js_invoke_function_0(j_calls->instance_ptr, 42);
8256         LDKCVec_TxidZ ret_constr;
8257         ret_constr.datalen = ret->arr_len;
8258         if (ret_constr.datalen > 0)
8259                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8260         else
8261                 ret_constr.data = NULL;
8262         int8_tArray* ret_vals = (void*) ret->elems /* XXX ret leaks */;
8263         for (size_t m = 0; m < ret_constr.datalen; m++) {
8264                 int8_tArray ret_conv_12 = ret_vals[m];
8265                 LDKThirtyTwoBytes ret_conv_12_ref;
8266                 CHECK(ret_conv_12->arr_len == 32);
8267                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
8268                 ret_constr.data[m] = ret_conv_12_ref;
8269         }
8270         return ret_constr;
8271 }
8272 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
8273         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
8274         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8275 }
8276 static inline LDKConfirm LDKConfirm_init (JSValue o) {
8277         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
8278         atomic_init(&calls->refcnt, 1);
8279         calls->instance_ptr = o;
8280
8281         LDKConfirm ret = {
8282                 .this_arg = (void*) calls,
8283                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8284                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8285                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8286                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8287                 .free = LDKConfirm_JCalls_free,
8288         };
8289         return ret;
8290 }
8291 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
8292         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8293         *res_ptr = LDKConfirm_init(o);
8294         return (long)res_ptr;
8295 }
8296 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) {
8297         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8298         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8299         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8300         unsigned char header_arr[80];
8301         CHECK(header->arr_len == 80);
8302         memcpy(header_arr, header->elems, 80); FREE(header);
8303         unsigned char (*header_ref)[80] = &header_arr;
8304         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8305         txdata_constr.datalen = txdata->arr_len;
8306         if (txdata_constr.datalen > 0)
8307                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8308         else
8309                 txdata_constr.data = NULL;
8310         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
8311         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8312                 uint32_t txdata_conv_28 = txdata_vals[c];
8313                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
8314                 CHECK_ACCESS(txdata_conv_28_ptr);
8315                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8316                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
8317                 txdata_constr.data[c] = txdata_conv_28_conv;
8318         }
8319         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8320 }
8321
8322 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
8323         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8324         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8325         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8326         unsigned char txid_arr[32];
8327         CHECK(txid->arr_len == 32);
8328         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8329         unsigned char (*txid_ref)[32] = &txid_arr;
8330         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8331 }
8332
8333 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
8334         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8335         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8336         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8337         unsigned char header_arr[80];
8338         CHECK(header->arr_len == 80);
8339         memcpy(header_arr, header->elems, 80); FREE(header);
8340         unsigned char (*header_ref)[80] = &header_arr;
8341         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8342 }
8343
8344 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
8345         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8346         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8347         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8348         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8349         ptrArray ret_arr = NULL;
8350         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
8351         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
8352         for (size_t m = 0; m < ret_var.datalen; m++) {
8353                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
8354                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
8355                 ret_arr_ptr[m] = ret_conv_12_arr;
8356         }
8357         
8358         FREE(ret_var.data);
8359         return ret_arr;
8360 }
8361
8362 typedef struct LDKPersist_JCalls {
8363         atomic_size_t refcnt;
8364         uint32_t instance_ptr;
8365 } LDKPersist_JCalls;
8366 static void LDKPersist_JCalls_free(void* this_arg) {
8367         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8368         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8369                 FREE(j_calls);
8370         }
8371 }
8372 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8373         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8374         LDKOutPoint channel_id_var = channel_id;
8375         uint32_t channel_id_ref = 0;
8376         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8377         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8378         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8379         channel_id_ref = (uintptr_t)channel_id_var.inner;
8380         if (channel_id_var.is_owned) {
8381                 channel_id_ref |= 1;
8382         }
8383         LDKChannelMonitor data_var = *data;
8384         uint32_t data_ref = 0;
8385         data_var = ChannelMonitor_clone(&data_var);
8386         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8387         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8388         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8389         data_ref = (uintptr_t)data_var.inner;
8390         if (data_var.is_owned) {
8391                 data_ref |= 1;
8392         }
8393         LDKMonitorUpdateId update_id_var = update_id;
8394         uint32_t update_id_ref = 0;
8395         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8396         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8397         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8398         update_id_ref = (uintptr_t)update_id_var.inner;
8399         if (update_id_var.is_owned) {
8400                 update_id_ref |= 1;
8401         }
8402         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);
8403         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8404         CHECK_ACCESS(ret_ptr);
8405         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8406         FREE((void*)ret);
8407         return ret_conv;
8408 }
8409 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8410         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8411         LDKOutPoint channel_id_var = channel_id;
8412         uint32_t channel_id_ref = 0;
8413         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8414         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8415         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8416         channel_id_ref = (uintptr_t)channel_id_var.inner;
8417         if (channel_id_var.is_owned) {
8418                 channel_id_ref |= 1;
8419         }
8420         LDKChannelMonitorUpdate update_var = *update;
8421         uint32_t update_ref = 0;
8422         if ((uintptr_t)update_var.inner > 4096) {
8423                 update_var = ChannelMonitorUpdate_clone(&update_var);
8424                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8425                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8426         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
8427                 update_ref = (uintptr_t)update_var.inner;
8428                 if (update_var.is_owned) {
8429                         update_ref |= 1;
8430                 }
8431         }
8432         LDKChannelMonitor data_var = *data;
8433         uint32_t data_ref = 0;
8434         data_var = ChannelMonitor_clone(&data_var);
8435         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8436         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8437         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8438         data_ref = (uintptr_t)data_var.inner;
8439         if (data_var.is_owned) {
8440                 data_ref |= 1;
8441         }
8442         LDKMonitorUpdateId update_id_var = update_id;
8443         uint32_t update_id_ref = 0;
8444         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8445         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8446         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8447         update_id_ref = (uintptr_t)update_id_var.inner;
8448         if (update_id_var.is_owned) {
8449                 update_id_ref |= 1;
8450         }
8451         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);
8452         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8453         CHECK_ACCESS(ret_ptr);
8454         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8455         FREE((void*)ret);
8456         return ret_conv;
8457 }
8458 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8459         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8460         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8461 }
8462 static inline LDKPersist LDKPersist_init (JSValue o) {
8463         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8464         atomic_init(&calls->refcnt, 1);
8465         calls->instance_ptr = o;
8466
8467         LDKPersist ret = {
8468                 .this_arg = (void*) calls,
8469                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8470                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8471                 .free = LDKPersist_JCalls_free,
8472         };
8473         return ret;
8474 }
8475 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
8476         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8477         *res_ptr = LDKPersist_init(o);
8478         return (long)res_ptr;
8479 }
8480 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) {
8481         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8482         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8483         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8484         LDKOutPoint channel_id_conv;
8485         channel_id_conv.inner = (void*)(channel_id & (~1));
8486         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8487         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8488         channel_id_conv = OutPoint_clone(&channel_id_conv);
8489         LDKChannelMonitor data_conv;
8490         data_conv.inner = (void*)(data & (~1));
8491         data_conv.is_owned = false;
8492         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8493         LDKMonitorUpdateId update_id_conv;
8494         update_id_conv.inner = (void*)(update_id & (~1));
8495         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8496         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8497         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8498         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8499         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
8500         return (uint32_t)ret_conv;
8501 }
8502
8503 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) {
8504         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8505         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8506         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8507         LDKOutPoint channel_id_conv;
8508         channel_id_conv.inner = (void*)(channel_id & (~1));
8509         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8510         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8511         channel_id_conv = OutPoint_clone(&channel_id_conv);
8512         LDKChannelMonitorUpdate update_conv;
8513         update_conv.inner = (void*)(update & (~1));
8514         update_conv.is_owned = false;
8515         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
8516         LDKChannelMonitor data_conv;
8517         data_conv.inner = (void*)(data & (~1));
8518         data_conv.is_owned = false;
8519         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8520         LDKMonitorUpdateId update_id_conv;
8521         update_id_conv.inner = (void*)(update_id & (~1));
8522         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8523         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8524         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8525         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8526         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
8527         return (uint32_t)ret_conv;
8528 }
8529
8530 typedef struct LDKChannelMessageHandler_JCalls {
8531         atomic_size_t refcnt;
8532         uint32_t instance_ptr;
8533         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8534 } LDKChannelMessageHandler_JCalls;
8535 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8536         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8537         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8538                 FREE(j_calls);
8539         }
8540 }
8541 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8542         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8543         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8544         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8545         LDKInitFeatures their_features_var = their_features;
8546         uint32_t their_features_ref = 0;
8547         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8548         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8549         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8550         their_features_ref = (uintptr_t)their_features_var.inner;
8551         if (their_features_var.is_owned) {
8552                 their_features_ref |= 1;
8553         }
8554         LDKOpenChannel msg_var = *msg;
8555         uint32_t msg_ref = 0;
8556         msg_var = OpenChannel_clone(&msg_var);
8557         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8558         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8559         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8560         msg_ref = (uintptr_t)msg_var.inner;
8561         if (msg_var.is_owned) {
8562                 msg_ref |= 1;
8563         }
8564         js_invoke_function_3(j_calls->instance_ptr, 45, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8565 }
8566 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8567         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8568         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8569         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8570         LDKInitFeatures their_features_var = their_features;
8571         uint32_t their_features_ref = 0;
8572         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8573         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8574         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8575         their_features_ref = (uintptr_t)their_features_var.inner;
8576         if (their_features_var.is_owned) {
8577                 their_features_ref |= 1;
8578         }
8579         LDKAcceptChannel msg_var = *msg;
8580         uint32_t msg_ref = 0;
8581         msg_var = AcceptChannel_clone(&msg_var);
8582         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8583         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8584         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8585         msg_ref = (uintptr_t)msg_var.inner;
8586         if (msg_var.is_owned) {
8587                 msg_ref |= 1;
8588         }
8589         js_invoke_function_3(j_calls->instance_ptr, 46, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8590 }
8591 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * 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         LDKFundingCreated msg_var = *msg;
8596         uint32_t msg_ref = 0;
8597         msg_var = FundingCreated_clone(&msg_var);
8598         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8599         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8600         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8601         msg_ref = (uintptr_t)msg_var.inner;
8602         if (msg_var.is_owned) {
8603                 msg_ref |= 1;
8604         }
8605         js_invoke_function_2(j_calls->instance_ptr, 47, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8606 }
8607 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8608         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8609         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8610         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8611         LDKFundingSigned msg_var = *msg;
8612         uint32_t msg_ref = 0;
8613         msg_var = FundingSigned_clone(&msg_var);
8614         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8615         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8616         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8617         msg_ref = (uintptr_t)msg_var.inner;
8618         if (msg_var.is_owned) {
8619                 msg_ref |= 1;
8620         }
8621         js_invoke_function_2(j_calls->instance_ptr, 48, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8622 }
8623 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8624         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8625         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8626         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8627         LDKFundingLocked msg_var = *msg;
8628         uint32_t msg_ref = 0;
8629         msg_var = FundingLocked_clone(&msg_var);
8630         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8631         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8632         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8633         msg_ref = (uintptr_t)msg_var.inner;
8634         if (msg_var.is_owned) {
8635                 msg_ref |= 1;
8636         }
8637         js_invoke_function_2(j_calls->instance_ptr, 49, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8638 }
8639 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8640         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8641         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8642         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8643         LDKInitFeatures their_features_var = *their_features;
8644         uint32_t their_features_ref = 0;
8645         their_features_var = InitFeatures_clone(&their_features_var);
8646         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8647         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8648         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8649         their_features_ref = (uintptr_t)their_features_var.inner;
8650         if (their_features_var.is_owned) {
8651                 their_features_ref |= 1;
8652         }
8653         LDKShutdown msg_var = *msg;
8654         uint32_t msg_ref = 0;
8655         msg_var = Shutdown_clone(&msg_var);
8656         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8657         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8658         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8659         msg_ref = (uintptr_t)msg_var.inner;
8660         if (msg_var.is_owned) {
8661                 msg_ref |= 1;
8662         }
8663         js_invoke_function_3(j_calls->instance_ptr, 50, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8664 }
8665 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8666         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8667         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8668         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8669         LDKClosingSigned msg_var = *msg;
8670         uint32_t msg_ref = 0;
8671         msg_var = ClosingSigned_clone(&msg_var);
8672         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8673         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8674         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8675         msg_ref = (uintptr_t)msg_var.inner;
8676         if (msg_var.is_owned) {
8677                 msg_ref |= 1;
8678         }
8679         js_invoke_function_2(j_calls->instance_ptr, 51, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8680 }
8681 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8682         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8683         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8684         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8685         LDKUpdateAddHTLC msg_var = *msg;
8686         uint32_t msg_ref = 0;
8687         msg_var = UpdateAddHTLC_clone(&msg_var);
8688         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8689         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8690         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8691         msg_ref = (uintptr_t)msg_var.inner;
8692         if (msg_var.is_owned) {
8693                 msg_ref |= 1;
8694         }
8695         js_invoke_function_2(j_calls->instance_ptr, 52, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8696 }
8697 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8698         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8699         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8700         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8701         LDKUpdateFulfillHTLC msg_var = *msg;
8702         uint32_t msg_ref = 0;
8703         msg_var = UpdateFulfillHTLC_clone(&msg_var);
8704         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8705         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8706         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8707         msg_ref = (uintptr_t)msg_var.inner;
8708         if (msg_var.is_owned) {
8709                 msg_ref |= 1;
8710         }
8711         js_invoke_function_2(j_calls->instance_ptr, 53, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8712 }
8713 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
8714         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8715         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8716         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8717         LDKUpdateFailHTLC msg_var = *msg;
8718         uint32_t msg_ref = 0;
8719         msg_var = UpdateFailHTLC_clone(&msg_var);
8720         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8721         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8722         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8723         msg_ref = (uintptr_t)msg_var.inner;
8724         if (msg_var.is_owned) {
8725                 msg_ref |= 1;
8726         }
8727         js_invoke_function_2(j_calls->instance_ptr, 54, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8728 }
8729 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
8730         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8731         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8732         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8733         LDKUpdateFailMalformedHTLC msg_var = *msg;
8734         uint32_t msg_ref = 0;
8735         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
8736         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8737         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8738         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8739         msg_ref = (uintptr_t)msg_var.inner;
8740         if (msg_var.is_owned) {
8741                 msg_ref |= 1;
8742         }
8743         js_invoke_function_2(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8744 }
8745 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
8746         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8747         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8748         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8749         LDKCommitmentSigned msg_var = *msg;
8750         uint32_t msg_ref = 0;
8751         msg_var = CommitmentSigned_clone(&msg_var);
8752         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8753         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8754         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8755         msg_ref = (uintptr_t)msg_var.inner;
8756         if (msg_var.is_owned) {
8757                 msg_ref |= 1;
8758         }
8759         js_invoke_function_2(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8760 }
8761 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
8762         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8763         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8764         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8765         LDKRevokeAndACK msg_var = *msg;
8766         uint32_t msg_ref = 0;
8767         msg_var = RevokeAndACK_clone(&msg_var);
8768         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8769         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8770         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8771         msg_ref = (uintptr_t)msg_var.inner;
8772         if (msg_var.is_owned) {
8773                 msg_ref |= 1;
8774         }
8775         js_invoke_function_2(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8776 }
8777 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
8778         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8779         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8780         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8781         LDKUpdateFee msg_var = *msg;
8782         uint32_t msg_ref = 0;
8783         msg_var = UpdateFee_clone(&msg_var);
8784         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8785         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8786         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8787         msg_ref = (uintptr_t)msg_var.inner;
8788         if (msg_var.is_owned) {
8789                 msg_ref |= 1;
8790         }
8791         js_invoke_function_2(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8792 }
8793 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
8794         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8795         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8796         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8797         LDKAnnouncementSignatures msg_var = *msg;
8798         uint32_t msg_ref = 0;
8799         msg_var = AnnouncementSignatures_clone(&msg_var);
8800         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8801         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8802         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8803         msg_ref = (uintptr_t)msg_var.inner;
8804         if (msg_var.is_owned) {
8805                 msg_ref |= 1;
8806         }
8807         js_invoke_function_2(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8808 }
8809 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
8810         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8811         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8812         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8813         js_invoke_function_2(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible);
8814 }
8815 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
8816         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8817         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8818         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8819         LDKInit msg_var = *msg;
8820         uint32_t msg_ref = 0;
8821         msg_var = Init_clone(&msg_var);
8822         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8823         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8824         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8825         msg_ref = (uintptr_t)msg_var.inner;
8826         if (msg_var.is_owned) {
8827                 msg_ref |= 1;
8828         }
8829         js_invoke_function_2(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8830 }
8831 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
8832         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8833         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8834         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8835         LDKChannelReestablish msg_var = *msg;
8836         uint32_t msg_ref = 0;
8837         msg_var = ChannelReestablish_clone(&msg_var);
8838         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8839         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8840         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8841         msg_ref = (uintptr_t)msg_var.inner;
8842         if (msg_var.is_owned) {
8843                 msg_ref |= 1;
8844         }
8845         js_invoke_function_2(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8846 }
8847 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
8848         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8849         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8850         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8851         LDKChannelUpdate msg_var = *msg;
8852         uint32_t msg_ref = 0;
8853         msg_var = ChannelUpdate_clone(&msg_var);
8854         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8855         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8856         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8857         msg_ref = (uintptr_t)msg_var.inner;
8858         if (msg_var.is_owned) {
8859                 msg_ref |= 1;
8860         }
8861         js_invoke_function_2(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8862 }
8863 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
8864         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8865         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8866         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8867         LDKErrorMessage msg_var = *msg;
8868         uint32_t msg_ref = 0;
8869         msg_var = ErrorMessage_clone(&msg_var);
8870         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8871         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8872         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8873         msg_ref = (uintptr_t)msg_var.inner;
8874         if (msg_var.is_owned) {
8875                 msg_ref |= 1;
8876         }
8877         js_invoke_function_2(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8878 }
8879 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
8880         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
8881         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8882         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8883 }
8884 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
8885         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
8886         atomic_init(&calls->refcnt, 1);
8887         calls->instance_ptr = o;
8888
8889         LDKChannelMessageHandler ret = {
8890                 .this_arg = (void*) calls,
8891                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
8892                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
8893                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
8894                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
8895                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
8896                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
8897                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
8898                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
8899                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
8900                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
8901                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
8902                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
8903                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
8904                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
8905                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
8906                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
8907                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
8908                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
8909                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
8910                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
8911                 .free = LDKChannelMessageHandler_JCalls_free,
8912                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
8913         };
8914         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8915         return ret;
8916 }
8917 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
8918         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8919         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
8920         return (long)res_ptr;
8921 }
8922 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) {
8923         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8924         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8925         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8926         LDKPublicKey their_node_id_ref;
8927         CHECK(their_node_id->arr_len == 33);
8928         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8929         LDKInitFeatures their_features_conv;
8930         their_features_conv.inner = (void*)(their_features & (~1));
8931         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8932         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8933         their_features_conv = InitFeatures_clone(&their_features_conv);
8934         LDKOpenChannel msg_conv;
8935         msg_conv.inner = (void*)(msg & (~1));
8936         msg_conv.is_owned = false;
8937         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8938         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8939 }
8940
8941 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) {
8942         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8943         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8944         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8945         LDKPublicKey their_node_id_ref;
8946         CHECK(their_node_id->arr_len == 33);
8947         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8948         LDKInitFeatures their_features_conv;
8949         their_features_conv.inner = (void*)(their_features & (~1));
8950         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8951         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8952         their_features_conv = InitFeatures_clone(&their_features_conv);
8953         LDKAcceptChannel msg_conv;
8954         msg_conv.inner = (void*)(msg & (~1));
8955         msg_conv.is_owned = false;
8956         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8957         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8958 }
8959
8960 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) {
8961         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8962         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8963         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8964         LDKPublicKey their_node_id_ref;
8965         CHECK(their_node_id->arr_len == 33);
8966         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8967         LDKFundingCreated msg_conv;
8968         msg_conv.inner = (void*)(msg & (~1));
8969         msg_conv.is_owned = false;
8970         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8971         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8972 }
8973
8974 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) {
8975         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8976         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8977         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8978         LDKPublicKey their_node_id_ref;
8979         CHECK(their_node_id->arr_len == 33);
8980         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8981         LDKFundingSigned msg_conv;
8982         msg_conv.inner = (void*)(msg & (~1));
8983         msg_conv.is_owned = false;
8984         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8985         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8986 }
8987
8988 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) {
8989         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8990         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8991         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8992         LDKPublicKey their_node_id_ref;
8993         CHECK(their_node_id->arr_len == 33);
8994         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8995         LDKFundingLocked msg_conv;
8996         msg_conv.inner = (void*)(msg & (~1));
8997         msg_conv.is_owned = false;
8998         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8999         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9000 }
9001
9002 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) {
9003         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9004         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9005         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9006         LDKPublicKey their_node_id_ref;
9007         CHECK(their_node_id->arr_len == 33);
9008         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9009         LDKInitFeatures their_features_conv;
9010         their_features_conv.inner = (void*)(their_features & (~1));
9011         their_features_conv.is_owned = false;
9012         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9013         LDKShutdown msg_conv;
9014         msg_conv.inner = (void*)(msg & (~1));
9015         msg_conv.is_owned = false;
9016         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9017         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9018 }
9019
9020 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) {
9021         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9022         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9023         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9024         LDKPublicKey their_node_id_ref;
9025         CHECK(their_node_id->arr_len == 33);
9026         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9027         LDKClosingSigned msg_conv;
9028         msg_conv.inner = (void*)(msg & (~1));
9029         msg_conv.is_owned = false;
9030         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9031         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9032 }
9033
9034 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) {
9035         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9036         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9037         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9038         LDKPublicKey their_node_id_ref;
9039         CHECK(their_node_id->arr_len == 33);
9040         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9041         LDKUpdateAddHTLC msg_conv;
9042         msg_conv.inner = (void*)(msg & (~1));
9043         msg_conv.is_owned = false;
9044         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9045         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9046 }
9047
9048 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) {
9049         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9050         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9051         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9052         LDKPublicKey their_node_id_ref;
9053         CHECK(their_node_id->arr_len == 33);
9054         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9055         LDKUpdateFulfillHTLC msg_conv;
9056         msg_conv.inner = (void*)(msg & (~1));
9057         msg_conv.is_owned = false;
9058         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9059         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9060 }
9061
9062 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) {
9063         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9064         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9065         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9066         LDKPublicKey their_node_id_ref;
9067         CHECK(their_node_id->arr_len == 33);
9068         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9069         LDKUpdateFailHTLC msg_conv;
9070         msg_conv.inner = (void*)(msg & (~1));
9071         msg_conv.is_owned = false;
9072         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9073         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9074 }
9075
9076 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) {
9077         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9078         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9079         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9080         LDKPublicKey their_node_id_ref;
9081         CHECK(their_node_id->arr_len == 33);
9082         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9083         LDKUpdateFailMalformedHTLC msg_conv;
9084         msg_conv.inner = (void*)(msg & (~1));
9085         msg_conv.is_owned = false;
9086         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9087         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9088 }
9089
9090 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) {
9091         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9092         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9093         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9094         LDKPublicKey their_node_id_ref;
9095         CHECK(their_node_id->arr_len == 33);
9096         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9097         LDKCommitmentSigned msg_conv;
9098         msg_conv.inner = (void*)(msg & (~1));
9099         msg_conv.is_owned = false;
9100         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9101         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9102 }
9103
9104 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) {
9105         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9106         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9107         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9108         LDKPublicKey their_node_id_ref;
9109         CHECK(their_node_id->arr_len == 33);
9110         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9111         LDKRevokeAndACK msg_conv;
9112         msg_conv.inner = (void*)(msg & (~1));
9113         msg_conv.is_owned = false;
9114         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9115         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9116 }
9117
9118 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) {
9119         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9120         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9121         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9122         LDKPublicKey their_node_id_ref;
9123         CHECK(their_node_id->arr_len == 33);
9124         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9125         LDKUpdateFee msg_conv;
9126         msg_conv.inner = (void*)(msg & (~1));
9127         msg_conv.is_owned = false;
9128         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9129         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9130 }
9131
9132 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) {
9133         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9134         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9135         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9136         LDKPublicKey their_node_id_ref;
9137         CHECK(their_node_id->arr_len == 33);
9138         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9139         LDKAnnouncementSignatures msg_conv;
9140         msg_conv.inner = (void*)(msg & (~1));
9141         msg_conv.is_owned = false;
9142         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9143         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9144 }
9145
9146 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) {
9147         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9148         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9149         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9150         LDKPublicKey their_node_id_ref;
9151         CHECK(their_node_id->arr_len == 33);
9152         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9153         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9154 }
9155
9156 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9157         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9158         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9159         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9160         LDKPublicKey their_node_id_ref;
9161         CHECK(their_node_id->arr_len == 33);
9162         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9163         LDKInit msg_conv;
9164         msg_conv.inner = (void*)(msg & (~1));
9165         msg_conv.is_owned = false;
9166         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9167         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9168 }
9169
9170 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) {
9171         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9172         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9173         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9174         LDKPublicKey their_node_id_ref;
9175         CHECK(their_node_id->arr_len == 33);
9176         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9177         LDKChannelReestablish msg_conv;
9178         msg_conv.inner = (void*)(msg & (~1));
9179         msg_conv.is_owned = false;
9180         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9181         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9182 }
9183
9184 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) {
9185         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9186         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9187         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9188         LDKPublicKey their_node_id_ref;
9189         CHECK(their_node_id->arr_len == 33);
9190         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9191         LDKChannelUpdate msg_conv;
9192         msg_conv.inner = (void*)(msg & (~1));
9193         msg_conv.is_owned = false;
9194         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9195         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9196 }
9197
9198 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9199         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9200         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9201         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9202         LDKPublicKey their_node_id_ref;
9203         CHECK(their_node_id->arr_len == 33);
9204         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9205         LDKErrorMessage msg_conv;
9206         msg_conv.inner = (void*)(msg & (~1));
9207         msg_conv.is_owned = false;
9208         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9209         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9210 }
9211
9212 typedef struct LDKRoutingMessageHandler_JCalls {
9213         atomic_size_t refcnt;
9214         uint32_t instance_ptr;
9215         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9216 } LDKRoutingMessageHandler_JCalls;
9217 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9218         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9219         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9220                 FREE(j_calls);
9221         }
9222 }
9223 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9224         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9225         LDKNodeAnnouncement msg_var = *msg;
9226         uint32_t msg_ref = 0;
9227         msg_var = NodeAnnouncement_clone(&msg_var);
9228         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9229         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9230         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9231         msg_ref = (uintptr_t)msg_var.inner;
9232         if (msg_var.is_owned) {
9233                 msg_ref |= 1;
9234         }
9235         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 65, (uint32_t)msg_ref);
9236         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9237         CHECK_ACCESS(ret_ptr);
9238         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9239         FREE((void*)ret);
9240         return ret_conv;
9241 }
9242 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9243         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9244         LDKChannelAnnouncement msg_var = *msg;
9245         uint32_t msg_ref = 0;
9246         msg_var = ChannelAnnouncement_clone(&msg_var);
9247         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9248         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9249         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9250         msg_ref = (uintptr_t)msg_var.inner;
9251         if (msg_var.is_owned) {
9252                 msg_ref |= 1;
9253         }
9254         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 66, (uint32_t)msg_ref);
9255         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9256         CHECK_ACCESS(ret_ptr);
9257         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9258         FREE((void*)ret);
9259         return ret_conv;
9260 }
9261 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9262         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9263         LDKChannelUpdate msg_var = *msg;
9264         uint32_t msg_ref = 0;
9265         msg_var = ChannelUpdate_clone(&msg_var);
9266         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9267         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9268         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9269         msg_ref = (uintptr_t)msg_var.inner;
9270         if (msg_var.is_owned) {
9271                 msg_ref |= 1;
9272         }
9273         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 67, (uint32_t)msg_ref);
9274         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9275         CHECK_ACCESS(ret_ptr);
9276         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9277         FREE((void*)ret);
9278         return ret_conv;
9279 }
9280 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9281         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9282         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 68, (uint32_t)starting_point, (uint32_t)batch_amount);
9283         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9284         ret_constr.datalen = ret->arr_len;
9285         if (ret_constr.datalen > 0)
9286                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9287         else
9288                 ret_constr.data = NULL;
9289         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9290         for (size_t h = 0; h < ret_constr.datalen; h++) {
9291                 uint32_t ret_conv_59 = ret_vals[h];
9292                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
9293                 CHECK_ACCESS(ret_conv_59_ptr);
9294                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9295                 FREE((void*)ret_conv_59);
9296                 ret_constr.data[h] = ret_conv_59_conv;
9297         }
9298         return ret_constr;
9299 }
9300 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9301         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9302         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
9303         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
9304         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 69, (uint32_t)starting_point_arr, (uint32_t)batch_amount);
9305         LDKCVec_NodeAnnouncementZ ret_constr;
9306         ret_constr.datalen = ret->arr_len;
9307         if (ret_constr.datalen > 0)
9308                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9309         else
9310                 ret_constr.data = NULL;
9311         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9312         for (size_t s = 0; s < ret_constr.datalen; s++) {
9313                 uint32_t ret_conv_18 = ret_vals[s];
9314                 LDKNodeAnnouncement ret_conv_18_conv;
9315                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9316                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9317                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
9318                 ret_constr.data[s] = ret_conv_18_conv;
9319         }
9320         return ret_constr;
9321 }
9322 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9323         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9324         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9325         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9326         LDKInit init_var = *init;
9327         uint32_t init_ref = 0;
9328         init_var = Init_clone(&init_var);
9329         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9330         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9331         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9332         init_ref = (uintptr_t)init_var.inner;
9333         if (init_var.is_owned) {
9334                 init_ref |= 1;
9335         }
9336         js_invoke_function_2(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
9337 }
9338 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9339         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9340         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9341         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9342         LDKReplyChannelRange msg_var = msg;
9343         uint32_t msg_ref = 0;
9344         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9345         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9346         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9347         msg_ref = (uintptr_t)msg_var.inner;
9348         if (msg_var.is_owned) {
9349                 msg_ref |= 1;
9350         }
9351         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9352         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9353         CHECK_ACCESS(ret_ptr);
9354         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9355         FREE((void*)ret);
9356         return ret_conv;
9357 }
9358 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9359         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9360         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9361         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9362         LDKReplyShortChannelIdsEnd msg_var = msg;
9363         uint32_t msg_ref = 0;
9364         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9365         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9366         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9367         msg_ref = (uintptr_t)msg_var.inner;
9368         if (msg_var.is_owned) {
9369                 msg_ref |= 1;
9370         }
9371         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9372         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9373         CHECK_ACCESS(ret_ptr);
9374         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9375         FREE((void*)ret);
9376         return ret_conv;
9377 }
9378 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9379         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9380         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9381         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9382         LDKQueryChannelRange msg_var = msg;
9383         uint32_t msg_ref = 0;
9384         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9385         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9386         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9387         msg_ref = (uintptr_t)msg_var.inner;
9388         if (msg_var.is_owned) {
9389                 msg_ref |= 1;
9390         }
9391         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9392         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9393         CHECK_ACCESS(ret_ptr);
9394         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9395         FREE((void*)ret);
9396         return ret_conv;
9397 }
9398 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9399         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9400         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9401         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9402         LDKQueryShortChannelIds msg_var = msg;
9403         uint32_t msg_ref = 0;
9404         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9405         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9406         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9407         msg_ref = (uintptr_t)msg_var.inner;
9408         if (msg_var.is_owned) {
9409                 msg_ref |= 1;
9410         }
9411         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9412         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9413         CHECK_ACCESS(ret_ptr);
9414         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9415         FREE((void*)ret);
9416         return ret_conv;
9417 }
9418 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9419         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9420         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9421         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9422 }
9423 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9424         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9425         atomic_init(&calls->refcnt, 1);
9426         calls->instance_ptr = o;
9427
9428         LDKRoutingMessageHandler ret = {
9429                 .this_arg = (void*) calls,
9430                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9431                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9432                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9433                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9434                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9435                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
9436                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9437                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9438                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9439                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9440                 .free = LDKRoutingMessageHandler_JCalls_free,
9441                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9442         };
9443         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9444         return ret;
9445 }
9446 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9447         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9448         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
9449         return (long)res_ptr;
9450 }
9451 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
9452         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9453         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9454         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9455         LDKNodeAnnouncement msg_conv;
9456         msg_conv.inner = (void*)(msg & (~1));
9457         msg_conv.is_owned = false;
9458         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9459         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9460         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9461         return (uint32_t)ret_conv;
9462 }
9463
9464 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
9465         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9466         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9467         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9468         LDKChannelAnnouncement msg_conv;
9469         msg_conv.inner = (void*)(msg & (~1));
9470         msg_conv.is_owned = false;
9471         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9472         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9473         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9474         return (uint32_t)ret_conv;
9475 }
9476
9477 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
9478         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9479         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9480         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9481         LDKChannelUpdate msg_conv;
9482         msg_conv.inner = (void*)(msg & (~1));
9483         msg_conv.is_owned = false;
9484         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9485         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9486         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9487         return (uint32_t)ret_conv;
9488 }
9489
9490 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) {
9491         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9492         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9493         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9494         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
9495         uint32_tArray ret_arr = NULL;
9496         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9497         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9498         for (size_t h = 0; h < ret_var.datalen; h++) {
9499                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9500                 *ret_conv_59_conv = ret_var.data[h];
9501                 ret_arr_ptr[h] = ((uint32_t)ret_conv_59_conv);
9502         }
9503         
9504         FREE(ret_var.data);
9505         return ret_arr;
9506 }
9507
9508 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) {
9509         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9510         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9511         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9512         LDKPublicKey starting_point_ref;
9513         CHECK(starting_point->arr_len == 33);
9514         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
9515         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
9516         uint32_tArray ret_arr = NULL;
9517         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9518         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9519         for (size_t s = 0; s < ret_var.datalen; s++) {
9520                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
9521                 uint32_t ret_conv_18_ref = 0;
9522                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9523                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9524                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
9525                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
9526                 if (ret_conv_18_var.is_owned) {
9527                         ret_conv_18_ref |= 1;
9528                 }
9529                 ret_arr_ptr[s] = ret_conv_18_ref;
9530         }
9531         
9532         FREE(ret_var.data);
9533         return ret_arr;
9534 }
9535
9536 void  __attribute__((export_name("TS_RoutingMessageHandler_peer_connected"))) TS_RoutingMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
9537         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9538         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9539         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9540         LDKPublicKey their_node_id_ref;
9541         CHECK(their_node_id->arr_len == 33);
9542         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9543         LDKInit init_conv;
9544         init_conv.inner = (void*)(init & (~1));
9545         init_conv.is_owned = false;
9546         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
9547         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
9548 }
9549
9550 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) {
9551         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9552         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9553         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9554         LDKPublicKey their_node_id_ref;
9555         CHECK(their_node_id->arr_len == 33);
9556         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9557         LDKReplyChannelRange msg_conv;
9558         msg_conv.inner = (void*)(msg & (~1));
9559         msg_conv.is_owned = (msg & 1) || (msg == 0);
9560         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9561         msg_conv = ReplyChannelRange_clone(&msg_conv);
9562         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9563         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9564         return (uint32_t)ret_conv;
9565 }
9566
9567 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) {
9568         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9569         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9570         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9571         LDKPublicKey their_node_id_ref;
9572         CHECK(their_node_id->arr_len == 33);
9573         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9574         LDKReplyShortChannelIdsEnd msg_conv;
9575         msg_conv.inner = (void*)(msg & (~1));
9576         msg_conv.is_owned = (msg & 1) || (msg == 0);
9577         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9578         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
9579         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9580         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9581         return (uint32_t)ret_conv;
9582 }
9583
9584 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) {
9585         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9586         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9587         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9588         LDKPublicKey their_node_id_ref;
9589         CHECK(their_node_id->arr_len == 33);
9590         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9591         LDKQueryChannelRange msg_conv;
9592         msg_conv.inner = (void*)(msg & (~1));
9593         msg_conv.is_owned = (msg & 1) || (msg == 0);
9594         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9595         msg_conv = QueryChannelRange_clone(&msg_conv);
9596         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9597         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9598         return (uint32_t)ret_conv;
9599 }
9600
9601 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) {
9602         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9603         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9604         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9605         LDKPublicKey their_node_id_ref;
9606         CHECK(their_node_id->arr_len == 33);
9607         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9608         LDKQueryShortChannelIds msg_conv;
9609         msg_conv.inner = (void*)(msg & (~1));
9610         msg_conv.is_owned = (msg & 1) || (msg == 0);
9611         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9612         msg_conv = QueryShortChannelIds_clone(&msg_conv);
9613         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9614         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9615         return (uint32_t)ret_conv;
9616 }
9617
9618 typedef struct LDKCustomMessageReader_JCalls {
9619         atomic_size_t refcnt;
9620         uint32_t instance_ptr;
9621 } LDKCustomMessageReader_JCalls;
9622 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
9623         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9624         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9625                 FREE(j_calls);
9626         }
9627 }
9628 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
9629         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9630         LDKu8slice buffer_var = buffer;
9631         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
9632         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
9633         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 75, (uint32_t)message_type, (uint32_t)buffer_arr);
9634         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9635         CHECK_ACCESS(ret_ptr);
9636         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
9637         FREE((void*)ret);
9638         return ret_conv;
9639 }
9640 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
9641         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
9642         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9643 }
9644 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
9645         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
9646         atomic_init(&calls->refcnt, 1);
9647         calls->instance_ptr = o;
9648
9649         LDKCustomMessageReader ret = {
9650                 .this_arg = (void*) calls,
9651                 .read = read_LDKCustomMessageReader_jcall,
9652                 .free = LDKCustomMessageReader_JCalls_free,
9653         };
9654         return ret;
9655 }
9656 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
9657         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
9658         *res_ptr = LDKCustomMessageReader_init(o);
9659         return (long)res_ptr;
9660 }
9661 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
9662         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9663         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9664         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
9665         LDKu8slice buffer_ref;
9666         buffer_ref.datalen = buffer->arr_len;
9667         buffer_ref.data = buffer->elems /* XXX buffer leaks */;
9668         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9669         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
9670         return (uint32_t)ret_conv;
9671 }
9672
9673 typedef struct LDKCustomMessageHandler_JCalls {
9674         atomic_size_t refcnt;
9675         uint32_t instance_ptr;
9676         LDKCustomMessageReader_JCalls* CustomMessageReader;
9677 } LDKCustomMessageHandler_JCalls;
9678 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
9679         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9680         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9681                 FREE(j_calls);
9682         }
9683 }
9684 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
9685         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9686         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
9687         *msg_ret = msg;
9688         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
9689         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
9690         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 76, (uint32_t)(uint32_t)msg_ret, (uint32_t)sender_node_id_arr);
9691         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9692         CHECK_ACCESS(ret_ptr);
9693         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9694         FREE((void*)ret);
9695         return ret_conv;
9696 }
9697 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
9698         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9699         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 77);
9700         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
9701         ret_constr.datalen = ret->arr_len;
9702         if (ret_constr.datalen > 0)
9703                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
9704         else
9705                 ret_constr.data = NULL;
9706         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9707         for (size_t z = 0; z < ret_constr.datalen; z++) {
9708                 uint32_t ret_conv_25 = ret_vals[z];
9709                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
9710                 CHECK_ACCESS(ret_conv_25_ptr);
9711                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
9712                 FREE((void*)ret_conv_25);
9713                 ret_constr.data[z] = ret_conv_25_conv;
9714         }
9715         return ret_constr;
9716 }
9717 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
9718         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
9719         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9720         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
9721 }
9722 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
9723         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
9724         atomic_init(&calls->refcnt, 1);
9725         calls->instance_ptr = o;
9726
9727         LDKCustomMessageHandler ret = {
9728                 .this_arg = (void*) calls,
9729                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
9730                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
9731                 .free = LDKCustomMessageHandler_JCalls_free,
9732                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
9733         };
9734         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
9735         return ret;
9736 }
9737 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
9738         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
9739         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
9740         return (long)res_ptr;
9741 }
9742 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) {
9743         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9744         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9745         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9746         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
9747         CHECK_ACCESS(msg_ptr);
9748         LDKType msg_conv = *(LDKType*)(msg_ptr);
9749         if (msg_conv.free == LDKType_JCalls_free) {
9750                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9751                 LDKType_JCalls_cloned(&msg_conv);
9752         }
9753         LDKPublicKey sender_node_id_ref;
9754         CHECK(sender_node_id->arr_len == 33);
9755         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
9756         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9757         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
9758         return (uint32_t)ret_conv;
9759 }
9760
9761 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
9762         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9763         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9764         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9765         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
9766         uint32_tArray ret_arr = NULL;
9767         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9768         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9769         for (size_t z = 0; z < ret_var.datalen; z++) {
9770                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
9771                 *ret_conv_25_conv = ret_var.data[z];
9772                 ret_arr_ptr[z] = ((uint32_t)ret_conv_25_conv);
9773         }
9774         
9775         FREE(ret_var.data);
9776         return ret_arr;
9777 }
9778
9779 typedef struct LDKSocketDescriptor_JCalls {
9780         atomic_size_t refcnt;
9781         uint32_t instance_ptr;
9782 } LDKSocketDescriptor_JCalls;
9783 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
9784         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9785         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9786                 FREE(j_calls);
9787         }
9788 }
9789 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
9790         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9791         LDKu8slice data_var = data;
9792         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
9793         memcpy(data_arr->elems, data_var.data, data_var.datalen);
9794         return js_invoke_function_2(j_calls->instance_ptr, 78, (uint32_t)data_arr, (uint32_t)resume_read);
9795 }
9796 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
9797         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9798         js_invoke_function_0(j_calls->instance_ptr, 79);
9799 }
9800 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
9801         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9802         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9803         *other_arg_clone = SocketDescriptor_clone(other_arg);
9804         return js_invoke_function_1(j_calls->instance_ptr, 80, (uint32_t)(uint32_t)other_arg_clone);
9805 }
9806 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
9807         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9808         return js_invoke_function_0(j_calls->instance_ptr, 81);
9809 }
9810 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
9811         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
9812         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9813 }
9814 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
9815         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
9816         atomic_init(&calls->refcnt, 1);
9817         calls->instance_ptr = o;
9818
9819         LDKSocketDescriptor ret = {
9820                 .this_arg = (void*) calls,
9821                 .send_data = send_data_LDKSocketDescriptor_jcall,
9822                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
9823                 .eq = eq_LDKSocketDescriptor_jcall,
9824                 .hash = hash_LDKSocketDescriptor_jcall,
9825                 .cloned = LDKSocketDescriptor_JCalls_cloned,
9826                 .free = LDKSocketDescriptor_JCalls_free,
9827         };
9828         return ret;
9829 }
9830 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
9831         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9832         *res_ptr = LDKSocketDescriptor_init(o);
9833         return (long)res_ptr;
9834 }
9835 uint32_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
9836         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9837         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9838         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9839         LDKu8slice data_ref;
9840         data_ref.datalen = data->arr_len;
9841         data_ref.data = data->elems /* XXX data leaks */;
9842         uint32_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
9843         return ret_val;
9844 }
9845
9846 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
9847         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9848         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9849         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9850         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
9851 }
9852
9853 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
9854         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9855         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9856         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9857         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
9858         return ret_val;
9859 }
9860
9861 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint32_t ptr) {
9862         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9863         switch(obj->tag) {
9864                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
9865                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
9866                 case LDKEffectiveCapacity_Total: return 2;
9867                 case LDKEffectiveCapacity_Infinite: return 3;
9868                 case LDKEffectiveCapacity_Unknown: return 4;
9869                 default: abort();
9870         }
9871 }
9872 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint32_t ptr) {
9873         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9874         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
9875         return obj->exact_liquidity.liquidity_msat;
9876 }
9877 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint32_t ptr) {
9878         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9879         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
9880         return obj->maximum_htlc.amount_msat;
9881 }
9882 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint32_t ptr) {
9883         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9884         assert(obj->tag == LDKEffectiveCapacity_Total);
9885         return obj->total.capacity_msat;
9886 }
9887 typedef struct LDKScore_JCalls {
9888         atomic_size_t refcnt;
9889         uint32_t instance_ptr;
9890 } LDKScore_JCalls;
9891 static void LDKScore_JCalls_free(void* this_arg) {
9892         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9893         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9894                 FREE(j_calls);
9895         }
9896 }
9897 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) {
9898         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9899         LDKNodeId source_var = *source;
9900         uint32_t source_ref = 0;
9901         source_var = NodeId_clone(&source_var);
9902         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9903         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9904         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
9905         source_ref = (uintptr_t)source_var.inner;
9906         if (source_var.is_owned) {
9907                 source_ref |= 1;
9908         }
9909         LDKNodeId target_var = *target;
9910         uint32_t target_ref = 0;
9911         target_var = NodeId_clone(&target_var);
9912         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9913         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9914         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
9915         target_ref = (uintptr_t)target_var.inner;
9916         if (target_var.is_owned) {
9917                 target_ref |= 1;
9918         }
9919         return js_invoke_function_5(j_calls->instance_ptr, 82, (uint32_t)short_channel_id, (uint32_t)send_amt_msat, (uint32_t)capacity_msat, (uint32_t)source_ref, (uint32_t)target_ref);
9920 }
9921 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
9922         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9923         LDKCVec_RouteHopZ path_var = path;
9924         uint32_tArray path_arr = NULL;
9925         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
9926         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
9927         for (size_t k = 0; k < path_var.datalen; k++) {
9928                 LDKRouteHop path_conv_10_var = path_var.data[k];
9929                 uint32_t path_conv_10_ref = 0;
9930                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9931                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9932                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9933                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
9934                 if (path_conv_10_var.is_owned) {
9935                         path_conv_10_ref |= 1;
9936                 }
9937                 path_arr_ptr[k] = path_conv_10_ref;
9938         }
9939         
9940         FREE(path_var.data);
9941         js_invoke_function_2(j_calls->instance_ptr, 83, (uint32_t)path_arr, (uint32_t)short_channel_id);
9942 }
9943 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
9944         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9945         LDKCVec_RouteHopZ path_var = path;
9946         uint32_tArray path_arr = NULL;
9947         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
9948         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
9949         for (size_t k = 0; k < path_var.datalen; k++) {
9950                 LDKRouteHop path_conv_10_var = path_var.data[k];
9951                 uint32_t path_conv_10_ref = 0;
9952                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9953                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9954                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9955                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
9956                 if (path_conv_10_var.is_owned) {
9957                         path_conv_10_ref |= 1;
9958                 }
9959                 path_arr_ptr[k] = path_conv_10_ref;
9960         }
9961         
9962         FREE(path_var.data);
9963         js_invoke_function_1(j_calls->instance_ptr, 84, (uint32_t)path_arr);
9964 }
9965 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
9966         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9967         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 85);
9968         LDKCVec_u8Z ret_ref;
9969         ret_ref.datalen = ret->arr_len;
9970         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
9971         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
9972         return ret_ref;
9973 }
9974 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
9975         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
9976         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9977 }
9978 static inline LDKScore LDKScore_init (JSValue o) {
9979         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
9980         atomic_init(&calls->refcnt, 1);
9981         calls->instance_ptr = o;
9982
9983         LDKScore ret = {
9984                 .this_arg = (void*) calls,
9985                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
9986                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
9987                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
9988                 .write = write_LDKScore_jcall,
9989                 .free = LDKScore_JCalls_free,
9990         };
9991         return ret;
9992 }
9993 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
9994         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
9995         *res_ptr = LDKScore_init(o);
9996         return (long)res_ptr;
9997 }
9998 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) {
9999         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10000         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10001         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10002         LDKNodeId source_conv;
10003         source_conv.inner = (void*)(source & (~1));
10004         source_conv.is_owned = false;
10005         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
10006         LDKNodeId target_conv;
10007         target_conv.inner = (void*)(target & (~1));
10008         target_conv.is_owned = false;
10009         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
10010         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, send_amt_msat, capacity_msat, &source_conv, &target_conv);
10011         return ret_val;
10012 }
10013
10014 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) {
10015         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10016         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10017         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10018         LDKCVec_RouteHopZ path_constr;
10019         path_constr.datalen = path->arr_len;
10020         if (path_constr.datalen > 0)
10021                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10022         else
10023                 path_constr.data = NULL;
10024         uint32_t* path_vals = path->elems /* XXX path leaks */;
10025         for (size_t k = 0; k < path_constr.datalen; k++) {
10026                 uint32_t path_conv_10 = path_vals[k];
10027                 LDKRouteHop path_conv_10_conv;
10028                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10029                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10030                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10031                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10032                 path_constr.data[k] = path_conv_10_conv;
10033         }
10034         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10035 }
10036
10037 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
10038         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10039         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10040         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10041         LDKCVec_RouteHopZ path_constr;
10042         path_constr.datalen = path->arr_len;
10043         if (path_constr.datalen > 0)
10044                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10045         else
10046                 path_constr.data = NULL;
10047         uint32_t* path_vals = path->elems /* XXX path leaks */;
10048         for (size_t k = 0; k < path_constr.datalen; k++) {
10049                 uint32_t path_conv_10 = path_vals[k];
10050                 LDKRouteHop path_conv_10_conv;
10051                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10052                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10053                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10054                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10055                 path_constr.data[k] = path_conv_10_conv;
10056         }
10057         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
10058 }
10059
10060 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
10061         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10062         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10063         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10064         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
10065         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
10066         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
10067         CVec_u8Z_free(ret_var);
10068         return ret_arr;
10069 }
10070
10071 typedef struct LDKLockableScore_JCalls {
10072         atomic_size_t refcnt;
10073         uint32_t instance_ptr;
10074 } LDKLockableScore_JCalls;
10075 static void LDKLockableScore_JCalls_free(void* this_arg) {
10076         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10077         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10078                 FREE(j_calls);
10079         }
10080 }
10081 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
10082         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10083         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 86);
10084         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10085         CHECK_ACCESS(ret_ptr);
10086         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
10087         if (ret_conv.free == LDKScore_JCalls_free) {
10088                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10089                 LDKScore_JCalls_cloned(&ret_conv);
10090         }// WARNING: we may need a move here but no clone is available for LDKScore
10091         
10092         return ret_conv;
10093 }
10094 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
10095         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
10096         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10097 }
10098 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
10099         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
10100         atomic_init(&calls->refcnt, 1);
10101         calls->instance_ptr = o;
10102
10103         LDKLockableScore ret = {
10104                 .this_arg = (void*) calls,
10105                 .lock = lock_LDKLockableScore_jcall,
10106                 .free = LDKLockableScore_JCalls_free,
10107         };
10108         return ret;
10109 }
10110 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
10111         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
10112         *res_ptr = LDKLockableScore_init(o);
10113         return (long)res_ptr;
10114 }
10115 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
10116         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10117         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10118         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
10119         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
10120         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
10121         return (uint32_t)ret_ret;
10122 }
10123
10124 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint32_t ptr) {
10125         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10126         switch(obj->tag) {
10127                 case LDKFallback_SegWitProgram: return 0;
10128                 case LDKFallback_PubKeyHash: return 1;
10129                 case LDKFallback_ScriptHash: return 2;
10130                 default: abort();
10131         }
10132 }
10133 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint32_t ptr) {
10134         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10135         assert(obj->tag == LDKFallback_SegWitProgram);
10136                         uint8_t version_val = obj->seg_wit_program.version._0;
10137         return version_val;
10138 }
10139 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint32_t ptr) {
10140         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10141         assert(obj->tag == LDKFallback_SegWitProgram);
10142                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10143                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
10144                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
10145         return program_arr;
10146 }
10147 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint32_t ptr) {
10148         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10149         assert(obj->tag == LDKFallback_PubKeyHash);
10150                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
10151                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
10152         return pub_key_hash_arr;
10153 }
10154 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint32_t ptr) {
10155         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10156         assert(obj->tag == LDKFallback_ScriptHash);
10157                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
10158                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
10159         return script_hash_arr;
10160 }
10161 typedef struct LDKPayer_JCalls {
10162         atomic_size_t refcnt;
10163         uint32_t instance_ptr;
10164 } LDKPayer_JCalls;
10165 static void LDKPayer_JCalls_free(void* this_arg) {
10166         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10167         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10168                 FREE(j_calls);
10169         }
10170 }
10171 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10172         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10173         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 87);
10174         LDKPublicKey ret_ref;
10175         CHECK(ret->arr_len == 33);
10176         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10177         return ret_ref;
10178 }
10179 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10180         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10181         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 88);
10182         LDKCVec_ChannelDetailsZ ret_constr;
10183         ret_constr.datalen = ret->arr_len;
10184         if (ret_constr.datalen > 0)
10185                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10186         else
10187                 ret_constr.data = NULL;
10188         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
10189         for (size_t q = 0; q < ret_constr.datalen; q++) {
10190                 uint32_t ret_conv_16 = ret_vals[q];
10191                 LDKChannelDetails ret_conv_16_conv;
10192                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10193                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10194                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10195                 ret_constr.data[q] = ret_conv_16_conv;
10196         }
10197         return ret_constr;
10198 }
10199 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10200         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10201         LDKRoute route_var = *route;
10202         uint32_t route_ref = 0;
10203         route_var = Route_clone(&route_var);
10204         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10205         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10206         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10207         route_ref = (uintptr_t)route_var.inner;
10208         if (route_var.is_owned) {
10209                 route_ref |= 1;
10210         }
10211         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10212         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10213         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10214         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10215         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);
10216         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10217         CHECK_ACCESS(ret_ptr);
10218         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10219         FREE((void*)ret);
10220         return ret_conv;
10221 }
10222 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10223         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10224         LDKRoute route_var = *route;
10225         uint32_t route_ref = 0;
10226         route_var = Route_clone(&route_var);
10227         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10228         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10229         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10230         route_ref = (uintptr_t)route_var.inner;
10231         if (route_var.is_owned) {
10232                 route_ref |= 1;
10233         }
10234         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10235         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10236         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 90, (uint32_t)route_ref, (uint32_t)payment_preimage_arr);
10237         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10238         CHECK_ACCESS(ret_ptr);
10239         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10240         FREE((void*)ret);
10241         return ret_conv;
10242 }
10243 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
10244         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10245         LDKRoute route_var = *route;
10246         uint32_t route_ref = 0;
10247         route_var = Route_clone(&route_var);
10248         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10249         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10250         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10251         route_ref = (uintptr_t)route_var.inner;
10252         if (route_var.is_owned) {
10253                 route_ref |= 1;
10254         }
10255         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10256         memcpy(payment_id_arr->elems, payment_id.data, 32);
10257         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 91, (uint32_t)route_ref, (uint32_t)payment_id_arr);
10258         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10259         CHECK_ACCESS(ret_ptr);
10260         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
10261         FREE((void*)ret);
10262         return ret_conv;
10263 }
10264 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
10265         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10266         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10267         memcpy(payment_id_arr->elems, payment_id.data, 32);
10268         js_invoke_function_1(j_calls->instance_ptr, 92, (uint32_t)payment_id_arr);
10269 }
10270 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
10271         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
10272         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10273 }
10274 static inline LDKPayer LDKPayer_init (JSValue o) {
10275         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
10276         atomic_init(&calls->refcnt, 1);
10277         calls->instance_ptr = o;
10278
10279         LDKPayer ret = {
10280                 .this_arg = (void*) calls,
10281                 .node_id = node_id_LDKPayer_jcall,
10282                 .first_hops = first_hops_LDKPayer_jcall,
10283                 .send_payment = send_payment_LDKPayer_jcall,
10284                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
10285                 .retry_payment = retry_payment_LDKPayer_jcall,
10286                 .abandon_payment = abandon_payment_LDKPayer_jcall,
10287                 .free = LDKPayer_JCalls_free,
10288         };
10289         return ret;
10290 }
10291 long  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
10292         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
10293         *res_ptr = LDKPayer_init(o);
10294         return (long)res_ptr;
10295 }
10296 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint32_t this_arg) {
10297         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10298         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10299         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10300         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
10301         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
10302         return ret_arr;
10303 }
10304
10305 uint32_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint32_t this_arg) {
10306         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10307         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10308         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10309         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
10310         uint32_tArray ret_arr = NULL;
10311         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10312         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10313         for (size_t q = 0; q < ret_var.datalen; q++) {
10314                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10315                 uint32_t ret_conv_16_ref = 0;
10316                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10317                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10318                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
10319                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
10320                 if (ret_conv_16_var.is_owned) {
10321                         ret_conv_16_ref |= 1;
10322                 }
10323                 ret_arr_ptr[q] = ret_conv_16_ref;
10324         }
10325         
10326         FREE(ret_var.data);
10327         return ret_arr;
10328 }
10329
10330 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) {
10331         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10332         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10333         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10334         LDKRoute route_conv;
10335         route_conv.inner = (void*)(route & (~1));
10336         route_conv.is_owned = false;
10337         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10338         LDKThirtyTwoBytes payment_hash_ref;
10339         CHECK(payment_hash->arr_len == 32);
10340         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
10341         LDKThirtyTwoBytes payment_secret_ref;
10342         CHECK(payment_secret->arr_len == 32);
10343         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
10344         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10345         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
10346         return (uint32_t)ret_conv;
10347 }
10348
10349 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) {
10350         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10351         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10352         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10353         LDKRoute route_conv;
10354         route_conv.inner = (void*)(route & (~1));
10355         route_conv.is_owned = false;
10356         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10357         LDKThirtyTwoBytes payment_preimage_ref;
10358         CHECK(payment_preimage->arr_len == 32);
10359         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
10360         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10361         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
10362         return (uint32_t)ret_conv;
10363 }
10364
10365 uint32_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
10366         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10367         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10368         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10369         LDKRoute route_conv;
10370         route_conv.inner = (void*)(route & (~1));
10371         route_conv.is_owned = false;
10372         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10373         LDKThirtyTwoBytes payment_id_ref;
10374         CHECK(payment_id->arr_len == 32);
10375         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10376         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10377         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
10378         return (uint32_t)ret_conv;
10379 }
10380
10381 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
10382         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10383         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10384         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10385         LDKThirtyTwoBytes payment_id_ref;
10386         CHECK(payment_id->arr_len == 32);
10387         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10388         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
10389 }
10390
10391 typedef struct LDKRouter_JCalls {
10392         atomic_size_t refcnt;
10393         uint32_t instance_ptr;
10394 } LDKRouter_JCalls;
10395 static void LDKRouter_JCalls_free(void* this_arg) {
10396         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10397         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10398                 FREE(j_calls);
10399         }
10400 }
10401 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) {
10402         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10403         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
10404         memcpy(payer_arr->elems, payer.compressed_form, 33);
10405         LDKRouteParameters route_params_var = *route_params;
10406         uint32_t route_params_ref = 0;
10407         route_params_var = RouteParameters_clone(&route_params_var);
10408         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10409         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10410         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
10411         route_params_ref = (uintptr_t)route_params_var.inner;
10412         if (route_params_var.is_owned) {
10413                 route_params_ref |= 1;
10414         }
10415         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10416         memcpy(payment_hash_arr->elems, *payment_hash, 32);
10417         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
10418         uint32_tArray first_hops_arr = NULL;
10419         if (first_hops != NULL) {
10420                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
10421                 first_hops_arr = init_uint32_tArray(first_hops_var.datalen, __LINE__);
10422                 uint32_t *first_hops_arr_ptr = (uint32_t*)(((uint8_t*)first_hops_arr) + 4);
10423                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
10424                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
10425                         uint32_t first_hops_conv_16_ref = 0;
10426                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10427                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10428                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
10429                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
10430                         if (first_hops_conv_16_var.is_owned) {
10431                                 first_hops_conv_16_ref |= 1;
10432                         }
10433                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
10434                 }
10435         
10436         }
10437         // WARNING: This object doesn't live past this scope, needs clone!
10438         uint32_t ret_scorer = ((uintptr_t)scorer) | 1;
10439         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);
10440         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10441         CHECK_ACCESS(ret_ptr);
10442         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
10443         FREE((void*)ret);
10444         return ret_conv;
10445 }
10446 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
10447         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
10448         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10449 }
10450 static inline LDKRouter LDKRouter_init (JSValue o) {
10451         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
10452         atomic_init(&calls->refcnt, 1);
10453         calls->instance_ptr = o;
10454
10455         LDKRouter ret = {
10456                 .this_arg = (void*) calls,
10457                 .find_route = find_route_LDKRouter_jcall,
10458                 .free = LDKRouter_JCalls_free,
10459         };
10460         return ret;
10461 }
10462 long  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
10463         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
10464         *res_ptr = LDKRouter_init(o);
10465         return (long)res_ptr;
10466 }
10467 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) {
10468         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10469         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10470         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10471         LDKPublicKey payer_ref;
10472         CHECK(payer->arr_len == 33);
10473         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
10474         LDKRouteParameters route_params_conv;
10475         route_params_conv.inner = (void*)(route_params & (~1));
10476         route_params_conv.is_owned = false;
10477         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
10478         unsigned char payment_hash_arr[32];
10479         CHECK(payment_hash->arr_len == 32);
10480         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
10481         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
10482         LDKCVec_ChannelDetailsZ first_hops_constr;
10483         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
10484         if (first_hops != 0) {
10485                 first_hops_constr.datalen = first_hops->arr_len;
10486                 if (first_hops_constr.datalen > 0)
10487                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10488                 else
10489                         first_hops_constr.data = NULL;
10490                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
10491                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
10492                         uint32_t first_hops_conv_16 = first_hops_vals[q];
10493                         LDKChannelDetails first_hops_conv_16_conv;
10494                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
10495                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
10496                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
10497                         first_hops_constr.data[q] = first_hops_conv_16_conv;
10498                 }
10499                 first_hops_ptr = &first_hops_constr;
10500         }
10501         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
10502         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
10503         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
10504         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10505         *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);
10506         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
10507         return (uint32_t)ret_conv;
10508 }
10509
10510 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
10511         LDKStr ret_str = _ldk_get_compiled_version();
10512         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10513         Str_free(ret_str);
10514         return ret_conv;
10515 }
10516
10517 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
10518         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
10519         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10520         Str_free(ret_str);
10521         return ret_conv;
10522 }
10523
10524 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
10525         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
10526         *ret_copy = Bech32Error_clone(arg);
10527 uint32_t ret_ref = (uintptr_t)ret_copy;
10528         return ret_ref;
10529 }
10530 uint32_t  __attribute__((export_name("TS_Bech32Error_clone_ptr"))) TS_Bech32Error_clone_ptr(uint32_t arg) {
10531         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
10532         uint32_t ret_val = Bech32Error_clone_ptr(arg_conv);
10533         return ret_val;
10534 }
10535
10536 uint32_t  __attribute__((export_name("TS_Bech32Error_clone"))) TS_Bech32Error_clone(uint32_t orig) {
10537         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
10538         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
10539         *ret_copy = Bech32Error_clone(orig_conv);
10540         uint32_t ret_ref = (uintptr_t)ret_copy;
10541         return ret_ref;
10542 }
10543
10544 void  __attribute__((export_name("TS_Bech32Error_free"))) TS_Bech32Error_free(uint32_t o) {
10545         if ((o & 1) != 0) return;
10546         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
10547         CHECK_ACCESS(o_ptr);
10548         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
10549         FREE((void*)o);
10550         Bech32Error_free(o_conv);
10551 }
10552
10553 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
10554         LDKTransaction _res_ref;
10555         _res_ref.datalen = _res->arr_len;
10556         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
10557         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
10558         _res_ref.data_is_owned = true;
10559         Transaction_free(_res_ref);
10560 }
10561
10562 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
10563         LDKCVec_u8Z script_pubkey_ref;
10564         script_pubkey_ref.datalen = script_pubkey->arr_len;
10565         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
10566         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
10567         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10568         *ret_ref = TxOut_new(script_pubkey_ref, value);
10569         return (uint32_t)ret_ref;
10570 }
10571
10572 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
10573         if ((_res & 1) != 0) return;
10574         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10575         CHECK_ACCESS(_res_ptr);
10576         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
10577         FREE((void*)_res);
10578         TxOut_free(_res_conv);
10579 }
10580
10581 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
10582         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10583         *ret_ref = TxOut_clone(arg);
10584         return (uint32_t)ret_ref;
10585 }
10586 uint32_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
10587         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
10588         uint32_t ret_val = TxOut_clone_ptr(arg_conv);
10589         return ret_val;
10590 }
10591
10592 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
10593         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
10594         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10595         *ret_ref = TxOut_clone(orig_conv);
10596         return (uint32_t)ret_ref;
10597 }
10598
10599 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
10600         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
10601         Str_free(dummy);
10602 }
10603
10604 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
10605         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10606         *ret_conv = CResult_NoneNoneZ_ok();
10607         return (uint32_t)ret_conv;
10608 }
10609
10610 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
10611         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10612         *ret_conv = CResult_NoneNoneZ_err();
10613         return (uint32_t)ret_conv;
10614 }
10615
10616 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
10617         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
10618         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
10619         return ret_val;
10620 }
10621
10622 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
10623         if ((_res & 1) != 0) return;
10624         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10625         CHECK_ACCESS(_res_ptr);
10626         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
10627         FREE((void*)_res);
10628         CResult_NoneNoneZ_free(_res_conv);
10629 }
10630
10631 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
10632         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10633         *ret_conv = CResult_NoneNoneZ_clone(arg);
10634         return (uint32_t)ret_conv;
10635 }
10636 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
10637         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
10638         uint32_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
10639         return ret_val;
10640 }
10641
10642 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
10643         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
10644         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10645         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
10646         return (uint32_t)ret_conv;
10647 }
10648
10649 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint32_t o) {
10650         LDKCounterpartyCommitmentSecrets o_conv;
10651         o_conv.inner = (void*)(o & (~1));
10652         o_conv.is_owned = (o & 1) || (o == 0);
10653         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10654         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
10655         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10656         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
10657         return (uint32_t)ret_conv;
10658 }
10659
10660 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint32_t e) {
10661         LDKDecodeError e_conv;
10662         e_conv.inner = (void*)(e & (~1));
10663         e_conv.is_owned = (e & 1) || (e == 0);
10664         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10665         e_conv = DecodeError_clone(&e_conv);
10666         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10667         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
10668         return (uint32_t)ret_conv;
10669 }
10670
10671 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint32_t o) {
10672         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
10673         jboolean ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
10674         return ret_val;
10675 }
10676
10677 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint32_t _res) {
10678         if ((_res & 1) != 0) return;
10679         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10680         CHECK_ACCESS(_res_ptr);
10681         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
10682         FREE((void*)_res);
10683         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
10684 }
10685
10686 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
10687         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10688         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
10689         return (uint32_t)ret_conv;
10690 }
10691 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint32_t arg) {
10692         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
10693         uint32_t ret_val = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
10694         return ret_val;
10695 }
10696
10697 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint32_t orig) {
10698         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
10699         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10700         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
10701         return (uint32_t)ret_conv;
10702 }
10703
10704 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
10705         LDKSecretKey o_ref;
10706         CHECK(o->arr_len == 32);
10707         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
10708         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10709         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
10710         return (uint32_t)ret_conv;
10711 }
10712
10713 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
10714         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10715         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10716         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
10717         return (uint32_t)ret_conv;
10718 }
10719
10720 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
10721         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
10722         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
10723         return ret_val;
10724 }
10725
10726 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
10727         if ((_res & 1) != 0) return;
10728         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10729         CHECK_ACCESS(_res_ptr);
10730         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
10731         FREE((void*)_res);
10732         CResult_SecretKeyErrorZ_free(_res_conv);
10733 }
10734
10735 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
10736         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10737         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
10738         return (uint32_t)ret_conv;
10739 }
10740 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint32_t arg) {
10741         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
10742         uint32_t ret_val = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
10743         return ret_val;
10744 }
10745
10746 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint32_t orig) {
10747         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
10748         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10749         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
10750         return (uint32_t)ret_conv;
10751 }
10752
10753 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
10754         LDKPublicKey o_ref;
10755         CHECK(o->arr_len == 33);
10756         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
10757         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10758         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
10759         return (uint32_t)ret_conv;
10760 }
10761
10762 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
10763         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10764         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10765         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
10766         return (uint32_t)ret_conv;
10767 }
10768
10769 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
10770         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
10771         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
10772         return ret_val;
10773 }
10774
10775 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
10776         if ((_res & 1) != 0) return;
10777         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10778         CHECK_ACCESS(_res_ptr);
10779         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
10780         FREE((void*)_res);
10781         CResult_PublicKeyErrorZ_free(_res_conv);
10782 }
10783
10784 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
10785         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10786         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
10787         return (uint32_t)ret_conv;
10788 }
10789 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
10790         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
10791         uint32_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
10792         return ret_val;
10793 }
10794
10795 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
10796         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
10797         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10798         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
10799         return (uint32_t)ret_conv;
10800 }
10801
10802 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
10803         LDKTxCreationKeys o_conv;
10804         o_conv.inner = (void*)(o & (~1));
10805         o_conv.is_owned = (o & 1) || (o == 0);
10806         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10807         o_conv = TxCreationKeys_clone(&o_conv);
10808         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10809         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
10810         return (uint32_t)ret_conv;
10811 }
10812
10813 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
10814         LDKDecodeError e_conv;
10815         e_conv.inner = (void*)(e & (~1));
10816         e_conv.is_owned = (e & 1) || (e == 0);
10817         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10818         e_conv = DecodeError_clone(&e_conv);
10819         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10820         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
10821         return (uint32_t)ret_conv;
10822 }
10823
10824 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
10825         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
10826         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
10827         return ret_val;
10828 }
10829
10830 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
10831         if ((_res & 1) != 0) return;
10832         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10833         CHECK_ACCESS(_res_ptr);
10834         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
10835         FREE((void*)_res);
10836         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
10837 }
10838
10839 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
10840         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10841         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
10842         return (uint32_t)ret_conv;
10843 }
10844 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10845         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
10846         uint32_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
10847         return ret_val;
10848 }
10849
10850 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
10851         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
10852         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10853         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
10854         return (uint32_t)ret_conv;
10855 }
10856
10857 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
10858         LDKChannelPublicKeys o_conv;
10859         o_conv.inner = (void*)(o & (~1));
10860         o_conv.is_owned = (o & 1) || (o == 0);
10861         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10862         o_conv = ChannelPublicKeys_clone(&o_conv);
10863         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10864         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
10865         return (uint32_t)ret_conv;
10866 }
10867
10868 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
10869         LDKDecodeError e_conv;
10870         e_conv.inner = (void*)(e & (~1));
10871         e_conv.is_owned = (e & 1) || (e == 0);
10872         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10873         e_conv = DecodeError_clone(&e_conv);
10874         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10875         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
10876         return (uint32_t)ret_conv;
10877 }
10878
10879 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
10880         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
10881         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
10882         return ret_val;
10883 }
10884
10885 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
10886         if ((_res & 1) != 0) return;
10887         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10888         CHECK_ACCESS(_res_ptr);
10889         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
10890         FREE((void*)_res);
10891         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
10892 }
10893
10894 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
10895         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10896         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
10897         return (uint32_t)ret_conv;
10898 }
10899 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10900         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
10901         uint32_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
10902         return ret_val;
10903 }
10904
10905 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
10906         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
10907         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10908         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
10909         return (uint32_t)ret_conv;
10910 }
10911
10912 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
10913         LDKTxCreationKeys o_conv;
10914         o_conv.inner = (void*)(o & (~1));
10915         o_conv.is_owned = (o & 1) || (o == 0);
10916         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10917         o_conv = TxCreationKeys_clone(&o_conv);
10918         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10919         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
10920         return (uint32_t)ret_conv;
10921 }
10922
10923 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
10924         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10925         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10926         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
10927         return (uint32_t)ret_conv;
10928 }
10929
10930 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
10931         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
10932         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
10933         return ret_val;
10934 }
10935
10936 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
10937         if ((_res & 1) != 0) return;
10938         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10939         CHECK_ACCESS(_res_ptr);
10940         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
10941         FREE((void*)_res);
10942         CResult_TxCreationKeysErrorZ_free(_res_conv);
10943 }
10944
10945 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
10946         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10947         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
10948         return (uint32_t)ret_conv;
10949 }
10950 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
10951         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
10952         uint32_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
10953         return ret_val;
10954 }
10955
10956 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
10957         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
10958         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10959         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
10960         return (uint32_t)ret_conv;
10961 }
10962
10963 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
10964         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10965         *ret_copy = COption_u32Z_some(o);
10966         uint32_t ret_ref = (uintptr_t)ret_copy;
10967         return ret_ref;
10968 }
10969
10970 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
10971         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10972         *ret_copy = COption_u32Z_none();
10973         uint32_t ret_ref = (uintptr_t)ret_copy;
10974         return ret_ref;
10975 }
10976
10977 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
10978         if ((_res & 1) != 0) return;
10979         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10980         CHECK_ACCESS(_res_ptr);
10981         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
10982         FREE((void*)_res);
10983         COption_u32Z_free(_res_conv);
10984 }
10985
10986 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
10987         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
10988         *ret_copy = COption_u32Z_clone(arg);
10989 uint32_t ret_ref = (uintptr_t)ret_copy;
10990         return ret_ref;
10991 }
10992 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
10993         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
10994         uint32_t ret_val = COption_u32Z_clone_ptr(arg_conv);
10995         return ret_val;
10996 }
10997
10998 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
10999         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11000         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11001         *ret_copy = COption_u32Z_clone(orig_conv);
11002         uint32_t ret_ref = (uintptr_t)ret_copy;
11003         return ret_ref;
11004 }
11005
11006 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
11007         LDKHTLCOutputInCommitment o_conv;
11008         o_conv.inner = (void*)(o & (~1));
11009         o_conv.is_owned = (o & 1) || (o == 0);
11010         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11011         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11012         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11013         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11014         return (uint32_t)ret_conv;
11015 }
11016
11017 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
11018         LDKDecodeError e_conv;
11019         e_conv.inner = (void*)(e & (~1));
11020         e_conv.is_owned = (e & 1) || (e == 0);
11021         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11022         e_conv = DecodeError_clone(&e_conv);
11023         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11024         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11025         return (uint32_t)ret_conv;
11026 }
11027
11028 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
11029         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
11030         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11031         return ret_val;
11032 }
11033
11034 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
11035         if ((_res & 1) != 0) return;
11036         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11037         CHECK_ACCESS(_res_ptr);
11038         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11039         FREE((void*)_res);
11040         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11041 }
11042
11043 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11044         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11045         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11046         return (uint32_t)ret_conv;
11047 }
11048 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
11049         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
11050         uint32_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11051         return ret_val;
11052 }
11053
11054 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
11055         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11056         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11057         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11058         return (uint32_t)ret_conv;
11059 }
11060
11061 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
11062         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
11063         return ret_conv;
11064 }
11065
11066 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
11067         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
11068         return ret_conv;
11069 }
11070
11071 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
11072         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
11073         COption_NoneZ_free(_res_conv);
11074 }
11075
11076 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11077         LDKCounterpartyChannelTransactionParameters o_conv;
11078         o_conv.inner = (void*)(o & (~1));
11079         o_conv.is_owned = (o & 1) || (o == 0);
11080         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11081         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11082         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11083         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11084         return (uint32_t)ret_conv;
11085 }
11086
11087 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11088         LDKDecodeError e_conv;
11089         e_conv.inner = (void*)(e & (~1));
11090         e_conv.is_owned = (e & 1) || (e == 0);
11091         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11092         e_conv = DecodeError_clone(&e_conv);
11093         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11094         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11095         return (uint32_t)ret_conv;
11096 }
11097
11098 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11099         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11100         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11101         return ret_val;
11102 }
11103
11104 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11105         if ((_res & 1) != 0) return;
11106         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11107         CHECK_ACCESS(_res_ptr);
11108         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11109         FREE((void*)_res);
11110         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11111 }
11112
11113 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11114         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11115         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
11116         return (uint32_t)ret_conv;
11117 }
11118 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11119         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11120         uint32_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11121         return ret_val;
11122 }
11123
11124 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11125         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11126         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11127         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11128         return (uint32_t)ret_conv;
11129 }
11130
11131 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11132         LDKChannelTransactionParameters o_conv;
11133         o_conv.inner = (void*)(o & (~1));
11134         o_conv.is_owned = (o & 1) || (o == 0);
11135         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11136         o_conv = ChannelTransactionParameters_clone(&o_conv);
11137         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11138         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11139         return (uint32_t)ret_conv;
11140 }
11141
11142 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11143         LDKDecodeError e_conv;
11144         e_conv.inner = (void*)(e & (~1));
11145         e_conv.is_owned = (e & 1) || (e == 0);
11146         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11147         e_conv = DecodeError_clone(&e_conv);
11148         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11149         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11150         return (uint32_t)ret_conv;
11151 }
11152
11153 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11154         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11155         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11156         return ret_val;
11157 }
11158
11159 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11160         if ((_res & 1) != 0) return;
11161         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11162         CHECK_ACCESS(_res_ptr);
11163         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11164         FREE((void*)_res);
11165         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11166 }
11167
11168 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11169         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11170         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11171         return (uint32_t)ret_conv;
11172 }
11173 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11174         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11175         uint32_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11176         return ret_val;
11177 }
11178
11179 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11180         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11181         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11182         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11183         return (uint32_t)ret_conv;
11184 }
11185
11186 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
11187         LDKCVec_SignatureZ _res_constr;
11188         _res_constr.datalen = _res->arr_len;
11189         if (_res_constr.datalen > 0)
11190                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11191         else
11192                 _res_constr.data = NULL;
11193         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11194         for (size_t m = 0; m < _res_constr.datalen; m++) {
11195                 int8_tArray _res_conv_12 = _res_vals[m];
11196                 LDKSignature _res_conv_12_ref;
11197                 CHECK(_res_conv_12->arr_len == 64);
11198                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11199                 _res_constr.data[m] = _res_conv_12_ref;
11200         }
11201         CVec_SignatureZ_free(_res_constr);
11202 }
11203
11204 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11205         LDKHolderCommitmentTransaction o_conv;
11206         o_conv.inner = (void*)(o & (~1));
11207         o_conv.is_owned = (o & 1) || (o == 0);
11208         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11209         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11210         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11211         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11212         return (uint32_t)ret_conv;
11213 }
11214
11215 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11216         LDKDecodeError e_conv;
11217         e_conv.inner = (void*)(e & (~1));
11218         e_conv.is_owned = (e & 1) || (e == 0);
11219         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11220         e_conv = DecodeError_clone(&e_conv);
11221         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11222         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11223         return (uint32_t)ret_conv;
11224 }
11225
11226 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11227         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
11228         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11229         return ret_val;
11230 }
11231
11232 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11233         if ((_res & 1) != 0) return;
11234         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11235         CHECK_ACCESS(_res_ptr);
11236         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11237         FREE((void*)_res);
11238         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11239 }
11240
11241 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11242         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11243         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
11244         return (uint32_t)ret_conv;
11245 }
11246 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11247         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11248         uint32_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11249         return ret_val;
11250 }
11251
11252 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11253         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11254         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11255         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11256         return (uint32_t)ret_conv;
11257 }
11258
11259 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11260         LDKBuiltCommitmentTransaction o_conv;
11261         o_conv.inner = (void*)(o & (~1));
11262         o_conv.is_owned = (o & 1) || (o == 0);
11263         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11264         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11265         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11266         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11267         return (uint32_t)ret_conv;
11268 }
11269
11270 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11271         LDKDecodeError e_conv;
11272         e_conv.inner = (void*)(e & (~1));
11273         e_conv.is_owned = (e & 1) || (e == 0);
11274         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11275         e_conv = DecodeError_clone(&e_conv);
11276         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11277         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11278         return (uint32_t)ret_conv;
11279 }
11280
11281 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11282         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
11283         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11284         return ret_val;
11285 }
11286
11287 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11288         if ((_res & 1) != 0) return;
11289         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11290         CHECK_ACCESS(_res_ptr);
11291         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11292         FREE((void*)_res);
11293         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11294 }
11295
11296 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11297         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11298         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
11299         return (uint32_t)ret_conv;
11300 }
11301 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11302         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11303         uint32_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11304         return ret_val;
11305 }
11306
11307 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11308         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11309         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11310         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11311         return (uint32_t)ret_conv;
11312 }
11313
11314 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
11315         LDKTrustedClosingTransaction o_conv;
11316         o_conv.inner = (void*)(o & (~1));
11317         o_conv.is_owned = (o & 1) || (o == 0);
11318         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11319         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
11320         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11321         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11322         return (uint32_t)ret_conv;
11323 }
11324
11325 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
11326         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11327         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11328         return (uint32_t)ret_conv;
11329 }
11330
11331 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
11332         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
11333         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
11334         return ret_val;
11335 }
11336
11337 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
11338         if ((_res & 1) != 0) return;
11339         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11340         CHECK_ACCESS(_res_ptr);
11341         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
11342         FREE((void*)_res);
11343         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
11344 }
11345
11346 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11347         LDKCommitmentTransaction o_conv;
11348         o_conv.inner = (void*)(o & (~1));
11349         o_conv.is_owned = (o & 1) || (o == 0);
11350         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11351         o_conv = CommitmentTransaction_clone(&o_conv);
11352         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11353         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
11354         return (uint32_t)ret_conv;
11355 }
11356
11357 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11358         LDKDecodeError e_conv;
11359         e_conv.inner = (void*)(e & (~1));
11360         e_conv.is_owned = (e & 1) || (e == 0);
11361         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11362         e_conv = DecodeError_clone(&e_conv);
11363         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11364         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
11365         return (uint32_t)ret_conv;
11366 }
11367
11368 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11369         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
11370         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11371         return ret_val;
11372 }
11373
11374 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11375         if ((_res & 1) != 0) return;
11376         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11377         CHECK_ACCESS(_res_ptr);
11378         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
11379         FREE((void*)_res);
11380         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
11381 }
11382
11383 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11384         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11385         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
11386         return (uint32_t)ret_conv;
11387 }
11388 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11389         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
11390         uint32_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11391         return ret_val;
11392 }
11393
11394 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11395         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
11396         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11397         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
11398         return (uint32_t)ret_conv;
11399 }
11400
11401 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
11402         LDKTrustedCommitmentTransaction o_conv;
11403         o_conv.inner = (void*)(o & (~1));
11404         o_conv.is_owned = (o & 1) || (o == 0);
11405         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11406         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
11407         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11408         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
11409         return (uint32_t)ret_conv;
11410 }
11411
11412 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
11413         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11414         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
11415         return (uint32_t)ret_conv;
11416 }
11417
11418 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
11419         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
11420         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
11421         return ret_val;
11422 }
11423
11424 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
11425         if ((_res & 1) != 0) return;
11426         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11427         CHECK_ACCESS(_res_ptr);
11428         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
11429         FREE((void*)_res);
11430         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
11431 }
11432
11433 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
11434         LDKCVec_SignatureZ o_constr;
11435         o_constr.datalen = o->arr_len;
11436         if (o_constr.datalen > 0)
11437                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11438         else
11439                 o_constr.data = NULL;
11440         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
11441         for (size_t m = 0; m < o_constr.datalen; m++) {
11442                 int8_tArray o_conv_12 = o_vals[m];
11443                 LDKSignature o_conv_12_ref;
11444                 CHECK(o_conv_12->arr_len == 64);
11445                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
11446                 o_constr.data[m] = o_conv_12_ref;
11447         }
11448         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11449         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
11450         return (uint32_t)ret_conv;
11451 }
11452
11453 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
11454         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11455         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
11456         return (uint32_t)ret_conv;
11457 }
11458
11459 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
11460         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
11461         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
11462         return ret_val;
11463 }
11464
11465 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
11466         if ((_res & 1) != 0) return;
11467         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11468         CHECK_ACCESS(_res_ptr);
11469         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
11470         FREE((void*)_res);
11471         CResult_CVec_SignatureZNoneZ_free(_res_conv);
11472 }
11473
11474 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
11475         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11476         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
11477         return (uint32_t)ret_conv;
11478 }
11479 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
11480         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
11481         uint32_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
11482         return ret_val;
11483 }
11484
11485 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
11486         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
11487         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11488         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
11489         return (uint32_t)ret_conv;
11490 }
11491
11492 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
11493         LDKShutdownScript o_conv;
11494         o_conv.inner = (void*)(o & (~1));
11495         o_conv.is_owned = (o & 1) || (o == 0);
11496         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11497         o_conv = ShutdownScript_clone(&o_conv);
11498         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11499         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
11500         return (uint32_t)ret_conv;
11501 }
11502
11503 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
11504         LDKDecodeError e_conv;
11505         e_conv.inner = (void*)(e & (~1));
11506         e_conv.is_owned = (e & 1) || (e == 0);
11507         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11508         e_conv = DecodeError_clone(&e_conv);
11509         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11510         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
11511         return (uint32_t)ret_conv;
11512 }
11513
11514 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
11515         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
11516         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
11517         return ret_val;
11518 }
11519
11520 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
11521         if ((_res & 1) != 0) return;
11522         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11523         CHECK_ACCESS(_res_ptr);
11524         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
11525         FREE((void*)_res);
11526         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
11527 }
11528
11529 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
11530         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11531         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
11532         return (uint32_t)ret_conv;
11533 }
11534 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
11535         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
11536         uint32_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
11537         return ret_val;
11538 }
11539
11540 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
11541         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
11542         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11543         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
11544         return (uint32_t)ret_conv;
11545 }
11546
11547 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
11548         LDKShutdownScript o_conv;
11549         o_conv.inner = (void*)(o & (~1));
11550         o_conv.is_owned = (o & 1) || (o == 0);
11551         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11552         o_conv = ShutdownScript_clone(&o_conv);
11553         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11554         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
11555         return (uint32_t)ret_conv;
11556 }
11557
11558 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
11559         LDKInvalidShutdownScript e_conv;
11560         e_conv.inner = (void*)(e & (~1));
11561         e_conv.is_owned = (e & 1) || (e == 0);
11562         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11563         e_conv = InvalidShutdownScript_clone(&e_conv);
11564         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11565         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
11566         return (uint32_t)ret_conv;
11567 }
11568
11569 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
11570         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
11571         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
11572         return ret_val;
11573 }
11574
11575 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
11576         if ((_res & 1) != 0) return;
11577         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11578         CHECK_ACCESS(_res_ptr);
11579         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
11580         FREE((void*)_res);
11581         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
11582 }
11583
11584 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
11585         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11586         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
11587         return (uint32_t)ret_conv;
11588 }
11589 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
11590         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
11591         uint32_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
11592         return ret_val;
11593 }
11594
11595 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
11596         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
11597         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11598         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
11599         return (uint32_t)ret_conv;
11600 }
11601
11602 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
11603         LDKRouteHop o_conv;
11604         o_conv.inner = (void*)(o & (~1));
11605         o_conv.is_owned = (o & 1) || (o == 0);
11606         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11607         o_conv = RouteHop_clone(&o_conv);
11608         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11609         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
11610         return (uint32_t)ret_conv;
11611 }
11612
11613 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
11614         LDKDecodeError e_conv;
11615         e_conv.inner = (void*)(e & (~1));
11616         e_conv.is_owned = (e & 1) || (e == 0);
11617         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11618         e_conv = DecodeError_clone(&e_conv);
11619         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11620         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
11621         return (uint32_t)ret_conv;
11622 }
11623
11624 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
11625         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
11626         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
11627         return ret_val;
11628 }
11629
11630 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
11631         if ((_res & 1) != 0) return;
11632         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11633         CHECK_ACCESS(_res_ptr);
11634         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
11635         FREE((void*)_res);
11636         CResult_RouteHopDecodeErrorZ_free(_res_conv);
11637 }
11638
11639 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
11640         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11641         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
11642         return (uint32_t)ret_conv;
11643 }
11644 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
11645         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
11646         uint32_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
11647         return ret_val;
11648 }
11649
11650 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
11651         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
11652         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11653         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
11654         return (uint32_t)ret_conv;
11655 }
11656
11657 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
11658         LDKCVec_RouteHopZ _res_constr;
11659         _res_constr.datalen = _res->arr_len;
11660         if (_res_constr.datalen > 0)
11661                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11662         else
11663                 _res_constr.data = NULL;
11664         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11665         for (size_t k = 0; k < _res_constr.datalen; k++) {
11666                 uint32_t _res_conv_10 = _res_vals[k];
11667                 LDKRouteHop _res_conv_10_conv;
11668                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
11669                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
11670                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
11671                 _res_constr.data[k] = _res_conv_10_conv;
11672         }
11673         CVec_RouteHopZ_free(_res_constr);
11674 }
11675
11676 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
11677         LDKCVec_CVec_RouteHopZZ _res_constr;
11678         _res_constr.datalen = _res->arr_len;
11679         if (_res_constr.datalen > 0)
11680                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
11681         else
11682                 _res_constr.data = NULL;
11683         uint32_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11684         for (size_t m = 0; m < _res_constr.datalen; m++) {
11685                 uint32_tArray _res_conv_12 = _res_vals[m];
11686                 LDKCVec_RouteHopZ _res_conv_12_constr;
11687                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
11688                 if (_res_conv_12_constr.datalen > 0)
11689                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11690                 else
11691                         _res_conv_12_constr.data = NULL;
11692                 uint32_t* _res_conv_12_vals = _res_conv_12->elems /* XXX _res_conv_12 leaks */;
11693                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
11694                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
11695                         LDKRouteHop _res_conv_12_conv_10_conv;
11696                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
11697                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
11698                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
11699                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
11700                 }
11701                 _res_constr.data[m] = _res_conv_12_constr;
11702         }
11703         CVec_CVec_RouteHopZZ_free(_res_constr);
11704 }
11705
11706 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
11707         LDKRoute o_conv;
11708         o_conv.inner = (void*)(o & (~1));
11709         o_conv.is_owned = (o & 1) || (o == 0);
11710         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11711         o_conv = Route_clone(&o_conv);
11712         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11713         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
11714         return (uint32_t)ret_conv;
11715 }
11716
11717 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
11718         LDKDecodeError e_conv;
11719         e_conv.inner = (void*)(e & (~1));
11720         e_conv.is_owned = (e & 1) || (e == 0);
11721         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11722         e_conv = DecodeError_clone(&e_conv);
11723         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11724         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
11725         return (uint32_t)ret_conv;
11726 }
11727
11728 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
11729         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
11730         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
11731         return ret_val;
11732 }
11733
11734 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
11735         if ((_res & 1) != 0) return;
11736         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11737         CHECK_ACCESS(_res_ptr);
11738         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
11739         FREE((void*)_res);
11740         CResult_RouteDecodeErrorZ_free(_res_conv);
11741 }
11742
11743 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
11744         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11745         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
11746         return (uint32_t)ret_conv;
11747 }
11748 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
11749         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
11750         uint32_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
11751         return ret_val;
11752 }
11753
11754 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
11755         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
11756         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11757         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
11758         return (uint32_t)ret_conv;
11759 }
11760
11761 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
11762         LDKRouteParameters o_conv;
11763         o_conv.inner = (void*)(o & (~1));
11764         o_conv.is_owned = (o & 1) || (o == 0);
11765         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11766         o_conv = RouteParameters_clone(&o_conv);
11767         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11768         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
11769         return (uint32_t)ret_conv;
11770 }
11771
11772 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
11773         LDKDecodeError e_conv;
11774         e_conv.inner = (void*)(e & (~1));
11775         e_conv.is_owned = (e & 1) || (e == 0);
11776         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11777         e_conv = DecodeError_clone(&e_conv);
11778         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11779         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
11780         return (uint32_t)ret_conv;
11781 }
11782
11783 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
11784         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
11785         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
11786         return ret_val;
11787 }
11788
11789 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
11790         if ((_res & 1) != 0) return;
11791         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11792         CHECK_ACCESS(_res_ptr);
11793         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
11794         FREE((void*)_res);
11795         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
11796 }
11797
11798 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
11799         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11800         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
11801         return (uint32_t)ret_conv;
11802 }
11803 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11804         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
11805         uint32_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
11806         return ret_val;
11807 }
11808
11809 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
11810         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
11811         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11812         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
11813         return (uint32_t)ret_conv;
11814 }
11815
11816 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
11817         LDKCVec_RouteHintZ _res_constr;
11818         _res_constr.datalen = _res->arr_len;
11819         if (_res_constr.datalen > 0)
11820                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
11821         else
11822                 _res_constr.data = NULL;
11823         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11824         for (size_t l = 0; l < _res_constr.datalen; l++) {
11825                 uint32_t _res_conv_11 = _res_vals[l];
11826                 LDKRouteHint _res_conv_11_conv;
11827                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
11828                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
11829                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
11830                 _res_constr.data[l] = _res_conv_11_conv;
11831         }
11832         CVec_RouteHintZ_free(_res_constr);
11833 }
11834
11835 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
11836         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11837         *ret_copy = COption_u64Z_some(o);
11838         uint32_t ret_ref = (uintptr_t)ret_copy;
11839         return ret_ref;
11840 }
11841
11842 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
11843         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11844         *ret_copy = COption_u64Z_none();
11845         uint32_t ret_ref = (uintptr_t)ret_copy;
11846         return ret_ref;
11847 }
11848
11849 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
11850         if ((_res & 1) != 0) return;
11851         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11852         CHECK_ACCESS(_res_ptr);
11853         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
11854         FREE((void*)_res);
11855         COption_u64Z_free(_res_conv);
11856 }
11857
11858 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
11859         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11860         *ret_copy = COption_u64Z_clone(arg);
11861 uint32_t ret_ref = (uintptr_t)ret_copy;
11862         return ret_ref;
11863 }
11864 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
11865         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
11866         uint32_t ret_val = COption_u64Z_clone_ptr(arg_conv);
11867         return ret_val;
11868 }
11869
11870 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
11871         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
11872         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11873         *ret_copy = COption_u64Z_clone(orig_conv);
11874         uint32_t ret_ref = (uintptr_t)ret_copy;
11875         return ret_ref;
11876 }
11877
11878 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint32_t o) {
11879         LDKPaymentParameters o_conv;
11880         o_conv.inner = (void*)(o & (~1));
11881         o_conv.is_owned = (o & 1) || (o == 0);
11882         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11883         o_conv = PaymentParameters_clone(&o_conv);
11884         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11885         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
11886         return (uint32_t)ret_conv;
11887 }
11888
11889 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint32_t e) {
11890         LDKDecodeError e_conv;
11891         e_conv.inner = (void*)(e & (~1));
11892         e_conv.is_owned = (e & 1) || (e == 0);
11893         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11894         e_conv = DecodeError_clone(&e_conv);
11895         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11896         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
11897         return (uint32_t)ret_conv;
11898 }
11899
11900 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint32_t o) {
11901         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
11902         jboolean ret_val = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
11903         return ret_val;
11904 }
11905
11906 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint32_t _res) {
11907         if ((_res & 1) != 0) return;
11908         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11909         CHECK_ACCESS(_res_ptr);
11910         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
11911         FREE((void*)_res);
11912         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
11913 }
11914
11915 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
11916         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11917         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
11918         return (uint32_t)ret_conv;
11919 }
11920 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11921         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
11922         uint32_t ret_val = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
11923         return ret_val;
11924 }
11925
11926 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint32_t orig) {
11927         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
11928         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11929         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
11930         return (uint32_t)ret_conv;
11931 }
11932
11933 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
11934         LDKCVec_RouteHintHopZ _res_constr;
11935         _res_constr.datalen = _res->arr_len;
11936         if (_res_constr.datalen > 0)
11937                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
11938         else
11939                 _res_constr.data = NULL;
11940         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11941         for (size_t o = 0; o < _res_constr.datalen; o++) {
11942                 uint32_t _res_conv_14 = _res_vals[o];
11943                 LDKRouteHintHop _res_conv_14_conv;
11944                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11945                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11946                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
11947                 _res_constr.data[o] = _res_conv_14_conv;
11948         }
11949         CVec_RouteHintHopZ_free(_res_constr);
11950 }
11951
11952 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
11953         LDKRouteHint o_conv;
11954         o_conv.inner = (void*)(o & (~1));
11955         o_conv.is_owned = (o & 1) || (o == 0);
11956         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11957         o_conv = RouteHint_clone(&o_conv);
11958         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11959         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
11960         return (uint32_t)ret_conv;
11961 }
11962
11963 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
11964         LDKDecodeError e_conv;
11965         e_conv.inner = (void*)(e & (~1));
11966         e_conv.is_owned = (e & 1) || (e == 0);
11967         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11968         e_conv = DecodeError_clone(&e_conv);
11969         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11970         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
11971         return (uint32_t)ret_conv;
11972 }
11973
11974 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
11975         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
11976         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
11977         return ret_val;
11978 }
11979
11980 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
11981         if ((_res & 1) != 0) return;
11982         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11983         CHECK_ACCESS(_res_ptr);
11984         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
11985         FREE((void*)_res);
11986         CResult_RouteHintDecodeErrorZ_free(_res_conv);
11987 }
11988
11989 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
11990         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11991         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
11992         return (uint32_t)ret_conv;
11993 }
11994 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
11995         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
11996         uint32_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
11997         return ret_val;
11998 }
11999
12000 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
12001         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12002         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12003         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12004         return (uint32_t)ret_conv;
12005 }
12006
12007 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
12008         LDKRouteHintHop o_conv;
12009         o_conv.inner = (void*)(o & (~1));
12010         o_conv.is_owned = (o & 1) || (o == 0);
12011         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12012         o_conv = RouteHintHop_clone(&o_conv);
12013         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12014         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12015         return (uint32_t)ret_conv;
12016 }
12017
12018 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
12019         LDKDecodeError e_conv;
12020         e_conv.inner = (void*)(e & (~1));
12021         e_conv.is_owned = (e & 1) || (e == 0);
12022         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12023         e_conv = DecodeError_clone(&e_conv);
12024         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12025         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12026         return (uint32_t)ret_conv;
12027 }
12028
12029 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
12030         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
12031         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12032         return ret_val;
12033 }
12034
12035 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
12036         if ((_res & 1) != 0) return;
12037         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12038         CHECK_ACCESS(_res_ptr);
12039         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12040         FREE((void*)_res);
12041         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12042 }
12043
12044 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12045         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12046         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12047         return (uint32_t)ret_conv;
12048 }
12049 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12050         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
12051         uint32_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12052         return ret_val;
12053 }
12054
12055 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
12056         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12057         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12058         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12059         return (uint32_t)ret_conv;
12060 }
12061
12062 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
12063         LDKCVec_ChannelDetailsZ _res_constr;
12064         _res_constr.datalen = _res->arr_len;
12065         if (_res_constr.datalen > 0)
12066                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12067         else
12068                 _res_constr.data = NULL;
12069         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12070         for (size_t q = 0; q < _res_constr.datalen; q++) {
12071                 uint32_t _res_conv_16 = _res_vals[q];
12072                 LDKChannelDetails _res_conv_16_conv;
12073                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12074                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12075                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
12076                 _res_constr.data[q] = _res_conv_16_conv;
12077         }
12078         CVec_ChannelDetailsZ_free(_res_constr);
12079 }
12080
12081 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
12082         LDKRoute o_conv;
12083         o_conv.inner = (void*)(o & (~1));
12084         o_conv.is_owned = (o & 1) || (o == 0);
12085         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12086         o_conv = Route_clone(&o_conv);
12087         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12088         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12089         return (uint32_t)ret_conv;
12090 }
12091
12092 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
12093         LDKLightningError e_conv;
12094         e_conv.inner = (void*)(e & (~1));
12095         e_conv.is_owned = (e & 1) || (e == 0);
12096         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12097         e_conv = LightningError_clone(&e_conv);
12098         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12099         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12100         return (uint32_t)ret_conv;
12101 }
12102
12103 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
12104         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
12105         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
12106         return ret_val;
12107 }
12108
12109 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
12110         if ((_res & 1) != 0) return;
12111         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12112         CHECK_ACCESS(_res_ptr);
12113         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12114         FREE((void*)_res);
12115         CResult_RouteLightningErrorZ_free(_res_conv);
12116 }
12117
12118 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
12119         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12120         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
12121         return (uint32_t)ret_conv;
12122 }
12123 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
12124         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
12125         uint32_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
12126         return ret_val;
12127 }
12128
12129 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
12130         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12131         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12132         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12133         return (uint32_t)ret_conv;
12134 }
12135
12136 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
12137         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12138         CHECK_ACCESS(o_ptr);
12139         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
12140         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
12141         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12142         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
12143         return (uint32_t)ret_conv;
12144 }
12145
12146 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
12147         LDKAccessError e_conv = LDKAccessError_from_js(e);
12148         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12149         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
12150         return (uint32_t)ret_conv;
12151 }
12152
12153 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
12154         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
12155         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
12156         return ret_val;
12157 }
12158
12159 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
12160         if ((_res & 1) != 0) return;
12161         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12162         CHECK_ACCESS(_res_ptr);
12163         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
12164         FREE((void*)_res);
12165         CResult_TxOutAccessErrorZ_free(_res_conv);
12166 }
12167
12168 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
12169         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12170         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
12171         return (uint32_t)ret_conv;
12172 }
12173 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
12174         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
12175         uint32_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
12176         return ret_val;
12177 }
12178
12179 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
12180         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
12181         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12182         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
12183         return (uint32_t)ret_conv;
12184 }
12185
12186 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
12187         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12188         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
12189         return ((uint32_t)ret_conv);
12190 }
12191 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
12192         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
12193         uint32_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
12194         return ret_val;
12195 }
12196
12197 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
12198         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
12199         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12200         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
12201         return ((uint32_t)ret_conv);
12202 }
12203
12204 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(uint32_t a, int8_tArray b) {
12205         LDKTransaction b_ref;
12206         b_ref.datalen = b->arr_len;
12207         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
12208         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
12209         b_ref.data_is_owned = true;
12210         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12211         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
12212         return ((uint32_t)ret_conv);
12213 }
12214
12215 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
12216         if ((_res & 1) != 0) return;
12217         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12218         CHECK_ACCESS(_res_ptr);
12219         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
12220         FREE((void*)_res);
12221         C2Tuple_usizeTransactionZ_free(_res_conv);
12222 }
12223
12224 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
12225         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
12226         _res_constr.datalen = _res->arr_len;
12227         if (_res_constr.datalen > 0)
12228                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12229         else
12230                 _res_constr.data = NULL;
12231         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12232         for (size_t c = 0; c < _res_constr.datalen; c++) {
12233                 uint32_t _res_conv_28 = _res_vals[c];
12234                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
12235                 CHECK_ACCESS(_res_conv_28_ptr);
12236                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
12237                 FREE((void*)_res_conv_28);
12238                 _res_constr.data[c] = _res_conv_28_conv;
12239         }
12240         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
12241 }
12242
12243 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
12244         LDKCVec_TxidZ _res_constr;
12245         _res_constr.datalen = _res->arr_len;
12246         if (_res_constr.datalen > 0)
12247                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
12248         else
12249                 _res_constr.data = NULL;
12250         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
12251         for (size_t m = 0; m < _res_constr.datalen; m++) {
12252                 int8_tArray _res_conv_12 = _res_vals[m];
12253                 LDKThirtyTwoBytes _res_conv_12_ref;
12254                 CHECK(_res_conv_12->arr_len == 32);
12255                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
12256                 _res_constr.data[m] = _res_conv_12_ref;
12257         }
12258         CVec_TxidZ_free(_res_constr);
12259 }
12260
12261 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
12262         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12263         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
12264         return (uint32_t)ret_conv;
12265 }
12266
12267 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
12268         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
12269         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12270         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
12271         return (uint32_t)ret_conv;
12272 }
12273
12274 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
12275         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
12276         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
12277         return ret_val;
12278 }
12279
12280 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
12281         if ((_res & 1) != 0) return;
12282         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12283         CHECK_ACCESS(_res_ptr);
12284         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
12285         FREE((void*)_res);
12286         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
12287 }
12288
12289 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
12290         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12291         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
12292         return (uint32_t)ret_conv;
12293 }
12294 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
12295         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
12296         uint32_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
12297         return ret_val;
12298 }
12299
12300 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
12301         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
12302         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12303         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
12304         return (uint32_t)ret_conv;
12305 }
12306
12307 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
12308         LDKCVec_MonitorEventZ _res_constr;
12309         _res_constr.datalen = _res->arr_len;
12310         if (_res_constr.datalen > 0)
12311                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
12312         else
12313                 _res_constr.data = NULL;
12314         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12315         for (size_t o = 0; o < _res_constr.datalen; o++) {
12316                 uint32_t _res_conv_14 = _res_vals[o];
12317                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
12318                 CHECK_ACCESS(_res_conv_14_ptr);
12319                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
12320                 FREE((void*)_res_conv_14);
12321                 _res_constr.data[o] = _res_conv_14_conv;
12322         }
12323         CVec_MonitorEventZ_free(_res_constr);
12324 }
12325
12326 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
12327         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12328         CHECK_ACCESS(o_ptr);
12329         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
12330         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
12331         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12332         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
12333         uint32_t ret_ref = (uintptr_t)ret_copy;
12334         return ret_ref;
12335 }
12336
12337 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
12338         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12339         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
12340         uint32_t ret_ref = (uintptr_t)ret_copy;
12341         return ret_ref;
12342 }
12343
12344 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
12345         if ((_res & 1) != 0) return;
12346         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12347         CHECK_ACCESS(_res_ptr);
12348         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
12349         FREE((void*)_res);
12350         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
12351 }
12352
12353 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
12354         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12355         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
12356 uint32_t ret_ref = (uintptr_t)ret_copy;
12357         return ret_ref;
12358 }
12359 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
12360         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
12361         uint32_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
12362         return ret_val;
12363 }
12364
12365 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
12366         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
12367         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12368         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
12369         uint32_t ret_ref = (uintptr_t)ret_copy;
12370         return ret_ref;
12371 }
12372
12373 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
12374         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12375         CHECK_ACCESS(o_ptr);
12376         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
12377         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
12378         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12379         *ret_copy = COption_ClosureReasonZ_some(o_conv);
12380         uint32_t ret_ref = (uintptr_t)ret_copy;
12381         return ret_ref;
12382 }
12383
12384 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
12385         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12386         *ret_copy = COption_ClosureReasonZ_none();
12387         uint32_t ret_ref = (uintptr_t)ret_copy;
12388         return ret_ref;
12389 }
12390
12391 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
12392         if ((_res & 1) != 0) return;
12393         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12394         CHECK_ACCESS(_res_ptr);
12395         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12396         FREE((void*)_res);
12397         COption_ClosureReasonZ_free(_res_conv);
12398 }
12399
12400 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12401         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12402         *ret_copy = COption_ClosureReasonZ_clone(arg);
12403 uint32_t ret_ref = (uintptr_t)ret_copy;
12404         return ret_ref;
12405 }
12406 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
12407         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12408         uint32_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
12409         return ret_val;
12410 }
12411
12412 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
12413         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12414         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12415         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12416         uint32_t ret_ref = (uintptr_t)ret_copy;
12417         return ret_ref;
12418 }
12419
12420 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
12421         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12422         CHECK_ACCESS(o_ptr);
12423         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12424         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
12425         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12426         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12427         return (uint32_t)ret_conv;
12428 }
12429
12430 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
12431         LDKDecodeError e_conv;
12432         e_conv.inner = (void*)(e & (~1));
12433         e_conv.is_owned = (e & 1) || (e == 0);
12434         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12435         e_conv = DecodeError_clone(&e_conv);
12436         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12437         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12438         return (uint32_t)ret_conv;
12439 }
12440
12441 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
12442         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12443         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12444         return ret_val;
12445 }
12446
12447 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
12448         if ((_res & 1) != 0) return;
12449         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12450         CHECK_ACCESS(_res_ptr);
12451         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12452         FREE((void*)_res);
12453         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12454 }
12455
12456 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12457         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12458         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12459         return (uint32_t)ret_conv;
12460 }
12461 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
12462         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12463         uint32_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12464         return ret_val;
12465 }
12466
12467 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
12468         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12469         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12470         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12471         return (uint32_t)ret_conv;
12472 }
12473
12474 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
12475         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12476         CHECK_ACCESS(o_ptr);
12477         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12478         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
12479         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12480         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12481         uint32_t ret_ref = (uintptr_t)ret_copy;
12482         return ret_ref;
12483 }
12484
12485 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
12486         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12487         *ret_copy = COption_NetworkUpdateZ_none();
12488         uint32_t ret_ref = (uintptr_t)ret_copy;
12489         return ret_ref;
12490 }
12491
12492 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
12493         if ((_res & 1) != 0) return;
12494         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12495         CHECK_ACCESS(_res_ptr);
12496         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12497         FREE((void*)_res);
12498         COption_NetworkUpdateZ_free(_res_conv);
12499 }
12500
12501 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12502         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12503         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12504 uint32_t ret_ref = (uintptr_t)ret_copy;
12505         return ret_ref;
12506 }
12507 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
12508         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12509         uint32_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12510         return ret_val;
12511 }
12512
12513 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
12514         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12515         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12516         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12517         uint32_t ret_ref = (uintptr_t)ret_copy;
12518         return ret_ref;
12519 }
12520
12521 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
12522         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12523         _res_constr.datalen = _res->arr_len;
12524         if (_res_constr.datalen > 0)
12525                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12526         else
12527                 _res_constr.data = NULL;
12528         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12529         for (size_t b = 0; b < _res_constr.datalen; b++) {
12530                 uint32_t _res_conv_27 = _res_vals[b];
12531                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
12532                 CHECK_ACCESS(_res_conv_27_ptr);
12533                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12534                 FREE((void*)_res_conv_27);
12535                 _res_constr.data[b] = _res_conv_27_conv;
12536         }
12537         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12538 }
12539
12540 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
12541         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12542         CHECK_ACCESS(o_ptr);
12543         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12544         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
12545         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12546         *ret_copy = COption_EventZ_some(o_conv);
12547         uint32_t ret_ref = (uintptr_t)ret_copy;
12548         return ret_ref;
12549 }
12550
12551 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
12552         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12553         *ret_copy = COption_EventZ_none();
12554         uint32_t ret_ref = (uintptr_t)ret_copy;
12555         return ret_ref;
12556 }
12557
12558 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
12559         if ((_res & 1) != 0) return;
12560         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12561         CHECK_ACCESS(_res_ptr);
12562         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12563         FREE((void*)_res);
12564         COption_EventZ_free(_res_conv);
12565 }
12566
12567 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12568         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12569         *ret_copy = COption_EventZ_clone(arg);
12570 uint32_t ret_ref = (uintptr_t)ret_copy;
12571         return ret_ref;
12572 }
12573 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
12574         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12575         uint32_t ret_val = COption_EventZ_clone_ptr(arg_conv);
12576         return ret_val;
12577 }
12578
12579 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
12580         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12581         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12582         *ret_copy = COption_EventZ_clone(orig_conv);
12583         uint32_t ret_ref = (uintptr_t)ret_copy;
12584         return ret_ref;
12585 }
12586
12587 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
12588         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12589         CHECK_ACCESS(o_ptr);
12590         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12591         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
12592         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12593         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12594         return (uint32_t)ret_conv;
12595 }
12596
12597 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
12598         LDKDecodeError e_conv;
12599         e_conv.inner = (void*)(e & (~1));
12600         e_conv.is_owned = (e & 1) || (e == 0);
12601         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12602         e_conv = DecodeError_clone(&e_conv);
12603         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12604         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
12605         return (uint32_t)ret_conv;
12606 }
12607
12608 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
12609         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
12610         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
12611         return ret_val;
12612 }
12613
12614 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
12615         if ((_res & 1) != 0) return;
12616         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12617         CHECK_ACCESS(_res_ptr);
12618         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
12619         FREE((void*)_res);
12620         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
12621 }
12622
12623 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
12624         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12625         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
12626         return (uint32_t)ret_conv;
12627 }
12628 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12629         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
12630         uint32_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
12631         return ret_val;
12632 }
12633
12634 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
12635         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
12636         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12637         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
12638         return (uint32_t)ret_conv;
12639 }
12640
12641 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
12642         LDKCVec_MessageSendEventZ _res_constr;
12643         _res_constr.datalen = _res->arr_len;
12644         if (_res_constr.datalen > 0)
12645                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
12646         else
12647                 _res_constr.data = NULL;
12648         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12649         for (size_t s = 0; s < _res_constr.datalen; s++) {
12650                 uint32_t _res_conv_18 = _res_vals[s];
12651                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
12652                 CHECK_ACCESS(_res_conv_18_ptr);
12653                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
12654                 FREE((void*)_res_conv_18);
12655                 _res_constr.data[s] = _res_conv_18_conv;
12656         }
12657         CVec_MessageSendEventZ_free(_res_constr);
12658 }
12659
12660 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint32_t o) {
12661         LDKFixedPenaltyScorer o_conv;
12662         o_conv.inner = (void*)(o & (~1));
12663         o_conv.is_owned = (o & 1) || (o == 0);
12664         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12665         o_conv = FixedPenaltyScorer_clone(&o_conv);
12666         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12667         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
12668         return (uint32_t)ret_conv;
12669 }
12670
12671 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint32_t e) {
12672         LDKDecodeError e_conv;
12673         e_conv.inner = (void*)(e & (~1));
12674         e_conv.is_owned = (e & 1) || (e == 0);
12675         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12676         e_conv = DecodeError_clone(&e_conv);
12677         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12678         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
12679         return (uint32_t)ret_conv;
12680 }
12681
12682 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint32_t o) {
12683         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
12684         jboolean ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
12685         return ret_val;
12686 }
12687
12688 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint32_t _res) {
12689         if ((_res & 1) != 0) return;
12690         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12691         CHECK_ACCESS(_res_ptr);
12692         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
12693         FREE((void*)_res);
12694         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
12695 }
12696
12697 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
12698         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12699         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
12700         return (uint32_t)ret_conv;
12701 }
12702 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint32_t arg) {
12703         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
12704         uint32_t ret_val = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
12705         return ret_val;
12706 }
12707
12708 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint32_t orig) {
12709         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
12710         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12711         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
12712         return (uint32_t)ret_conv;
12713 }
12714
12715 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
12716         LDKScoringParameters o_conv;
12717         o_conv.inner = (void*)(o & (~1));
12718         o_conv.is_owned = (o & 1) || (o == 0);
12719         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12720         o_conv = ScoringParameters_clone(&o_conv);
12721         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12722         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
12723         return (uint32_t)ret_conv;
12724 }
12725
12726 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_err"))) TS_CResult_ScoringParametersDecodeErrorZ_err(uint32_t e) {
12727         LDKDecodeError e_conv;
12728         e_conv.inner = (void*)(e & (~1));
12729         e_conv.is_owned = (e & 1) || (e == 0);
12730         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12731         e_conv = DecodeError_clone(&e_conv);
12732         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12733         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
12734         return (uint32_t)ret_conv;
12735 }
12736
12737 jboolean  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_is_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
12738         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
12739         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
12740         return ret_val;
12741 }
12742
12743 void  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_free"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
12744         if ((_res & 1) != 0) return;
12745         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12746         CHECK_ACCESS(_res_ptr);
12747         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
12748         FREE((void*)_res);
12749         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
12750 }
12751
12752 static inline uintptr_t CResult_ScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
12753         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12754         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(arg);
12755         return (uint32_t)ret_conv;
12756 }
12757 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12758         LDKCResult_ScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
12759         uint32_t ret_val = CResult_ScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
12760         return ret_val;
12761 }
12762
12763 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone"))) TS_CResult_ScoringParametersDecodeErrorZ_clone(uint32_t orig) {
12764         LDKCResult_ScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(orig & ~1);
12765         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12766         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(orig_conv);
12767         return (uint32_t)ret_conv;
12768 }
12769
12770 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_ok"))) TS_CResult_ScorerDecodeErrorZ_ok(uint32_t o) {
12771         LDKScorer o_conv;
12772         o_conv.inner = (void*)(o & (~1));
12773         o_conv.is_owned = (o & 1) || (o == 0);
12774         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12775         // WARNING: we need a move here but no clone is available for LDKScorer
12776         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12777         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
12778         return (uint32_t)ret_conv;
12779 }
12780
12781 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_err"))) TS_CResult_ScorerDecodeErrorZ_err(uint32_t e) {
12782         LDKDecodeError e_conv;
12783         e_conv.inner = (void*)(e & (~1));
12784         e_conv.is_owned = (e & 1) || (e == 0);
12785         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12786         e_conv = DecodeError_clone(&e_conv);
12787         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12788         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
12789         return (uint32_t)ret_conv;
12790 }
12791
12792 jboolean  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_is_ok"))) TS_CResult_ScorerDecodeErrorZ_is_ok(uint32_t o) {
12793         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
12794         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
12795         return ret_val;
12796 }
12797
12798 void  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_free"))) TS_CResult_ScorerDecodeErrorZ_free(uint32_t _res) {
12799         if ((_res & 1) != 0) return;
12800         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12801         CHECK_ACCESS(_res_ptr);
12802         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
12803         FREE((void*)_res);
12804         CResult_ScorerDecodeErrorZ_free(_res_conv);
12805 }
12806
12807 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_ok(uint32_t o) {
12808         LDKProbabilisticScorer o_conv;
12809         o_conv.inner = (void*)(o & (~1));
12810         o_conv.is_owned = (o & 1) || (o == 0);
12811         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12812         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
12813         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
12814         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
12815         return (uint32_t)ret_conv;
12816 }
12817
12818 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_err(uint32_t e) {
12819         LDKDecodeError e_conv;
12820         e_conv.inner = (void*)(e & (~1));
12821         e_conv.is_owned = (e & 1) || (e == 0);
12822         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12823         e_conv = DecodeError_clone(&e_conv);
12824         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
12825         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
12826         return (uint32_t)ret_conv;
12827 }
12828
12829 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(uint32_t o) {
12830         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
12831         jboolean ret_val = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
12832         return ret_val;
12833 }
12834
12835 void  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_free"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_free(uint32_t _res) {
12836         if ((_res & 1) != 0) return;
12837         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12838         CHECK_ACCESS(_res_ptr);
12839         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
12840         FREE((void*)_res);
12841         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
12842 }
12843
12844 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
12845         LDKInitFeatures o_conv;
12846         o_conv.inner = (void*)(o & (~1));
12847         o_conv.is_owned = (o & 1) || (o == 0);
12848         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12849         o_conv = InitFeatures_clone(&o_conv);
12850         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12851         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
12852         return (uint32_t)ret_conv;
12853 }
12854
12855 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
12856         LDKDecodeError e_conv;
12857         e_conv.inner = (void*)(e & (~1));
12858         e_conv.is_owned = (e & 1) || (e == 0);
12859         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12860         e_conv = DecodeError_clone(&e_conv);
12861         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12862         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
12863         return (uint32_t)ret_conv;
12864 }
12865
12866 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12867         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
12868         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
12869         return ret_val;
12870 }
12871
12872 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
12873         if ((_res & 1) != 0) return;
12874         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12875         CHECK_ACCESS(_res_ptr);
12876         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
12877         FREE((void*)_res);
12878         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
12879 }
12880
12881 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
12882         LDKChannelFeatures o_conv;
12883         o_conv.inner = (void*)(o & (~1));
12884         o_conv.is_owned = (o & 1) || (o == 0);
12885         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12886         o_conv = ChannelFeatures_clone(&o_conv);
12887         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12888         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
12889         return (uint32_t)ret_conv;
12890 }
12891
12892 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
12893         LDKDecodeError e_conv;
12894         e_conv.inner = (void*)(e & (~1));
12895         e_conv.is_owned = (e & 1) || (e == 0);
12896         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12897         e_conv = DecodeError_clone(&e_conv);
12898         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12899         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
12900         return (uint32_t)ret_conv;
12901 }
12902
12903 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12904         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
12905         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
12906         return ret_val;
12907 }
12908
12909 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
12910         if ((_res & 1) != 0) return;
12911         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12912         CHECK_ACCESS(_res_ptr);
12913         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
12914         FREE((void*)_res);
12915         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
12916 }
12917
12918 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
12919         LDKNodeFeatures o_conv;
12920         o_conv.inner = (void*)(o & (~1));
12921         o_conv.is_owned = (o & 1) || (o == 0);
12922         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12923         o_conv = NodeFeatures_clone(&o_conv);
12924         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12925         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
12926         return (uint32_t)ret_conv;
12927 }
12928
12929 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
12930         LDKDecodeError e_conv;
12931         e_conv.inner = (void*)(e & (~1));
12932         e_conv.is_owned = (e & 1) || (e == 0);
12933         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12934         e_conv = DecodeError_clone(&e_conv);
12935         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12936         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
12937         return (uint32_t)ret_conv;
12938 }
12939
12940 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12941         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
12942         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
12943         return ret_val;
12944 }
12945
12946 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
12947         if ((_res & 1) != 0) return;
12948         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12949         CHECK_ACCESS(_res_ptr);
12950         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
12951         FREE((void*)_res);
12952         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
12953 }
12954
12955 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
12956         LDKInvoiceFeatures o_conv;
12957         o_conv.inner = (void*)(o & (~1));
12958         o_conv.is_owned = (o & 1) || (o == 0);
12959         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12960         o_conv = InvoiceFeatures_clone(&o_conv);
12961         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12962         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
12963         return (uint32_t)ret_conv;
12964 }
12965
12966 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
12967         LDKDecodeError e_conv;
12968         e_conv.inner = (void*)(e & (~1));
12969         e_conv.is_owned = (e & 1) || (e == 0);
12970         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12971         e_conv = DecodeError_clone(&e_conv);
12972         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12973         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
12974         return (uint32_t)ret_conv;
12975 }
12976
12977 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12978         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
12979         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
12980         return ret_val;
12981 }
12982
12983 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
12984         if ((_res & 1) != 0) return;
12985         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12986         CHECK_ACCESS(_res_ptr);
12987         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
12988         FREE((void*)_res);
12989         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
12990 }
12991
12992 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
12993         LDKChannelTypeFeatures o_conv;
12994         o_conv.inner = (void*)(o & (~1));
12995         o_conv.is_owned = (o & 1) || (o == 0);
12996         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12997         o_conv = ChannelTypeFeatures_clone(&o_conv);
12998         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
12999         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
13000         return (uint32_t)ret_conv;
13001 }
13002
13003 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
13004         LDKDecodeError e_conv;
13005         e_conv.inner = (void*)(e & (~1));
13006         e_conv.is_owned = (e & 1) || (e == 0);
13007         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13008         e_conv = DecodeError_clone(&e_conv);
13009         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13010         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
13011         return (uint32_t)ret_conv;
13012 }
13013
13014 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13015         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
13016         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
13017         return ret_val;
13018 }
13019
13020 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
13021         if ((_res & 1) != 0) return;
13022         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13023         CHECK_ACCESS(_res_ptr);
13024         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
13025         FREE((void*)_res);
13026         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
13027 }
13028
13029 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13030         LDKDelayedPaymentOutputDescriptor o_conv;
13031         o_conv.inner = (void*)(o & (~1));
13032         o_conv.is_owned = (o & 1) || (o == 0);
13033         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13034         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
13035         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13036         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13037         return (uint32_t)ret_conv;
13038 }
13039
13040 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13041         LDKDecodeError e_conv;
13042         e_conv.inner = (void*)(e & (~1));
13043         e_conv.is_owned = (e & 1) || (e == 0);
13044         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13045         e_conv = DecodeError_clone(&e_conv);
13046         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13047         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13048         return (uint32_t)ret_conv;
13049 }
13050
13051 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13052         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13053         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13054         return ret_val;
13055 }
13056
13057 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13058         if ((_res & 1) != 0) return;
13059         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13060         CHECK_ACCESS(_res_ptr);
13061         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13062         FREE((void*)_res);
13063         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13064 }
13065
13066 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13067         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13068         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13069         return (uint32_t)ret_conv;
13070 }
13071 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13072         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13073         uint32_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13074         return ret_val;
13075 }
13076
13077 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13078         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13079         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13080         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13081         return (uint32_t)ret_conv;
13082 }
13083
13084 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13085         LDKStaticPaymentOutputDescriptor o_conv;
13086         o_conv.inner = (void*)(o & (~1));
13087         o_conv.is_owned = (o & 1) || (o == 0);
13088         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13089         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
13090         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13091         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13092         return (uint32_t)ret_conv;
13093 }
13094
13095 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13096         LDKDecodeError e_conv;
13097         e_conv.inner = (void*)(e & (~1));
13098         e_conv.is_owned = (e & 1) || (e == 0);
13099         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13100         e_conv = DecodeError_clone(&e_conv);
13101         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13102         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13103         return (uint32_t)ret_conv;
13104 }
13105
13106 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13107         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13108         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13109         return ret_val;
13110 }
13111
13112 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13113         if ((_res & 1) != 0) return;
13114         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13115         CHECK_ACCESS(_res_ptr);
13116         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13117         FREE((void*)_res);
13118         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13119 }
13120
13121 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13122         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13123         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13124         return (uint32_t)ret_conv;
13125 }
13126 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13127         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13128         uint32_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13129         return ret_val;
13130 }
13131
13132 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13133         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13134         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13135         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13136         return (uint32_t)ret_conv;
13137 }
13138
13139 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13140         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13141         CHECK_ACCESS(o_ptr);
13142         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
13143         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
13144         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13145         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
13146         return (uint32_t)ret_conv;
13147 }
13148
13149 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13150         LDKDecodeError e_conv;
13151         e_conv.inner = (void*)(e & (~1));
13152         e_conv.is_owned = (e & 1) || (e == 0);
13153         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13154         e_conv = DecodeError_clone(&e_conv);
13155         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13156         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
13157         return (uint32_t)ret_conv;
13158 }
13159
13160 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13161         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
13162         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13163         return ret_val;
13164 }
13165
13166 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13167         if ((_res & 1) != 0) return;
13168         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13169         CHECK_ACCESS(_res_ptr);
13170         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
13171         FREE((void*)_res);
13172         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
13173 }
13174
13175 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13176         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13177         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
13178         return (uint32_t)ret_conv;
13179 }
13180 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13181         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
13182         uint32_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13183         return ret_val;
13184 }
13185
13186 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13187         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
13188         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13189         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
13190         return (uint32_t)ret_conv;
13191 }
13192
13193 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
13194         LDKCVec_PaymentPreimageZ _res_constr;
13195         _res_constr.datalen = _res->arr_len;
13196         if (_res_constr.datalen > 0)
13197                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
13198         else
13199                 _res_constr.data = NULL;
13200         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13201         for (size_t m = 0; m < _res_constr.datalen; m++) {
13202                 int8_tArray _res_conv_12 = _res_vals[m];
13203                 LDKThirtyTwoBytes _res_conv_12_ref;
13204                 CHECK(_res_conv_12->arr_len == 32);
13205                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
13206                 _res_constr.data[m] = _res_conv_12_ref;
13207         }
13208         CVec_PaymentPreimageZ_free(_res_constr);
13209 }
13210
13211 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
13212         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13213         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
13214         return ((uint32_t)ret_conv);
13215 }
13216 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
13217         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
13218         uint32_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
13219         return ret_val;
13220 }
13221
13222 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
13223         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
13224         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13225         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
13226         return ((uint32_t)ret_conv);
13227 }
13228
13229 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
13230         LDKSignature a_ref;
13231         CHECK(a->arr_len == 64);
13232         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13233         LDKCVec_SignatureZ b_constr;
13234         b_constr.datalen = b->arr_len;
13235         if (b_constr.datalen > 0)
13236                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13237         else
13238                 b_constr.data = NULL;
13239         int8_tArray* b_vals = (void*) b->elems /* XXX b leaks */;
13240         for (size_t m = 0; m < b_constr.datalen; m++) {
13241                 int8_tArray b_conv_12 = b_vals[m];
13242                 LDKSignature b_conv_12_ref;
13243                 CHECK(b_conv_12->arr_len == 64);
13244                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
13245                 b_constr.data[m] = b_conv_12_ref;
13246         }
13247         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13248         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
13249         return ((uint32_t)ret_conv);
13250 }
13251
13252 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
13253         if ((_res & 1) != 0) return;
13254         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13255         CHECK_ACCESS(_res_ptr);
13256         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
13257         FREE((void*)_res);
13258         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
13259 }
13260
13261 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
13262         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13263         CHECK_ACCESS(o_ptr);
13264         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
13265         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
13266         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13267         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
13268         return (uint32_t)ret_conv;
13269 }
13270
13271 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
13272         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13273         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
13274         return (uint32_t)ret_conv;
13275 }
13276
13277 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
13278         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
13279         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
13280         return ret_val;
13281 }
13282
13283 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
13284         if ((_res & 1) != 0) return;
13285         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13286         CHECK_ACCESS(_res_ptr);
13287         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
13288         FREE((void*)_res);
13289         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
13290 }
13291
13292 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
13293         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13294         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
13295         return (uint32_t)ret_conv;
13296 }
13297 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
13298         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
13299         uint32_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
13300         return ret_val;
13301 }
13302
13303 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
13304         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
13305         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13306         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
13307         return (uint32_t)ret_conv;
13308 }
13309
13310 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
13311         LDKSignature o_ref;
13312         CHECK(o->arr_len == 64);
13313         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
13314         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13315         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
13316         return (uint32_t)ret_conv;
13317 }
13318
13319 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
13320         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13321         *ret_conv = CResult_SignatureNoneZ_err();
13322         return (uint32_t)ret_conv;
13323 }
13324
13325 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
13326         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
13327         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
13328         return ret_val;
13329 }
13330
13331 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
13332         if ((_res & 1) != 0) return;
13333         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13334         CHECK_ACCESS(_res_ptr);
13335         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
13336         FREE((void*)_res);
13337         CResult_SignatureNoneZ_free(_res_conv);
13338 }
13339
13340 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
13341         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13342         *ret_conv = CResult_SignatureNoneZ_clone(arg);
13343         return (uint32_t)ret_conv;
13344 }
13345 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
13346         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
13347         uint32_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
13348         return ret_val;
13349 }
13350
13351 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
13352         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
13353         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13354         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
13355         return (uint32_t)ret_conv;
13356 }
13357
13358 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
13359         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13360         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
13361         return ((uint32_t)ret_conv);
13362 }
13363 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint32_t arg) {
13364         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
13365         uint32_t ret_val = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
13366         return ret_val;
13367 }
13368
13369 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint32_t orig) {
13370         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
13371         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13372         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
13373         return ((uint32_t)ret_conv);
13374 }
13375
13376 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
13377         LDKSignature a_ref;
13378         CHECK(a->arr_len == 64);
13379         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13380         LDKSignature b_ref;
13381         CHECK(b->arr_len == 64);
13382         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
13383         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13384         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
13385         return ((uint32_t)ret_conv);
13386 }
13387
13388 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint32_t _res) {
13389         if ((_res & 1) != 0) return;
13390         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13391         CHECK_ACCESS(_res_ptr);
13392         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
13393         FREE((void*)_res);
13394         C2Tuple_SignatureSignatureZ_free(_res_conv);
13395 }
13396
13397 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint32_t o) {
13398         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13399         CHECK_ACCESS(o_ptr);
13400         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
13401         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
13402         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13403         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
13404         return (uint32_t)ret_conv;
13405 }
13406
13407 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
13408         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13409         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
13410         return (uint32_t)ret_conv;
13411 }
13412
13413 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint32_t o) {
13414         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
13415         jboolean ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
13416         return ret_val;
13417 }
13418
13419 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint32_t _res) {
13420         if ((_res & 1) != 0) return;
13421         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13422         CHECK_ACCESS(_res_ptr);
13423         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
13424         FREE((void*)_res);
13425         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
13426 }
13427
13428 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
13429         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13430         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
13431         return (uint32_t)ret_conv;
13432 }
13433 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint32_t arg) {
13434         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
13435         uint32_t ret_val = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
13436         return ret_val;
13437 }
13438
13439 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint32_t orig) {
13440         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
13441         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13442         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
13443         return (uint32_t)ret_conv;
13444 }
13445
13446 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
13447         LDKSecretKey o_ref;
13448         CHECK(o->arr_len == 32);
13449         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
13450         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13451         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
13452         return (uint32_t)ret_conv;
13453 }
13454
13455 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
13456         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13457         *ret_conv = CResult_SecretKeyNoneZ_err();
13458         return (uint32_t)ret_conv;
13459 }
13460
13461 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint32_t o) {
13462         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
13463         jboolean ret_val = CResult_SecretKeyNoneZ_is_ok(o_conv);
13464         return ret_val;
13465 }
13466
13467 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint32_t _res) {
13468         if ((_res & 1) != 0) return;
13469         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13470         CHECK_ACCESS(_res_ptr);
13471         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
13472         FREE((void*)_res);
13473         CResult_SecretKeyNoneZ_free(_res_conv);
13474 }
13475
13476 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
13477         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13478         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
13479         return (uint32_t)ret_conv;
13480 }
13481 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint32_t arg) {
13482         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
13483         uint32_t ret_val = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
13484         return ret_val;
13485 }
13486
13487 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint32_t orig) {
13488         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
13489         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13490         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
13491         return (uint32_t)ret_conv;
13492 }
13493
13494 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
13495         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13496         CHECK_ACCESS(o_ptr);
13497         LDKSign o_conv = *(LDKSign*)(o_ptr);
13498         if (o_conv.free == LDKSign_JCalls_free) {
13499                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13500                 LDKSign_JCalls_cloned(&o_conv);
13501         }
13502         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13503         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
13504         return (uint32_t)ret_conv;
13505 }
13506
13507 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
13508         LDKDecodeError e_conv;
13509         e_conv.inner = (void*)(e & (~1));
13510         e_conv.is_owned = (e & 1) || (e == 0);
13511         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13512         e_conv = DecodeError_clone(&e_conv);
13513         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13514         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
13515         return (uint32_t)ret_conv;
13516 }
13517
13518 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
13519         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
13520         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
13521         return ret_val;
13522 }
13523
13524 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
13525         if ((_res & 1) != 0) return;
13526         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13527         CHECK_ACCESS(_res_ptr);
13528         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
13529         FREE((void*)_res);
13530         CResult_SignDecodeErrorZ_free(_res_conv);
13531 }
13532
13533 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
13534         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13535         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
13536         return (uint32_t)ret_conv;
13537 }
13538 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
13539         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
13540         uint32_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
13541         return ret_val;
13542 }
13543
13544 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
13545         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
13546         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13547         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
13548         return (uint32_t)ret_conv;
13549 }
13550
13551 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
13552         LDKCVec_u5Z _res_constr;
13553         _res_constr.datalen = _res->arr_len;
13554         if (_res_constr.datalen > 0)
13555                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
13556         else
13557                 _res_constr.data = NULL;
13558         int8_t* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13559         for (size_t h = 0; h < _res_constr.datalen; h++) {
13560                 int8_t _res_conv_7 = _res_vals[h];
13561                 
13562                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
13563         }
13564         CVec_u5Z_free(_res_constr);
13565 }
13566
13567 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
13568         LDKRecoverableSignature o_ref;
13569         CHECK(o->arr_len == 68);
13570         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
13571         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13572         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
13573         return (uint32_t)ret_conv;
13574 }
13575
13576 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
13577         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13578         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
13579         return (uint32_t)ret_conv;
13580 }
13581
13582 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
13583         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
13584         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
13585         return ret_val;
13586 }
13587
13588 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
13589         if ((_res & 1) != 0) return;
13590         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13591         CHECK_ACCESS(_res_ptr);
13592         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
13593         FREE((void*)_res);
13594         CResult_RecoverableSignatureNoneZ_free(_res_conv);
13595 }
13596
13597 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
13598         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13599         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
13600         return (uint32_t)ret_conv;
13601 }
13602 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
13603         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
13604         uint32_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
13605         return ret_val;
13606 }
13607
13608 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
13609         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
13610         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13611         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
13612         return (uint32_t)ret_conv;
13613 }
13614
13615 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
13616         LDKCVec_u8Z _res_ref;
13617         _res_ref.datalen = _res->arr_len;
13618         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
13619         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
13620         CVec_u8Z_free(_res_ref);
13621 }
13622
13623 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
13624         LDKCVec_CVec_u8ZZ _res_constr;
13625         _res_constr.datalen = _res->arr_len;
13626         if (_res_constr.datalen > 0)
13627                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13628         else
13629                 _res_constr.data = NULL;
13630         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13631         for (size_t m = 0; m < _res_constr.datalen; m++) {
13632                 int8_tArray _res_conv_12 = _res_vals[m];
13633                 LDKCVec_u8Z _res_conv_12_ref;
13634                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
13635                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13636                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
13637                 _res_constr.data[m] = _res_conv_12_ref;
13638         }
13639         CVec_CVec_u8ZZ_free(_res_constr);
13640 }
13641
13642 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
13643         LDKCVec_CVec_u8ZZ o_constr;
13644         o_constr.datalen = o->arr_len;
13645         if (o_constr.datalen > 0)
13646                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13647         else
13648                 o_constr.data = NULL;
13649         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
13650         for (size_t m = 0; m < o_constr.datalen; m++) {
13651                 int8_tArray o_conv_12 = o_vals[m];
13652                 LDKCVec_u8Z o_conv_12_ref;
13653                 o_conv_12_ref.datalen = o_conv_12->arr_len;
13654                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13655                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
13656                 o_constr.data[m] = o_conv_12_ref;
13657         }
13658         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13659         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
13660         return (uint32_t)ret_conv;
13661 }
13662
13663 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
13664         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13665         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
13666         return (uint32_t)ret_conv;
13667 }
13668
13669 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
13670         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
13671         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
13672         return ret_val;
13673 }
13674
13675 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
13676         if ((_res & 1) != 0) return;
13677         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13678         CHECK_ACCESS(_res_ptr);
13679         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
13680         FREE((void*)_res);
13681         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
13682 }
13683
13684 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
13685         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13686         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
13687         return (uint32_t)ret_conv;
13688 }
13689 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
13690         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
13691         uint32_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
13692         return ret_val;
13693 }
13694
13695 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
13696         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
13697         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13698         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
13699         return (uint32_t)ret_conv;
13700 }
13701
13702 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
13703         LDKInMemorySigner o_conv;
13704         o_conv.inner = (void*)(o & (~1));
13705         o_conv.is_owned = (o & 1) || (o == 0);
13706         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13707         o_conv = InMemorySigner_clone(&o_conv);
13708         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13709         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
13710         return (uint32_t)ret_conv;
13711 }
13712
13713 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
13714         LDKDecodeError e_conv;
13715         e_conv.inner = (void*)(e & (~1));
13716         e_conv.is_owned = (e & 1) || (e == 0);
13717         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13718         e_conv = DecodeError_clone(&e_conv);
13719         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13720         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
13721         return (uint32_t)ret_conv;
13722 }
13723
13724 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
13725         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
13726         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
13727         return ret_val;
13728 }
13729
13730 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
13731         if ((_res & 1) != 0) return;
13732         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13733         CHECK_ACCESS(_res_ptr);
13734         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
13735         FREE((void*)_res);
13736         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
13737 }
13738
13739 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
13740         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13741         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
13742         return (uint32_t)ret_conv;
13743 }
13744 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
13745         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
13746         uint32_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
13747         return ret_val;
13748 }
13749
13750 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
13751         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
13752         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13753         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
13754         return (uint32_t)ret_conv;
13755 }
13756
13757 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
13758         LDKCVec_TxOutZ _res_constr;
13759         _res_constr.datalen = _res->arr_len;
13760         if (_res_constr.datalen > 0)
13761                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
13762         else
13763                 _res_constr.data = NULL;
13764         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13765         for (size_t h = 0; h < _res_constr.datalen; h++) {
13766                 uint32_t _res_conv_7 = _res_vals[h];
13767                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
13768                 CHECK_ACCESS(_res_conv_7_ptr);
13769                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
13770                 FREE((void*)_res_conv_7);
13771                 _res_constr.data[h] = _res_conv_7_conv;
13772         }
13773         CVec_TxOutZ_free(_res_constr);
13774 }
13775
13776 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
13777         LDKTransaction o_ref;
13778         o_ref.datalen = o->arr_len;
13779         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
13780         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
13781         o_ref.data_is_owned = true;
13782         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13783         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
13784         return (uint32_t)ret_conv;
13785 }
13786
13787 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
13788         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13789         *ret_conv = CResult_TransactionNoneZ_err();
13790         return (uint32_t)ret_conv;
13791 }
13792
13793 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
13794         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
13795         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
13796         return ret_val;
13797 }
13798
13799 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
13800         if ((_res & 1) != 0) return;
13801         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13802         CHECK_ACCESS(_res_ptr);
13803         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
13804         FREE((void*)_res);
13805         CResult_TransactionNoneZ_free(_res_conv);
13806 }
13807
13808 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
13809         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13810         *ret_conv = CResult_TransactionNoneZ_clone(arg);
13811         return (uint32_t)ret_conv;
13812 }
13813 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
13814         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
13815         uint32_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
13816         return ret_val;
13817 }
13818
13819 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
13820         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
13821         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13822         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
13823         return (uint32_t)ret_conv;
13824 }
13825
13826 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
13827         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13828         *ret_copy = COption_u16Z_some(o);
13829         uint32_t ret_ref = (uintptr_t)ret_copy;
13830         return ret_ref;
13831 }
13832
13833 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
13834         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13835         *ret_copy = COption_u16Z_none();
13836         uint32_t ret_ref = (uintptr_t)ret_copy;
13837         return ret_ref;
13838 }
13839
13840 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
13841         if ((_res & 1) != 0) return;
13842         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13843         CHECK_ACCESS(_res_ptr);
13844         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
13845         FREE((void*)_res);
13846         COption_u16Z_free(_res_conv);
13847 }
13848
13849 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
13850         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13851         *ret_copy = COption_u16Z_clone(arg);
13852 uint32_t ret_ref = (uintptr_t)ret_copy;
13853         return ret_ref;
13854 }
13855 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
13856         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
13857         uint32_t ret_val = COption_u16Z_clone_ptr(arg_conv);
13858         return ret_val;
13859 }
13860
13861 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
13862         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
13863         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13864         *ret_copy = COption_u16Z_clone(orig_conv);
13865         uint32_t ret_ref = (uintptr_t)ret_copy;
13866         return ret_ref;
13867 }
13868
13869 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
13870         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13871         *ret_conv = CResult_NoneAPIErrorZ_ok();
13872         return (uint32_t)ret_conv;
13873 }
13874
13875 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
13876         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13877         CHECK_ACCESS(e_ptr);
13878         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13879         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
13880         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13881         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
13882         return (uint32_t)ret_conv;
13883 }
13884
13885 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
13886         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
13887         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
13888         return ret_val;
13889 }
13890
13891 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
13892         if ((_res & 1) != 0) return;
13893         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13894         CHECK_ACCESS(_res_ptr);
13895         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
13896         FREE((void*)_res);
13897         CResult_NoneAPIErrorZ_free(_res_conv);
13898 }
13899
13900 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
13901         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13902         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
13903         return (uint32_t)ret_conv;
13904 }
13905 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
13906         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
13907         uint32_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
13908         return ret_val;
13909 }
13910
13911 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
13912         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
13913         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13914         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
13915         return (uint32_t)ret_conv;
13916 }
13917
13918 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
13919         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
13920         _res_constr.datalen = _res->arr_len;
13921         if (_res_constr.datalen > 0)
13922                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
13923         else
13924                 _res_constr.data = NULL;
13925         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13926         for (size_t w = 0; w < _res_constr.datalen; w++) {
13927                 uint32_t _res_conv_22 = _res_vals[w];
13928                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
13929                 CHECK_ACCESS(_res_conv_22_ptr);
13930                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
13931                 FREE((void*)_res_conv_22);
13932                 _res_constr.data[w] = _res_conv_22_conv;
13933         }
13934         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
13935 }
13936
13937 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
13938         LDKCVec_APIErrorZ _res_constr;
13939         _res_constr.datalen = _res->arr_len;
13940         if (_res_constr.datalen > 0)
13941                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
13942         else
13943                 _res_constr.data = NULL;
13944         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13945         for (size_t k = 0; k < _res_constr.datalen; k++) {
13946                 uint32_t _res_conv_10 = _res_vals[k];
13947                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
13948                 CHECK_ACCESS(_res_conv_10_ptr);
13949                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
13950                 FREE((void*)_res_conv_10);
13951                 _res_constr.data[k] = _res_conv_10_conv;
13952         }
13953         CVec_APIErrorZ_free(_res_constr);
13954 }
13955
13956 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
13957         LDKThirtyTwoBytes o_ref;
13958         CHECK(o->arr_len == 32);
13959         memcpy(o_ref.data, o->elems, 32); FREE(o);
13960         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13961         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
13962         return (uint32_t)ret_conv;
13963 }
13964
13965 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
13966         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13967         CHECK_ACCESS(e_ptr);
13968         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13969         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
13970         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13971         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
13972         return (uint32_t)ret_conv;
13973 }
13974
13975 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
13976         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
13977         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
13978         return ret_val;
13979 }
13980
13981 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
13982         if ((_res & 1) != 0) return;
13983         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13984         CHECK_ACCESS(_res_ptr);
13985         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
13986         FREE((void*)_res);
13987         CResult__u832APIErrorZ_free(_res_conv);
13988 }
13989
13990 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
13991         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
13992         *ret_conv = CResult__u832APIErrorZ_clone(arg);
13993         return (uint32_t)ret_conv;
13994 }
13995 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
13996         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
13997         uint32_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
13998         return ret_val;
13999 }
14000
14001 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
14002         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
14003         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14004         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
14005         return (uint32_t)ret_conv;
14006 }
14007
14008 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
14009         LDKThirtyTwoBytes o_ref;
14010         CHECK(o->arr_len == 32);
14011         memcpy(o_ref.data, o->elems, 32); FREE(o);
14012         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14013         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
14014         return (uint32_t)ret_conv;
14015 }
14016
14017 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
14018         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14019         CHECK_ACCESS(e_ptr);
14020         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14021         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14022         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14023         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
14024         return (uint32_t)ret_conv;
14025 }
14026
14027 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
14028         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
14029         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
14030         return ret_val;
14031 }
14032
14033 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
14034         if ((_res & 1) != 0) return;
14035         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14036         CHECK_ACCESS(_res_ptr);
14037         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
14038         FREE((void*)_res);
14039         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
14040 }
14041
14042 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
14043         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14044         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
14045         return (uint32_t)ret_conv;
14046 }
14047 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
14048         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
14049         uint32_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
14050         return ret_val;
14051 }
14052
14053 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
14054         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
14055         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14056         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
14057         return (uint32_t)ret_conv;
14058 }
14059
14060 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
14061         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14062         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
14063         return (uint32_t)ret_conv;
14064 }
14065
14066 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
14067         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14068         CHECK_ACCESS(e_ptr);
14069         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14070         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14071         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14072         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
14073         return (uint32_t)ret_conv;
14074 }
14075
14076 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
14077         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
14078         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
14079         return ret_val;
14080 }
14081
14082 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
14083         if ((_res & 1) != 0) return;
14084         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14085         CHECK_ACCESS(_res_ptr);
14086         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
14087         FREE((void*)_res);
14088         CResult_NonePaymentSendFailureZ_free(_res_conv);
14089 }
14090
14091 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
14092         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14093         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
14094         return (uint32_t)ret_conv;
14095 }
14096 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
14097         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
14098         uint32_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
14099         return ret_val;
14100 }
14101
14102 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
14103         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
14104         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14105         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
14106         return (uint32_t)ret_conv;
14107 }
14108
14109 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
14110         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14111         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
14112         return ((uint32_t)ret_conv);
14113 }
14114 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
14115         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
14116         uint32_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
14117         return ret_val;
14118 }
14119
14120 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
14121         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
14122         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14123         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
14124         return ((uint32_t)ret_conv);
14125 }
14126
14127 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
14128         LDKThirtyTwoBytes a_ref;
14129         CHECK(a->arr_len == 32);
14130         memcpy(a_ref.data, a->elems, 32); FREE(a);
14131         LDKThirtyTwoBytes b_ref;
14132         CHECK(b->arr_len == 32);
14133         memcpy(b_ref.data, b->elems, 32); FREE(b);
14134         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14135         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
14136         return ((uint32_t)ret_conv);
14137 }
14138
14139 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
14140         if ((_res & 1) != 0) return;
14141         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14142         CHECK_ACCESS(_res_ptr);
14143         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
14144         FREE((void*)_res);
14145         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
14146 }
14147
14148 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
14149         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14150         CHECK_ACCESS(o_ptr);
14151         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
14152         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
14153         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14154         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
14155         return (uint32_t)ret_conv;
14156 }
14157
14158 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
14159         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14160         CHECK_ACCESS(e_ptr);
14161         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14162         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14163         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14164         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
14165         return (uint32_t)ret_conv;
14166 }
14167
14168 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
14169         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
14170         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
14171         return ret_val;
14172 }
14173
14174 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
14175         if ((_res & 1) != 0) return;
14176         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14177         CHECK_ACCESS(_res_ptr);
14178         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
14179         FREE((void*)_res);
14180         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
14181 }
14182
14183 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
14184         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14185         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
14186         return (uint32_t)ret_conv;
14187 }
14188 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
14189         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
14190         uint32_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
14191         return ret_val;
14192 }
14193
14194 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
14195         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
14196         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14197         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
14198         return (uint32_t)ret_conv;
14199 }
14200
14201 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
14202         LDKCVec_NetAddressZ _res_constr;
14203         _res_constr.datalen = _res->arr_len;
14204         if (_res_constr.datalen > 0)
14205                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14206         else
14207                 _res_constr.data = NULL;
14208         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14209         for (size_t m = 0; m < _res_constr.datalen; m++) {
14210                 uint32_t _res_conv_12 = _res_vals[m];
14211                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
14212                 CHECK_ACCESS(_res_conv_12_ptr);
14213                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14214                 FREE((void*)_res_conv_12);
14215                 _res_constr.data[m] = _res_conv_12_conv;
14216         }
14217         CVec_NetAddressZ_free(_res_constr);
14218 }
14219
14220 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
14221         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14222         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
14223         return ((uint32_t)ret_conv);
14224 }
14225 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
14226         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
14227         uint32_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
14228         return ret_val;
14229 }
14230
14231 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
14232         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
14233         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14234         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
14235         return ((uint32_t)ret_conv);
14236 }
14237
14238 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
14239         LDKThirtyTwoBytes a_ref;
14240         CHECK(a->arr_len == 32);
14241         memcpy(a_ref.data, a->elems, 32); FREE(a);
14242         LDKThirtyTwoBytes b_ref;
14243         CHECK(b->arr_len == 32);
14244         memcpy(b_ref.data, b->elems, 32); FREE(b);
14245         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14246         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
14247         return ((uint32_t)ret_conv);
14248 }
14249
14250 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
14251         if ((_res & 1) != 0) return;
14252         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14253         CHECK_ACCESS(_res_ptr);
14254         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
14255         FREE((void*)_res);
14256         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
14257 }
14258
14259 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
14260         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14261         CHECK_ACCESS(o_ptr);
14262         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14263         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14264         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14265         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
14266         return (uint32_t)ret_conv;
14267 }
14268
14269 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
14270         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14271         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
14272         return (uint32_t)ret_conv;
14273 }
14274
14275 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
14276         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
14277         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
14278         return ret_val;
14279 }
14280
14281 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
14282         if ((_res & 1) != 0) return;
14283         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14284         CHECK_ACCESS(_res_ptr);
14285         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
14286         FREE((void*)_res);
14287         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
14288 }
14289
14290 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
14291         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14292         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
14293         return (uint32_t)ret_conv;
14294 }
14295 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
14296         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
14297         uint32_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
14298         return ret_val;
14299 }
14300
14301 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
14302         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
14303         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14304         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
14305         return (uint32_t)ret_conv;
14306 }
14307
14308 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
14309         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14310         CHECK_ACCESS(o_ptr);
14311         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14312         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14313         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14314         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
14315         return (uint32_t)ret_conv;
14316 }
14317
14318 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
14319         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14320         CHECK_ACCESS(e_ptr);
14321         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14322         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14323         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14324         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
14325         return (uint32_t)ret_conv;
14326 }
14327
14328 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
14329         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
14330         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
14331         return ret_val;
14332 }
14333
14334 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
14335         if ((_res & 1) != 0) return;
14336         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14337         CHECK_ACCESS(_res_ptr);
14338         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
14339         FREE((void*)_res);
14340         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
14341 }
14342
14343 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
14344         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14345         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
14346         return (uint32_t)ret_conv;
14347 }
14348 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
14349         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
14350         uint32_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
14351         return ret_val;
14352 }
14353
14354 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
14355         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
14356         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14357         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
14358         return (uint32_t)ret_conv;
14359 }
14360
14361 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
14362         LDKThirtyTwoBytes o_ref;
14363         CHECK(o->arr_len == 32);
14364         memcpy(o_ref.data, o->elems, 32); FREE(o);
14365         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14366         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
14367         return (uint32_t)ret_conv;
14368 }
14369
14370 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
14371         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14372         *ret_conv = CResult_PaymentSecretNoneZ_err();
14373         return (uint32_t)ret_conv;
14374 }
14375
14376 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
14377         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
14378         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
14379         return ret_val;
14380 }
14381
14382 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
14383         if ((_res & 1) != 0) return;
14384         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14385         CHECK_ACCESS(_res_ptr);
14386         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
14387         FREE((void*)_res);
14388         CResult_PaymentSecretNoneZ_free(_res_conv);
14389 }
14390
14391 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
14392         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14393         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
14394         return (uint32_t)ret_conv;
14395 }
14396 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
14397         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
14398         uint32_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
14399         return ret_val;
14400 }
14401
14402 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
14403         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
14404         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14405         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
14406         return (uint32_t)ret_conv;
14407 }
14408
14409 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
14410         LDKThirtyTwoBytes o_ref;
14411         CHECK(o->arr_len == 32);
14412         memcpy(o_ref.data, o->elems, 32); FREE(o);
14413         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14414         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
14415         return (uint32_t)ret_conv;
14416 }
14417
14418 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
14419         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14420         CHECK_ACCESS(e_ptr);
14421         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14422         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14423         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14424         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
14425         return (uint32_t)ret_conv;
14426 }
14427
14428 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
14429         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
14430         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
14431         return ret_val;
14432 }
14433
14434 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
14435         if ((_res & 1) != 0) return;
14436         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14437         CHECK_ACCESS(_res_ptr);
14438         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
14439         FREE((void*)_res);
14440         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
14441 }
14442
14443 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
14444         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14445         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
14446         return (uint32_t)ret_conv;
14447 }
14448 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
14449         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
14450         uint32_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
14451         return ret_val;
14452 }
14453
14454 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
14455         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
14456         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14457         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
14458         return (uint32_t)ret_conv;
14459 }
14460
14461 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
14462         LDKThirtyTwoBytes o_ref;
14463         CHECK(o->arr_len == 32);
14464         memcpy(o_ref.data, o->elems, 32); FREE(o);
14465         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14466         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
14467         return (uint32_t)ret_conv;
14468 }
14469
14470 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
14471         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14472         CHECK_ACCESS(e_ptr);
14473         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14474         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14475         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14476         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
14477         return (uint32_t)ret_conv;
14478 }
14479
14480 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
14481         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
14482         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
14483         return ret_val;
14484 }
14485
14486 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
14487         if ((_res & 1) != 0) return;
14488         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14489         CHECK_ACCESS(_res_ptr);
14490         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
14491         FREE((void*)_res);
14492         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
14493 }
14494
14495 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
14496         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14497         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
14498         return (uint32_t)ret_conv;
14499 }
14500 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
14501         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
14502         uint32_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
14503         return ret_val;
14504 }
14505
14506 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
14507         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
14508         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14509         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
14510         return (uint32_t)ret_conv;
14511 }
14512
14513 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint32_t o) {
14514         LDKCounterpartyForwardingInfo o_conv;
14515         o_conv.inner = (void*)(o & (~1));
14516         o_conv.is_owned = (o & 1) || (o == 0);
14517         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14518         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
14519         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14520         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
14521         return (uint32_t)ret_conv;
14522 }
14523
14524 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint32_t e) {
14525         LDKDecodeError e_conv;
14526         e_conv.inner = (void*)(e & (~1));
14527         e_conv.is_owned = (e & 1) || (e == 0);
14528         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14529         e_conv = DecodeError_clone(&e_conv);
14530         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14531         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
14532         return (uint32_t)ret_conv;
14533 }
14534
14535 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint32_t o) {
14536         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
14537         jboolean ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
14538         return ret_val;
14539 }
14540
14541 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint32_t _res) {
14542         if ((_res & 1) != 0) return;
14543         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14544         CHECK_ACCESS(_res_ptr);
14545         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
14546         FREE((void*)_res);
14547         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
14548 }
14549
14550 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
14551         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14552         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
14553         return (uint32_t)ret_conv;
14554 }
14555 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14556         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
14557         uint32_t ret_val = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
14558         return ret_val;
14559 }
14560
14561 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint32_t orig) {
14562         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
14563         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14564         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
14565         return (uint32_t)ret_conv;
14566 }
14567
14568 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint32_t o) {
14569         LDKChannelCounterparty o_conv;
14570         o_conv.inner = (void*)(o & (~1));
14571         o_conv.is_owned = (o & 1) || (o == 0);
14572         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14573         o_conv = ChannelCounterparty_clone(&o_conv);
14574         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14575         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
14576         return (uint32_t)ret_conv;
14577 }
14578
14579 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint32_t e) {
14580         LDKDecodeError e_conv;
14581         e_conv.inner = (void*)(e & (~1));
14582         e_conv.is_owned = (e & 1) || (e == 0);
14583         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14584         e_conv = DecodeError_clone(&e_conv);
14585         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14586         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
14587         return (uint32_t)ret_conv;
14588 }
14589
14590 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint32_t o) {
14591         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
14592         jboolean ret_val = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
14593         return ret_val;
14594 }
14595
14596 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint32_t _res) {
14597         if ((_res & 1) != 0) return;
14598         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14599         CHECK_ACCESS(_res_ptr);
14600         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
14601         FREE((void*)_res);
14602         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
14603 }
14604
14605 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
14606         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14607         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
14608         return (uint32_t)ret_conv;
14609 }
14610 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint32_t arg) {
14611         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
14612         uint32_t ret_val = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
14613         return ret_val;
14614 }
14615
14616 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint32_t orig) {
14617         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
14618         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14619         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
14620         return (uint32_t)ret_conv;
14621 }
14622
14623 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint32_t o) {
14624         LDKChannelDetails o_conv;
14625         o_conv.inner = (void*)(o & (~1));
14626         o_conv.is_owned = (o & 1) || (o == 0);
14627         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14628         o_conv = ChannelDetails_clone(&o_conv);
14629         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14630         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
14631         return (uint32_t)ret_conv;
14632 }
14633
14634 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint32_t e) {
14635         LDKDecodeError e_conv;
14636         e_conv.inner = (void*)(e & (~1));
14637         e_conv.is_owned = (e & 1) || (e == 0);
14638         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14639         e_conv = DecodeError_clone(&e_conv);
14640         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14641         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
14642         return (uint32_t)ret_conv;
14643 }
14644
14645 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint32_t o) {
14646         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
14647         jboolean ret_val = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
14648         return ret_val;
14649 }
14650
14651 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint32_t _res) {
14652         if ((_res & 1) != 0) return;
14653         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14654         CHECK_ACCESS(_res_ptr);
14655         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
14656         FREE((void*)_res);
14657         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
14658 }
14659
14660 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
14661         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14662         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
14663         return (uint32_t)ret_conv;
14664 }
14665 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint32_t arg) {
14666         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
14667         uint32_t ret_val = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
14668         return ret_val;
14669 }
14670
14671 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint32_t orig) {
14672         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
14673         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14674         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
14675         return (uint32_t)ret_conv;
14676 }
14677
14678 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint32_t o) {
14679         LDKPhantomRouteHints o_conv;
14680         o_conv.inner = (void*)(o & (~1));
14681         o_conv.is_owned = (o & 1) || (o == 0);
14682         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14683         o_conv = PhantomRouteHints_clone(&o_conv);
14684         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14685         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
14686         return (uint32_t)ret_conv;
14687 }
14688
14689 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint32_t e) {
14690         LDKDecodeError e_conv;
14691         e_conv.inner = (void*)(e & (~1));
14692         e_conv.is_owned = (e & 1) || (e == 0);
14693         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14694         e_conv = DecodeError_clone(&e_conv);
14695         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14696         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
14697         return (uint32_t)ret_conv;
14698 }
14699
14700 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint32_t o) {
14701         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
14702         jboolean ret_val = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
14703         return ret_val;
14704 }
14705
14706 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint32_t _res) {
14707         if ((_res & 1) != 0) return;
14708         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14709         CHECK_ACCESS(_res_ptr);
14710         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
14711         FREE((void*)_res);
14712         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
14713 }
14714
14715 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
14716         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14717         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
14718         return (uint32_t)ret_conv;
14719 }
14720 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint32_t arg) {
14721         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
14722         uint32_t ret_val = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
14723         return ret_val;
14724 }
14725
14726 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint32_t orig) {
14727         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
14728         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14729         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
14730         return (uint32_t)ret_conv;
14731 }
14732
14733 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
14734         LDKCVec_ChannelMonitorZ _res_constr;
14735         _res_constr.datalen = _res->arr_len;
14736         if (_res_constr.datalen > 0)
14737                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
14738         else
14739                 _res_constr.data = NULL;
14740         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14741         for (size_t q = 0; q < _res_constr.datalen; q++) {
14742                 uint32_t _res_conv_16 = _res_vals[q];
14743                 LDKChannelMonitor _res_conv_16_conv;
14744                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14745                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14746                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
14747                 _res_constr.data[q] = _res_conv_16_conv;
14748         }
14749         CVec_ChannelMonitorZ_free(_res_constr);
14750 }
14751
14752 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
14753         LDKThirtyTwoBytes a_ref;
14754         CHECK(a->arr_len == 32);
14755         memcpy(a_ref.data, a->elems, 32); FREE(a);
14756         LDKChannelManager b_conv;
14757         b_conv.inner = (void*)(b & (~1));
14758         b_conv.is_owned = (b & 1) || (b == 0);
14759         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14760         // WARNING: we need a move here but no clone is available for LDKChannelManager
14761         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
14762         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
14763         return ((uint32_t)ret_conv);
14764 }
14765
14766 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
14767         if ((_res & 1) != 0) return;
14768         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14769         CHECK_ACCESS(_res_ptr);
14770         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
14771         FREE((void*)_res);
14772         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
14773 }
14774
14775 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
14776         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14777         CHECK_ACCESS(o_ptr);
14778         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
14779         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
14780         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14781         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
14782         return (uint32_t)ret_conv;
14783 }
14784
14785 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
14786         LDKDecodeError e_conv;
14787         e_conv.inner = (void*)(e & (~1));
14788         e_conv.is_owned = (e & 1) || (e == 0);
14789         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14790         e_conv = DecodeError_clone(&e_conv);
14791         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14792         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
14793         return (uint32_t)ret_conv;
14794 }
14795
14796 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
14797         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
14798         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
14799         return ret_val;
14800 }
14801
14802 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
14803         if ((_res & 1) != 0) return;
14804         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14805         CHECK_ACCESS(_res_ptr);
14806         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
14807         FREE((void*)_res);
14808         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
14809 }
14810
14811 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
14812         LDKChannelConfig o_conv;
14813         o_conv.inner = (void*)(o & (~1));
14814         o_conv.is_owned = (o & 1) || (o == 0);
14815         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14816         o_conv = ChannelConfig_clone(&o_conv);
14817         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14818         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
14819         return (uint32_t)ret_conv;
14820 }
14821
14822 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
14823         LDKDecodeError e_conv;
14824         e_conv.inner = (void*)(e & (~1));
14825         e_conv.is_owned = (e & 1) || (e == 0);
14826         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14827         e_conv = DecodeError_clone(&e_conv);
14828         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14829         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
14830         return (uint32_t)ret_conv;
14831 }
14832
14833 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
14834         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
14835         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
14836         return ret_val;
14837 }
14838
14839 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
14840         if ((_res & 1) != 0) return;
14841         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14842         CHECK_ACCESS(_res_ptr);
14843         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
14844         FREE((void*)_res);
14845         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
14846 }
14847
14848 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
14849         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14850         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
14851         return (uint32_t)ret_conv;
14852 }
14853 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
14854         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
14855         uint32_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
14856         return ret_val;
14857 }
14858
14859 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
14860         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
14861         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14862         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
14863         return (uint32_t)ret_conv;
14864 }
14865
14866 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
14867         LDKOutPoint o_conv;
14868         o_conv.inner = (void*)(o & (~1));
14869         o_conv.is_owned = (o & 1) || (o == 0);
14870         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14871         o_conv = OutPoint_clone(&o_conv);
14872         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14873         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
14874         return (uint32_t)ret_conv;
14875 }
14876
14877 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
14878         LDKDecodeError e_conv;
14879         e_conv.inner = (void*)(e & (~1));
14880         e_conv.is_owned = (e & 1) || (e == 0);
14881         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14882         e_conv = DecodeError_clone(&e_conv);
14883         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14884         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
14885         return (uint32_t)ret_conv;
14886 }
14887
14888 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
14889         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
14890         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
14891         return ret_val;
14892 }
14893
14894 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
14895         if ((_res & 1) != 0) return;
14896         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14897         CHECK_ACCESS(_res_ptr);
14898         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
14899         FREE((void*)_res);
14900         CResult_OutPointDecodeErrorZ_free(_res_conv);
14901 }
14902
14903 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
14904         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14905         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
14906         return (uint32_t)ret_conv;
14907 }
14908 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
14909         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
14910         uint32_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
14911         return ret_val;
14912 }
14913
14914 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
14915         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
14916         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14917         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
14918         return (uint32_t)ret_conv;
14919 }
14920
14921 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
14922         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14923         CHECK_ACCESS(o_ptr);
14924         LDKType o_conv = *(LDKType*)(o_ptr);
14925         if (o_conv.free == LDKType_JCalls_free) {
14926                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14927                 LDKType_JCalls_cloned(&o_conv);
14928         }
14929         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14930         *ret_copy = COption_TypeZ_some(o_conv);
14931         uint32_t ret_ref = (uintptr_t)ret_copy;
14932         return ret_ref;
14933 }
14934
14935 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
14936         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14937         *ret_copy = COption_TypeZ_none();
14938         uint32_t ret_ref = (uintptr_t)ret_copy;
14939         return ret_ref;
14940 }
14941
14942 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
14943         if ((_res & 1) != 0) return;
14944         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14945         CHECK_ACCESS(_res_ptr);
14946         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
14947         FREE((void*)_res);
14948         COption_TypeZ_free(_res_conv);
14949 }
14950
14951 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
14952         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14953         *ret_copy = COption_TypeZ_clone(arg);
14954 uint32_t ret_ref = (uintptr_t)ret_copy;
14955         return ret_ref;
14956 }
14957 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
14958         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
14959         uint32_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
14960         return ret_val;
14961 }
14962
14963 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
14964         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
14965         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14966         *ret_copy = COption_TypeZ_clone(orig_conv);
14967         uint32_t ret_ref = (uintptr_t)ret_copy;
14968         return ret_ref;
14969 }
14970
14971 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
14972         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14973         CHECK_ACCESS(o_ptr);
14974         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
14975         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
14976         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14977         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
14978         return (uint32_t)ret_conv;
14979 }
14980
14981 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
14982         LDKDecodeError e_conv;
14983         e_conv.inner = (void*)(e & (~1));
14984         e_conv.is_owned = (e & 1) || (e == 0);
14985         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14986         e_conv = DecodeError_clone(&e_conv);
14987         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14988         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
14989         return (uint32_t)ret_conv;
14990 }
14991
14992 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
14993         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
14994         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
14995         return ret_val;
14996 }
14997
14998 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
14999         if ((_res & 1) != 0) return;
15000         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15001         CHECK_ACCESS(_res_ptr);
15002         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
15003         FREE((void*)_res);
15004         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
15005 }
15006
15007 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
15008         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15009         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
15010         return (uint32_t)ret_conv;
15011 }
15012 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
15013         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
15014         uint32_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
15015         return ret_val;
15016 }
15017
15018 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
15019         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
15020         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15021         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
15022         return (uint32_t)ret_conv;
15023 }
15024
15025 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
15026         LDKThirtyTwoBytes o_ref;
15027         CHECK(o->arr_len == 32);
15028         memcpy(o_ref.data, o->elems, 32); FREE(o);
15029         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15030         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
15031         return (uint32_t)ret_conv;
15032 }
15033
15034 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
15035         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15036         CHECK_ACCESS(e_ptr);
15037         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
15038         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
15039         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15040         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
15041         return (uint32_t)ret_conv;
15042 }
15043
15044 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
15045         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
15046         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
15047         return ret_val;
15048 }
15049
15050 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
15051         if ((_res & 1) != 0) return;
15052         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15053         CHECK_ACCESS(_res_ptr);
15054         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
15055         FREE((void*)_res);
15056         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
15057 }
15058
15059 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
15060         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15061         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
15062         return (uint32_t)ret_conv;
15063 }
15064 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
15065         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
15066         uint32_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
15067         return ret_val;
15068 }
15069
15070 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
15071         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
15072         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15073         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
15074         return (uint32_t)ret_conv;
15075 }
15076
15077 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_ok"))) TS_CResult_SiPrefixParseErrorZ_ok(uint32_t o) {
15078         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
15079         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15080         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
15081         return (uint32_t)ret_conv;
15082 }
15083
15084 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_err"))) TS_CResult_SiPrefixParseErrorZ_err(uint32_t e) {
15085         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15086         CHECK_ACCESS(e_ptr);
15087         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
15088         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
15089         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15090         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
15091         return (uint32_t)ret_conv;
15092 }
15093
15094 jboolean  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_is_ok"))) TS_CResult_SiPrefixParseErrorZ_is_ok(uint32_t o) {
15095         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
15096         jboolean ret_val = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
15097         return ret_val;
15098 }
15099
15100 void  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_free"))) TS_CResult_SiPrefixParseErrorZ_free(uint32_t _res) {
15101         if ((_res & 1) != 0) return;
15102         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15103         CHECK_ACCESS(_res_ptr);
15104         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
15105         FREE((void*)_res);
15106         CResult_SiPrefixParseErrorZ_free(_res_conv);
15107 }
15108
15109 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
15110         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15111         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
15112         return (uint32_t)ret_conv;
15113 }
15114 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone_ptr"))) TS_CResult_SiPrefixParseErrorZ_clone_ptr(uint32_t arg) {
15115         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
15116         uint32_t ret_val = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
15117         return ret_val;
15118 }
15119
15120 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone"))) TS_CResult_SiPrefixParseErrorZ_clone(uint32_t orig) {
15121         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
15122         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15123         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
15124         return (uint32_t)ret_conv;
15125 }
15126
15127 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_ok(uint32_t o) {
15128         LDKInvoice o_conv;
15129         o_conv.inner = (void*)(o & (~1));
15130         o_conv.is_owned = (o & 1) || (o == 0);
15131         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15132         o_conv = Invoice_clone(&o_conv);
15133         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15134         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
15135         return (uint32_t)ret_conv;
15136 }
15137
15138 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_err(uint32_t e) {
15139         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15140         CHECK_ACCESS(e_ptr);
15141         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
15142         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
15143         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15144         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
15145         return (uint32_t)ret_conv;
15146 }
15147
15148 jboolean  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok(uint32_t o) {
15149         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
15150         jboolean ret_val = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
15151         return ret_val;
15152 }
15153
15154 void  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_free"))) TS_CResult_InvoiceParseOrSemanticErrorZ_free(uint32_t _res) {
15155         if ((_res & 1) != 0) return;
15156         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15157         CHECK_ACCESS(_res_ptr);
15158         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
15159         FREE((void*)_res);
15160         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
15161 }
15162
15163 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
15164         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15165         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
15166         return (uint32_t)ret_conv;
15167 }
15168 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(uint32_t arg) {
15169         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
15170         uint32_t ret_val = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
15171         return ret_val;
15172 }
15173
15174 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone(uint32_t orig) {
15175         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
15176         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15177         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
15178         return (uint32_t)ret_conv;
15179 }
15180
15181 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_ok(uint32_t o) {
15182         LDKSignedRawInvoice o_conv;
15183         o_conv.inner = (void*)(o & (~1));
15184         o_conv.is_owned = (o & 1) || (o == 0);
15185         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15186         o_conv = SignedRawInvoice_clone(&o_conv);
15187         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15188         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
15189         return (uint32_t)ret_conv;
15190 }
15191
15192 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_err(uint32_t e) {
15193         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15194         CHECK_ACCESS(e_ptr);
15195         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
15196         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
15197         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15198         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
15199         return (uint32_t)ret_conv;
15200 }
15201
15202 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_is_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_is_ok(uint32_t o) {
15203         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
15204         jboolean ret_val = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
15205         return ret_val;
15206 }
15207
15208 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_free"))) TS_CResult_SignedRawInvoiceParseErrorZ_free(uint32_t _res) {
15209         if ((_res & 1) != 0) return;
15210         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15211         CHECK_ACCESS(_res_ptr);
15212         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
15213         FREE((void*)_res);
15214         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
15215 }
15216
15217 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
15218         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15219         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
15220         return (uint32_t)ret_conv;
15221 }
15222 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr(uint32_t arg) {
15223         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
15224         uint32_t ret_val = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
15225         return ret_val;
15226 }
15227
15228 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone(uint32_t orig) {
15229         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
15230         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15231         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
15232         return (uint32_t)ret_conv;
15233 }
15234
15235 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
15236         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15237         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
15238         return ((uint32_t)ret_conv);
15239 }
15240 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
15241         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
15242         uint32_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
15243         return ret_val;
15244 }
15245
15246 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
15247         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
15248         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15249         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
15250         return ((uint32_t)ret_conv);
15251 }
15252
15253 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
15254         LDKRawInvoice a_conv;
15255         a_conv.inner = (void*)(a & (~1));
15256         a_conv.is_owned = (a & 1) || (a == 0);
15257         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15258         a_conv = RawInvoice_clone(&a_conv);
15259         LDKThirtyTwoBytes b_ref;
15260         CHECK(b->arr_len == 32);
15261         memcpy(b_ref.data, b->elems, 32); FREE(b);
15262         LDKInvoiceSignature c_conv;
15263         c_conv.inner = (void*)(c & (~1));
15264         c_conv.is_owned = (c & 1) || (c == 0);
15265         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
15266         c_conv = InvoiceSignature_clone(&c_conv);
15267         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15268         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
15269         return ((uint32_t)ret_conv);
15270 }
15271
15272 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
15273         if ((_res & 1) != 0) return;
15274         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15275         CHECK_ACCESS(_res_ptr);
15276         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
15277         FREE((void*)_res);
15278         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
15279 }
15280
15281 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
15282         LDKPayeePubKey o_conv;
15283         o_conv.inner = (void*)(o & (~1));
15284         o_conv.is_owned = (o & 1) || (o == 0);
15285         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15286         o_conv = PayeePubKey_clone(&o_conv);
15287         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15288         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
15289         return (uint32_t)ret_conv;
15290 }
15291
15292 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
15293         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15294         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15295         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
15296         return (uint32_t)ret_conv;
15297 }
15298
15299 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
15300         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
15301         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
15302         return ret_val;
15303 }
15304
15305 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
15306         if ((_res & 1) != 0) return;
15307         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15308         CHECK_ACCESS(_res_ptr);
15309         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
15310         FREE((void*)_res);
15311         CResult_PayeePubKeyErrorZ_free(_res_conv);
15312 }
15313
15314 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
15315         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15316         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
15317         return (uint32_t)ret_conv;
15318 }
15319 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
15320         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
15321         uint32_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
15322         return ret_val;
15323 }
15324
15325 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
15326         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
15327         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15328         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
15329         return (uint32_t)ret_conv;
15330 }
15331
15332 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
15333         LDKCVec_PrivateRouteZ _res_constr;
15334         _res_constr.datalen = _res->arr_len;
15335         if (_res_constr.datalen > 0)
15336                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
15337         else
15338                 _res_constr.data = NULL;
15339         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15340         for (size_t o = 0; o < _res_constr.datalen; o++) {
15341                 uint32_t _res_conv_14 = _res_vals[o];
15342                 LDKPrivateRoute _res_conv_14_conv;
15343                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15344                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15345                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15346                 _res_constr.data[o] = _res_conv_14_conv;
15347         }
15348         CVec_PrivateRouteZ_free(_res_constr);
15349 }
15350
15351 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
15352         LDKPositiveTimestamp o_conv;
15353         o_conv.inner = (void*)(o & (~1));
15354         o_conv.is_owned = (o & 1) || (o == 0);
15355         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15356         o_conv = PositiveTimestamp_clone(&o_conv);
15357         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15358         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
15359         return (uint32_t)ret_conv;
15360 }
15361
15362 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
15363         LDKCreationError e_conv = LDKCreationError_from_js(e);
15364         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15365         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
15366         return (uint32_t)ret_conv;
15367 }
15368
15369 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
15370         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
15371         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
15372         return ret_val;
15373 }
15374
15375 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
15376         if ((_res & 1) != 0) return;
15377         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15378         CHECK_ACCESS(_res_ptr);
15379         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
15380         FREE((void*)_res);
15381         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
15382 }
15383
15384 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
15385         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15386         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
15387         return (uint32_t)ret_conv;
15388 }
15389 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
15390         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
15391         uint32_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
15392         return ret_val;
15393 }
15394
15395 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
15396         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
15397         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15398         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
15399         return (uint32_t)ret_conv;
15400 }
15401
15402 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
15403         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15404         *ret_conv = CResult_NoneSemanticErrorZ_ok();
15405         return (uint32_t)ret_conv;
15406 }
15407
15408 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
15409         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15410         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15411         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
15412         return (uint32_t)ret_conv;
15413 }
15414
15415 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
15416         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
15417         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
15418         return ret_val;
15419 }
15420
15421 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
15422         if ((_res & 1) != 0) return;
15423         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15424         CHECK_ACCESS(_res_ptr);
15425         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
15426         FREE((void*)_res);
15427         CResult_NoneSemanticErrorZ_free(_res_conv);
15428 }
15429
15430 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
15431         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15432         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
15433         return (uint32_t)ret_conv;
15434 }
15435 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
15436         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
15437         uint32_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
15438         return ret_val;
15439 }
15440
15441 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
15442         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
15443         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15444         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
15445         return (uint32_t)ret_conv;
15446 }
15447
15448 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
15449         LDKInvoice o_conv;
15450         o_conv.inner = (void*)(o & (~1));
15451         o_conv.is_owned = (o & 1) || (o == 0);
15452         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15453         o_conv = Invoice_clone(&o_conv);
15454         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15455         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
15456         return (uint32_t)ret_conv;
15457 }
15458
15459 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
15460         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15461         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15462         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
15463         return (uint32_t)ret_conv;
15464 }
15465
15466 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
15467         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
15468         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
15469         return ret_val;
15470 }
15471
15472 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
15473         if ((_res & 1) != 0) return;
15474         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15475         CHECK_ACCESS(_res_ptr);
15476         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
15477         FREE((void*)_res);
15478         CResult_InvoiceSemanticErrorZ_free(_res_conv);
15479 }
15480
15481 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
15482         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15483         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
15484         return (uint32_t)ret_conv;
15485 }
15486 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
15487         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
15488         uint32_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
15489         return ret_val;
15490 }
15491
15492 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
15493         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
15494         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15495         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
15496         return (uint32_t)ret_conv;
15497 }
15498
15499 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
15500         LDKDescription o_conv;
15501         o_conv.inner = (void*)(o & (~1));
15502         o_conv.is_owned = (o & 1) || (o == 0);
15503         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15504         o_conv = Description_clone(&o_conv);
15505         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15506         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
15507         return (uint32_t)ret_conv;
15508 }
15509
15510 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
15511         LDKCreationError e_conv = LDKCreationError_from_js(e);
15512         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15513         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
15514         return (uint32_t)ret_conv;
15515 }
15516
15517 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
15518         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
15519         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
15520         return ret_val;
15521 }
15522
15523 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
15524         if ((_res & 1) != 0) return;
15525         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15526         CHECK_ACCESS(_res_ptr);
15527         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
15528         FREE((void*)_res);
15529         CResult_DescriptionCreationErrorZ_free(_res_conv);
15530 }
15531
15532 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
15533         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15534         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
15535         return (uint32_t)ret_conv;
15536 }
15537 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
15538         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
15539         uint32_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
15540         return ret_val;
15541 }
15542
15543 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
15544         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
15545         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15546         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
15547         return (uint32_t)ret_conv;
15548 }
15549
15550 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
15551         LDKPrivateRoute o_conv;
15552         o_conv.inner = (void*)(o & (~1));
15553         o_conv.is_owned = (o & 1) || (o == 0);
15554         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15555         o_conv = PrivateRoute_clone(&o_conv);
15556         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15557         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
15558         return (uint32_t)ret_conv;
15559 }
15560
15561 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
15562         LDKCreationError e_conv = LDKCreationError_from_js(e);
15563         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15564         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
15565         return (uint32_t)ret_conv;
15566 }
15567
15568 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
15569         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
15570         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
15571         return ret_val;
15572 }
15573
15574 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
15575         if ((_res & 1) != 0) return;
15576         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15577         CHECK_ACCESS(_res_ptr);
15578         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
15579         FREE((void*)_res);
15580         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
15581 }
15582
15583 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
15584         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15585         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
15586         return (uint32_t)ret_conv;
15587 }
15588 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
15589         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
15590         uint32_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
15591         return ret_val;
15592 }
15593
15594 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
15595         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
15596         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15597         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
15598         return (uint32_t)ret_conv;
15599 }
15600
15601 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
15602         LDKStr o_conv = str_ref_to_owned_c(o);
15603         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15604         *ret_conv = CResult_StringErrorZ_ok(o_conv);
15605         return (uint32_t)ret_conv;
15606 }
15607
15608 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
15609         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15610         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15611         *ret_conv = CResult_StringErrorZ_err(e_conv);
15612         return (uint32_t)ret_conv;
15613 }
15614
15615 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
15616         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
15617         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
15618         return ret_val;
15619 }
15620
15621 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
15622         if ((_res & 1) != 0) return;
15623         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15624         CHECK_ACCESS(_res_ptr);
15625         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
15626         FREE((void*)_res);
15627         CResult_StringErrorZ_free(_res_conv);
15628 }
15629
15630 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
15631         LDKChannelMonitorUpdate o_conv;
15632         o_conv.inner = (void*)(o & (~1));
15633         o_conv.is_owned = (o & 1) || (o == 0);
15634         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15635         o_conv = ChannelMonitorUpdate_clone(&o_conv);
15636         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15637         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
15638         return (uint32_t)ret_conv;
15639 }
15640
15641 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
15642         LDKDecodeError e_conv;
15643         e_conv.inner = (void*)(e & (~1));
15644         e_conv.is_owned = (e & 1) || (e == 0);
15645         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15646         e_conv = DecodeError_clone(&e_conv);
15647         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15648         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
15649         return (uint32_t)ret_conv;
15650 }
15651
15652 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
15653         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
15654         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
15655         return ret_val;
15656 }
15657
15658 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
15659         if ((_res & 1) != 0) return;
15660         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15661         CHECK_ACCESS(_res_ptr);
15662         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
15663         FREE((void*)_res);
15664         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
15665 }
15666
15667 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
15668         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15669         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
15670         return (uint32_t)ret_conv;
15671 }
15672 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15673         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
15674         uint32_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
15675         return ret_val;
15676 }
15677
15678 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
15679         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
15680         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15681         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
15682         return (uint32_t)ret_conv;
15683 }
15684
15685 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
15686         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15687         CHECK_ACCESS(o_ptr);
15688         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
15689         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
15690         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15691         *ret_copy = COption_MonitorEventZ_some(o_conv);
15692         uint32_t ret_ref = (uintptr_t)ret_copy;
15693         return ret_ref;
15694 }
15695
15696 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
15697         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15698         *ret_copy = COption_MonitorEventZ_none();
15699         uint32_t ret_ref = (uintptr_t)ret_copy;
15700         return ret_ref;
15701 }
15702
15703 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
15704         if ((_res & 1) != 0) return;
15705         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15706         CHECK_ACCESS(_res_ptr);
15707         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
15708         FREE((void*)_res);
15709         COption_MonitorEventZ_free(_res_conv);
15710 }
15711
15712 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
15713         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15714         *ret_copy = COption_MonitorEventZ_clone(arg);
15715 uint32_t ret_ref = (uintptr_t)ret_copy;
15716         return ret_ref;
15717 }
15718 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
15719         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
15720         uint32_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
15721         return ret_val;
15722 }
15723
15724 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
15725         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
15726         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15727         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
15728         uint32_t ret_ref = (uintptr_t)ret_copy;
15729         return ret_ref;
15730 }
15731
15732 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
15733         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15734         CHECK_ACCESS(o_ptr);
15735         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
15736         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
15737         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15738         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
15739         return (uint32_t)ret_conv;
15740 }
15741
15742 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
15743         LDKDecodeError e_conv;
15744         e_conv.inner = (void*)(e & (~1));
15745         e_conv.is_owned = (e & 1) || (e == 0);
15746         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15747         e_conv = DecodeError_clone(&e_conv);
15748         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15749         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
15750         return (uint32_t)ret_conv;
15751 }
15752
15753 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
15754         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
15755         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
15756         return ret_val;
15757 }
15758
15759 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
15760         if ((_res & 1) != 0) return;
15761         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15762         CHECK_ACCESS(_res_ptr);
15763         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
15764         FREE((void*)_res);
15765         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
15766 }
15767
15768 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
15769         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15770         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
15771         return (uint32_t)ret_conv;
15772 }
15773 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
15774         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
15775         uint32_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
15776         return ret_val;
15777 }
15778
15779 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
15780         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
15781         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15782         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
15783         return (uint32_t)ret_conv;
15784 }
15785
15786 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
15787         LDKHTLCUpdate o_conv;
15788         o_conv.inner = (void*)(o & (~1));
15789         o_conv.is_owned = (o & 1) || (o == 0);
15790         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15791         o_conv = HTLCUpdate_clone(&o_conv);
15792         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15793         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
15794         return (uint32_t)ret_conv;
15795 }
15796
15797 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
15798         LDKDecodeError e_conv;
15799         e_conv.inner = (void*)(e & (~1));
15800         e_conv.is_owned = (e & 1) || (e == 0);
15801         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15802         e_conv = DecodeError_clone(&e_conv);
15803         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15804         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
15805         return (uint32_t)ret_conv;
15806 }
15807
15808 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
15809         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
15810         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
15811         return ret_val;
15812 }
15813
15814 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
15815         if ((_res & 1) != 0) return;
15816         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15817         CHECK_ACCESS(_res_ptr);
15818         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
15819         FREE((void*)_res);
15820         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
15821 }
15822
15823 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
15824         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15825         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
15826         return (uint32_t)ret_conv;
15827 }
15828 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15829         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
15830         uint32_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
15831         return ret_val;
15832 }
15833
15834 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
15835         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
15836         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15837         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
15838         return (uint32_t)ret_conv;
15839 }
15840
15841 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
15842         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15843         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
15844         return ((uint32_t)ret_conv);
15845 }
15846 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
15847         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
15848         uint32_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
15849         return ret_val;
15850 }
15851
15852 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
15853         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
15854         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15855         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
15856         return ((uint32_t)ret_conv);
15857 }
15858
15859 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
15860         LDKOutPoint a_conv;
15861         a_conv.inner = (void*)(a & (~1));
15862         a_conv.is_owned = (a & 1) || (a == 0);
15863         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15864         a_conv = OutPoint_clone(&a_conv);
15865         LDKCVec_u8Z b_ref;
15866         b_ref.datalen = b->arr_len;
15867         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15868         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15869         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15870         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
15871         return ((uint32_t)ret_conv);
15872 }
15873
15874 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
15875         if ((_res & 1) != 0) return;
15876         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15877         CHECK_ACCESS(_res_ptr);
15878         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
15879         FREE((void*)_res);
15880         C2Tuple_OutPointScriptZ_free(_res_conv);
15881 }
15882
15883 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
15884         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15885         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
15886         return ((uint32_t)ret_conv);
15887 }
15888 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
15889         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
15890         uint32_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
15891         return ret_val;
15892 }
15893
15894 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
15895         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
15896         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15897         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
15898         return ((uint32_t)ret_conv);
15899 }
15900
15901 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
15902         LDKCVec_u8Z b_ref;
15903         b_ref.datalen = b->arr_len;
15904         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15905         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15906         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15907         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
15908         return ((uint32_t)ret_conv);
15909 }
15910
15911 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
15912         if ((_res & 1) != 0) return;
15913         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15914         CHECK_ACCESS(_res_ptr);
15915         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
15916         FREE((void*)_res);
15917         C2Tuple_u32ScriptZ_free(_res_conv);
15918 }
15919
15920 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
15921         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
15922         _res_constr.datalen = _res->arr_len;
15923         if (_res_constr.datalen > 0)
15924                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15925         else
15926                 _res_constr.data = NULL;
15927         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15928         for (size_t v = 0; v < _res_constr.datalen; v++) {
15929                 uint32_t _res_conv_21 = _res_vals[v];
15930                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
15931                 CHECK_ACCESS(_res_conv_21_ptr);
15932                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
15933                 FREE((void*)_res_conv_21);
15934                 _res_constr.data[v] = _res_conv_21_conv;
15935         }
15936         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
15937 }
15938
15939 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
15940         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15941         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
15942         return ((uint32_t)ret_conv);
15943 }
15944 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
15945         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
15946         uint32_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
15947         return ret_val;
15948 }
15949
15950 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
15951         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
15952         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15953         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
15954         return ((uint32_t)ret_conv);
15955 }
15956
15957 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
15958         LDKThirtyTwoBytes a_ref;
15959         CHECK(a->arr_len == 32);
15960         memcpy(a_ref.data, a->elems, 32); FREE(a);
15961         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
15962         b_constr.datalen = b->arr_len;
15963         if (b_constr.datalen > 0)
15964                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15965         else
15966                 b_constr.data = NULL;
15967         uint32_t* b_vals = b->elems /* XXX b leaks */;
15968         for (size_t v = 0; v < b_constr.datalen; v++) {
15969                 uint32_t b_conv_21 = b_vals[v];
15970                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
15971                 CHECK_ACCESS(b_conv_21_ptr);
15972                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
15973                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
15974                 b_constr.data[v] = b_conv_21_conv;
15975         }
15976         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15977         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
15978         return ((uint32_t)ret_conv);
15979 }
15980
15981 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
15982         if ((_res & 1) != 0) return;
15983         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15984         CHECK_ACCESS(_res_ptr);
15985         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
15986         FREE((void*)_res);
15987         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
15988 }
15989
15990 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
15991         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
15992         _res_constr.datalen = _res->arr_len;
15993         if (_res_constr.datalen > 0)
15994                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
15995         else
15996                 _res_constr.data = NULL;
15997         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15998         for (size_t o = 0; o < _res_constr.datalen; o++) {
15999                 uint32_t _res_conv_40 = _res_vals[o];
16000                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
16001                 CHECK_ACCESS(_res_conv_40_ptr);
16002                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
16003                 FREE((void*)_res_conv_40);
16004                 _res_constr.data[o] = _res_conv_40_conv;
16005         }
16006         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
16007 }
16008
16009 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
16010         LDKCVec_EventZ _res_constr;
16011         _res_constr.datalen = _res->arr_len;
16012         if (_res_constr.datalen > 0)
16013                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
16014         else
16015                 _res_constr.data = NULL;
16016         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16017         for (size_t h = 0; h < _res_constr.datalen; h++) {
16018                 uint32_t _res_conv_7 = _res_vals[h];
16019                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
16020                 CHECK_ACCESS(_res_conv_7_ptr);
16021                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
16022                 FREE((void*)_res_conv_7);
16023                 _res_constr.data[h] = _res_conv_7_conv;
16024         }
16025         CVec_EventZ_free(_res_constr);
16026 }
16027
16028 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
16029         LDKCVec_TransactionZ _res_constr;
16030         _res_constr.datalen = _res->arr_len;
16031         if (_res_constr.datalen > 0)
16032                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
16033         else
16034                 _res_constr.data = NULL;
16035         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
16036         for (size_t m = 0; m < _res_constr.datalen; m++) {
16037                 int8_tArray _res_conv_12 = _res_vals[m];
16038                 LDKTransaction _res_conv_12_ref;
16039                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
16040                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
16041                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
16042                 _res_conv_12_ref.data_is_owned = true;
16043                 _res_constr.data[m] = _res_conv_12_ref;
16044         }
16045         CVec_TransactionZ_free(_res_constr);
16046 }
16047
16048 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
16049         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16050         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
16051         return ((uint32_t)ret_conv);
16052 }
16053 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
16054         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
16055         uint32_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
16056         return ret_val;
16057 }
16058
16059 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
16060         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
16061         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16062         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
16063         return ((uint32_t)ret_conv);
16064 }
16065
16066 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
16067         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
16068         CHECK_ACCESS(b_ptr);
16069         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
16070         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
16071         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16072         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
16073         return ((uint32_t)ret_conv);
16074 }
16075
16076 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
16077         if ((_res & 1) != 0) return;
16078         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16079         CHECK_ACCESS(_res_ptr);
16080         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
16081         FREE((void*)_res);
16082         C2Tuple_u32TxOutZ_free(_res_conv);
16083 }
16084
16085 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
16086         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
16087         _res_constr.datalen = _res->arr_len;
16088         if (_res_constr.datalen > 0)
16089                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16090         else
16091                 _res_constr.data = NULL;
16092         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16093         for (size_t u = 0; u < _res_constr.datalen; u++) {
16094                 uint32_t _res_conv_20 = _res_vals[u];
16095                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
16096                 CHECK_ACCESS(_res_conv_20_ptr);
16097                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
16098                 FREE((void*)_res_conv_20);
16099                 _res_constr.data[u] = _res_conv_20_conv;
16100         }
16101         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
16102 }
16103
16104 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
16105         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16106         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
16107         return ((uint32_t)ret_conv);
16108 }
16109 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
16110         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
16111         uint32_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
16112         return ret_val;
16113 }
16114
16115 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
16116         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
16117         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16118         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
16119         return ((uint32_t)ret_conv);
16120 }
16121
16122 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
16123         LDKThirtyTwoBytes a_ref;
16124         CHECK(a->arr_len == 32);
16125         memcpy(a_ref.data, a->elems, 32); FREE(a);
16126         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
16127         b_constr.datalen = b->arr_len;
16128         if (b_constr.datalen > 0)
16129                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16130         else
16131                 b_constr.data = NULL;
16132         uint32_t* b_vals = b->elems /* XXX b leaks */;
16133         for (size_t u = 0; u < b_constr.datalen; u++) {
16134                 uint32_t b_conv_20 = b_vals[u];
16135                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
16136                 CHECK_ACCESS(b_conv_20_ptr);
16137                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
16138                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
16139                 b_constr.data[u] = b_conv_20_conv;
16140         }
16141         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16142         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
16143         return ((uint32_t)ret_conv);
16144 }
16145
16146 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
16147         if ((_res & 1) != 0) return;
16148         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16149         CHECK_ACCESS(_res_ptr);
16150         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
16151         FREE((void*)_res);
16152         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
16153 }
16154
16155 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
16156         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
16157         _res_constr.datalen = _res->arr_len;
16158         if (_res_constr.datalen > 0)
16159                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
16160         else
16161                 _res_constr.data = NULL;
16162         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16163         for (size_t n = 0; n < _res_constr.datalen; n++) {
16164                 uint32_t _res_conv_39 = _res_vals[n];
16165                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
16166                 CHECK_ACCESS(_res_conv_39_ptr);
16167                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
16168                 FREE((void*)_res_conv_39);
16169                 _res_constr.data[n] = _res_conv_39_conv;
16170         }
16171         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
16172 }
16173
16174 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
16175         LDKCVec_BalanceZ _res_constr;
16176         _res_constr.datalen = _res->arr_len;
16177         if (_res_constr.datalen > 0)
16178                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
16179         else
16180                 _res_constr.data = NULL;
16181         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16182         for (size_t j = 0; j < _res_constr.datalen; j++) {
16183                 uint32_t _res_conv_9 = _res_vals[j];
16184                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
16185                 CHECK_ACCESS(_res_conv_9_ptr);
16186                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
16187                 FREE((void*)_res_conv_9);
16188                 _res_constr.data[j] = _res_conv_9_conv;
16189         }
16190         CVec_BalanceZ_free(_res_constr);
16191 }
16192
16193 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
16194         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16195         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
16196         return ((uint32_t)ret_conv);
16197 }
16198 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
16199         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
16200         uint32_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
16201         return ret_val;
16202 }
16203
16204 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
16205         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
16206         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16207         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
16208         return ((uint32_t)ret_conv);
16209 }
16210
16211 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
16212         LDKThirtyTwoBytes a_ref;
16213         CHECK(a->arr_len == 32);
16214         memcpy(a_ref.data, a->elems, 32); FREE(a);
16215         LDKChannelMonitor b_conv;
16216         b_conv.inner = (void*)(b & (~1));
16217         b_conv.is_owned = (b & 1) || (b == 0);
16218         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16219         b_conv = ChannelMonitor_clone(&b_conv);
16220         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16221         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
16222         return ((uint32_t)ret_conv);
16223 }
16224
16225 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
16226         if ((_res & 1) != 0) return;
16227         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16228         CHECK_ACCESS(_res_ptr);
16229         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
16230         FREE((void*)_res);
16231         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
16232 }
16233
16234 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
16235         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16236         CHECK_ACCESS(o_ptr);
16237         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
16238         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
16239         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16240         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
16241         return (uint32_t)ret_conv;
16242 }
16243
16244 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
16245         LDKDecodeError e_conv;
16246         e_conv.inner = (void*)(e & (~1));
16247         e_conv.is_owned = (e & 1) || (e == 0);
16248         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16249         e_conv = DecodeError_clone(&e_conv);
16250         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16251         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
16252         return (uint32_t)ret_conv;
16253 }
16254
16255 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
16256         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
16257         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
16258         return ret_val;
16259 }
16260
16261 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
16262         if ((_res & 1) != 0) return;
16263         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16264         CHECK_ACCESS(_res_ptr);
16265         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
16266         FREE((void*)_res);
16267         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
16268 }
16269
16270 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
16271         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16272         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
16273         return (uint32_t)ret_conv;
16274 }
16275 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
16276         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
16277         uint32_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
16278         return ret_val;
16279 }
16280
16281 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
16282         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
16283         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16284         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
16285         return (uint32_t)ret_conv;
16286 }
16287
16288 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
16289         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16290         *ret_conv = CResult_NoneLightningErrorZ_ok();
16291         return (uint32_t)ret_conv;
16292 }
16293
16294 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
16295         LDKLightningError e_conv;
16296         e_conv.inner = (void*)(e & (~1));
16297         e_conv.is_owned = (e & 1) || (e == 0);
16298         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16299         e_conv = LightningError_clone(&e_conv);
16300         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16301         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
16302         return (uint32_t)ret_conv;
16303 }
16304
16305 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
16306         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
16307         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
16308         return ret_val;
16309 }
16310
16311 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
16312         if ((_res & 1) != 0) return;
16313         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16314         CHECK_ACCESS(_res_ptr);
16315         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
16316         FREE((void*)_res);
16317         CResult_NoneLightningErrorZ_free(_res_conv);
16318 }
16319
16320 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
16321         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16322         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
16323         return (uint32_t)ret_conv;
16324 }
16325 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
16326         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
16327         uint32_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
16328         return ret_val;
16329 }
16330
16331 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
16332         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
16333         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16334         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
16335         return (uint32_t)ret_conv;
16336 }
16337
16338 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
16339         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16340         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
16341         return ((uint32_t)ret_conv);
16342 }
16343 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
16344         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
16345         uint32_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
16346         return ret_val;
16347 }
16348
16349 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
16350         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
16351         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16352         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
16353         return ((uint32_t)ret_conv);
16354 }
16355
16356 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
16357         LDKPublicKey a_ref;
16358         CHECK(a->arr_len == 33);
16359         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
16360         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
16361         CHECK_ACCESS(b_ptr);
16362         LDKType b_conv = *(LDKType*)(b_ptr);
16363         if (b_conv.free == LDKType_JCalls_free) {
16364                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16365                 LDKType_JCalls_cloned(&b_conv);
16366         }
16367         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16368         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
16369         return ((uint32_t)ret_conv);
16370 }
16371
16372 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
16373         if ((_res & 1) != 0) return;
16374         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16375         CHECK_ACCESS(_res_ptr);
16376         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
16377         FREE((void*)_res);
16378         C2Tuple_PublicKeyTypeZ_free(_res_conv);
16379 }
16380
16381 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
16382         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
16383         _res_constr.datalen = _res->arr_len;
16384         if (_res_constr.datalen > 0)
16385                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
16386         else
16387                 _res_constr.data = NULL;
16388         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16389         for (size_t z = 0; z < _res_constr.datalen; z++) {
16390                 uint32_t _res_conv_25 = _res_vals[z];
16391                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
16392                 CHECK_ACCESS(_res_conv_25_ptr);
16393                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
16394                 FREE((void*)_res_conv_25);
16395                 _res_constr.data[z] = _res_conv_25_conv;
16396         }
16397         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
16398 }
16399
16400 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
16401         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16402         *ret_conv = CResult_boolLightningErrorZ_ok(o);
16403         return (uint32_t)ret_conv;
16404 }
16405
16406 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
16407         LDKLightningError e_conv;
16408         e_conv.inner = (void*)(e & (~1));
16409         e_conv.is_owned = (e & 1) || (e == 0);
16410         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16411         e_conv = LightningError_clone(&e_conv);
16412         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16413         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
16414         return (uint32_t)ret_conv;
16415 }
16416
16417 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
16418         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
16419         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
16420         return ret_val;
16421 }
16422
16423 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
16424         if ((_res & 1) != 0) return;
16425         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16426         CHECK_ACCESS(_res_ptr);
16427         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
16428         FREE((void*)_res);
16429         CResult_boolLightningErrorZ_free(_res_conv);
16430 }
16431
16432 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
16433         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16434         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
16435         return (uint32_t)ret_conv;
16436 }
16437 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
16438         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
16439         uint32_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
16440         return ret_val;
16441 }
16442
16443 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
16444         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
16445         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16446         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
16447         return (uint32_t)ret_conv;
16448 }
16449
16450 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
16451         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16452         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
16453         return ((uint32_t)ret_conv);
16454 }
16455 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
16456         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
16457         uint32_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
16458         return ret_val;
16459 }
16460
16461 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
16462         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
16463         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16464         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
16465         return ((uint32_t)ret_conv);
16466 }
16467
16468 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
16469         LDKChannelAnnouncement a_conv;
16470         a_conv.inner = (void*)(a & (~1));
16471         a_conv.is_owned = (a & 1) || (a == 0);
16472         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16473         a_conv = ChannelAnnouncement_clone(&a_conv);
16474         LDKChannelUpdate b_conv;
16475         b_conv.inner = (void*)(b & (~1));
16476         b_conv.is_owned = (b & 1) || (b == 0);
16477         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16478         b_conv = ChannelUpdate_clone(&b_conv);
16479         LDKChannelUpdate c_conv;
16480         c_conv.inner = (void*)(c & (~1));
16481         c_conv.is_owned = (c & 1) || (c == 0);
16482         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
16483         c_conv = ChannelUpdate_clone(&c_conv);
16484         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16485         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
16486         return ((uint32_t)ret_conv);
16487 }
16488
16489 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
16490         if ((_res & 1) != 0) return;
16491         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16492         CHECK_ACCESS(_res_ptr);
16493         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
16494         FREE((void*)_res);
16495         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
16496 }
16497
16498 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
16499         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
16500         _res_constr.datalen = _res->arr_len;
16501         if (_res_constr.datalen > 0)
16502                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
16503         else
16504                 _res_constr.data = NULL;
16505         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16506         for (size_t h = 0; h < _res_constr.datalen; h++) {
16507                 uint32_t _res_conv_59 = _res_vals[h];
16508                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
16509                 CHECK_ACCESS(_res_conv_59_ptr);
16510                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
16511                 FREE((void*)_res_conv_59);
16512                 _res_constr.data[h] = _res_conv_59_conv;
16513         }
16514         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
16515 }
16516
16517 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
16518         LDKCVec_NodeAnnouncementZ _res_constr;
16519         _res_constr.datalen = _res->arr_len;
16520         if (_res_constr.datalen > 0)
16521                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
16522         else
16523                 _res_constr.data = NULL;
16524         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16525         for (size_t s = 0; s < _res_constr.datalen; s++) {
16526                 uint32_t _res_conv_18 = _res_vals[s];
16527                 LDKNodeAnnouncement _res_conv_18_conv;
16528                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
16529                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
16530                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
16531                 _res_constr.data[s] = _res_conv_18_conv;
16532         }
16533         CVec_NodeAnnouncementZ_free(_res_constr);
16534 }
16535
16536 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
16537         LDKCVec_PublicKeyZ _res_constr;
16538         _res_constr.datalen = _res->arr_len;
16539         if (_res_constr.datalen > 0)
16540                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16541         else
16542                 _res_constr.data = NULL;
16543         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
16544         for (size_t m = 0; m < _res_constr.datalen; m++) {
16545                 int8_tArray _res_conv_12 = _res_vals[m];
16546                 LDKPublicKey _res_conv_12_ref;
16547                 CHECK(_res_conv_12->arr_len == 33);
16548                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
16549                 _res_constr.data[m] = _res_conv_12_ref;
16550         }
16551         CVec_PublicKeyZ_free(_res_constr);
16552 }
16553
16554 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_some"))) TS_COption_NetAddressZ_some(uint32_t o) {
16555         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16556         CHECK_ACCESS(o_ptr);
16557         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
16558         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
16559         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16560         *ret_copy = COption_NetAddressZ_some(o_conv);
16561         uint32_t ret_ref = (uintptr_t)ret_copy;
16562         return ret_ref;
16563 }
16564
16565 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_none"))) TS_COption_NetAddressZ_none() {
16566         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16567         *ret_copy = COption_NetAddressZ_none();
16568         uint32_t ret_ref = (uintptr_t)ret_copy;
16569         return ret_ref;
16570 }
16571
16572 void  __attribute__((export_name("TS_COption_NetAddressZ_free"))) TS_COption_NetAddressZ_free(uint32_t _res) {
16573         if ((_res & 1) != 0) return;
16574         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16575         CHECK_ACCESS(_res_ptr);
16576         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
16577         FREE((void*)_res);
16578         COption_NetAddressZ_free(_res_conv);
16579 }
16580
16581 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
16582         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16583         *ret_copy = COption_NetAddressZ_clone(arg);
16584 uint32_t ret_ref = (uintptr_t)ret_copy;
16585         return ret_ref;
16586 }
16587 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone_ptr"))) TS_COption_NetAddressZ_clone_ptr(uint32_t arg) {
16588         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
16589         uint32_t ret_val = COption_NetAddressZ_clone_ptr(arg_conv);
16590         return ret_val;
16591 }
16592
16593 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone"))) TS_COption_NetAddressZ_clone(uint32_t orig) {
16594         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
16595         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16596         *ret_copy = COption_NetAddressZ_clone(orig_conv);
16597         uint32_t ret_ref = (uintptr_t)ret_copy;
16598         return ret_ref;
16599 }
16600
16601 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
16602         LDKCVec_u8Z o_ref;
16603         o_ref.datalen = o->arr_len;
16604         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
16605         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
16606         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16607         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
16608         return (uint32_t)ret_conv;
16609 }
16610
16611 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
16612         LDKPeerHandleError e_conv;
16613         e_conv.inner = (void*)(e & (~1));
16614         e_conv.is_owned = (e & 1) || (e == 0);
16615         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16616         e_conv = PeerHandleError_clone(&e_conv);
16617         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16618         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
16619         return (uint32_t)ret_conv;
16620 }
16621
16622 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
16623         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
16624         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
16625         return ret_val;
16626 }
16627
16628 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
16629         if ((_res & 1) != 0) return;
16630         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16631         CHECK_ACCESS(_res_ptr);
16632         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
16633         FREE((void*)_res);
16634         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
16635 }
16636
16637 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
16638         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16639         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
16640         return (uint32_t)ret_conv;
16641 }
16642 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16643         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
16644         uint32_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
16645         return ret_val;
16646 }
16647
16648 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
16649         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
16650         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16651         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
16652         return (uint32_t)ret_conv;
16653 }
16654
16655 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
16656         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16657         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
16658         return (uint32_t)ret_conv;
16659 }
16660
16661 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
16662         LDKPeerHandleError e_conv;
16663         e_conv.inner = (void*)(e & (~1));
16664         e_conv.is_owned = (e & 1) || (e == 0);
16665         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16666         e_conv = PeerHandleError_clone(&e_conv);
16667         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16668         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
16669         return (uint32_t)ret_conv;
16670 }
16671
16672 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
16673         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
16674         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
16675         return ret_val;
16676 }
16677
16678 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
16679         if ((_res & 1) != 0) return;
16680         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16681         CHECK_ACCESS(_res_ptr);
16682         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
16683         FREE((void*)_res);
16684         CResult_NonePeerHandleErrorZ_free(_res_conv);
16685 }
16686
16687 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
16688         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16689         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
16690         return (uint32_t)ret_conv;
16691 }
16692 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
16693         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
16694         uint32_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
16695         return ret_val;
16696 }
16697
16698 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
16699         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
16700         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16701         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
16702         return (uint32_t)ret_conv;
16703 }
16704
16705 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
16706         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16707         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
16708         return (uint32_t)ret_conv;
16709 }
16710
16711 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
16712         LDKPeerHandleError e_conv;
16713         e_conv.inner = (void*)(e & (~1));
16714         e_conv.is_owned = (e & 1) || (e == 0);
16715         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16716         e_conv = PeerHandleError_clone(&e_conv);
16717         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16718         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
16719         return (uint32_t)ret_conv;
16720 }
16721
16722 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
16723         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
16724         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
16725         return ret_val;
16726 }
16727
16728 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
16729         if ((_res & 1) != 0) return;
16730         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16731         CHECK_ACCESS(_res_ptr);
16732         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
16733         FREE((void*)_res);
16734         CResult_boolPeerHandleErrorZ_free(_res_conv);
16735 }
16736
16737 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
16738         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16739         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
16740         return (uint32_t)ret_conv;
16741 }
16742 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16743         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
16744         uint32_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
16745         return ret_val;
16746 }
16747
16748 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
16749         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
16750         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16751         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
16752         return (uint32_t)ret_conv;
16753 }
16754
16755 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
16756         LDKNodeId o_conv;
16757         o_conv.inner = (void*)(o & (~1));
16758         o_conv.is_owned = (o & 1) || (o == 0);
16759         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16760         o_conv = NodeId_clone(&o_conv);
16761         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16762         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
16763         return (uint32_t)ret_conv;
16764 }
16765
16766 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
16767         LDKDecodeError e_conv;
16768         e_conv.inner = (void*)(e & (~1));
16769         e_conv.is_owned = (e & 1) || (e == 0);
16770         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16771         e_conv = DecodeError_clone(&e_conv);
16772         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16773         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
16774         return (uint32_t)ret_conv;
16775 }
16776
16777 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
16778         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
16779         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
16780         return ret_val;
16781 }
16782
16783 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
16784         if ((_res & 1) != 0) return;
16785         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16786         CHECK_ACCESS(_res_ptr);
16787         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
16788         FREE((void*)_res);
16789         CResult_NodeIdDecodeErrorZ_free(_res_conv);
16790 }
16791
16792 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
16793         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16794         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
16795         return (uint32_t)ret_conv;
16796 }
16797 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
16798         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
16799         uint32_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
16800         return ret_val;
16801 }
16802
16803 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
16804         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
16805         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16806         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
16807         return (uint32_t)ret_conv;
16808 }
16809
16810 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
16811         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16812         CHECK_ACCESS(o_ptr);
16813         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
16814         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
16815         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16816         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
16817         return (uint32_t)ret_conv;
16818 }
16819
16820 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
16821         LDKDecodeError e_conv;
16822         e_conv.inner = (void*)(e & (~1));
16823         e_conv.is_owned = (e & 1) || (e == 0);
16824         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16825         e_conv = DecodeError_clone(&e_conv);
16826         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16827         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
16828         return (uint32_t)ret_conv;
16829 }
16830
16831 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
16832         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
16833         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
16834         return ret_val;
16835 }
16836
16837 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
16838         if ((_res & 1) != 0) return;
16839         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16840         CHECK_ACCESS(_res_ptr);
16841         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
16842         FREE((void*)_res);
16843         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
16844 }
16845
16846 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
16847         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16848         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
16849         return (uint32_t)ret_conv;
16850 }
16851 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
16852         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
16853         uint32_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
16854         return ret_val;
16855 }
16856
16857 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
16858         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
16859         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16860         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
16861         return (uint32_t)ret_conv;
16862 }
16863
16864 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
16865         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16866         CHECK_ACCESS(o_ptr);
16867         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
16868         if (o_conv.free == LDKAccess_JCalls_free) {
16869                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16870                 LDKAccess_JCalls_cloned(&o_conv);
16871         }
16872         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16873         *ret_copy = COption_AccessZ_some(o_conv);
16874         uint32_t ret_ref = (uintptr_t)ret_copy;
16875         return ret_ref;
16876 }
16877
16878 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
16879         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16880         *ret_copy = COption_AccessZ_none();
16881         uint32_t ret_ref = (uintptr_t)ret_copy;
16882         return ret_ref;
16883 }
16884
16885 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
16886         if ((_res & 1) != 0) return;
16887         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16888         CHECK_ACCESS(_res_ptr);
16889         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
16890         FREE((void*)_res);
16891         COption_AccessZ_free(_res_conv);
16892 }
16893
16894 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint32_t o) {
16895         LDKChannelUpdateInfo o_conv;
16896         o_conv.inner = (void*)(o & (~1));
16897         o_conv.is_owned = (o & 1) || (o == 0);
16898         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16899         o_conv = ChannelUpdateInfo_clone(&o_conv);
16900         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16901         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
16902         return (uint32_t)ret_conv;
16903 }
16904
16905 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint32_t e) {
16906         LDKDecodeError e_conv;
16907         e_conv.inner = (void*)(e & (~1));
16908         e_conv.is_owned = (e & 1) || (e == 0);
16909         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16910         e_conv = DecodeError_clone(&e_conv);
16911         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16912         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
16913         return (uint32_t)ret_conv;
16914 }
16915
16916 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint32_t o) {
16917         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
16918         jboolean ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
16919         return ret_val;
16920 }
16921
16922 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint32_t _res) {
16923         if ((_res & 1) != 0) return;
16924         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16925         CHECK_ACCESS(_res_ptr);
16926         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
16927         FREE((void*)_res);
16928         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
16929 }
16930
16931 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
16932         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16933         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
16934         return (uint32_t)ret_conv;
16935 }
16936 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16937         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
16938         uint32_t ret_val = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
16939         return ret_val;
16940 }
16941
16942 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint32_t orig) {
16943         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
16944         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16945         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
16946         return (uint32_t)ret_conv;
16947 }
16948
16949 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
16950         LDKChannelInfo o_conv;
16951         o_conv.inner = (void*)(o & (~1));
16952         o_conv.is_owned = (o & 1) || (o == 0);
16953         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16954         o_conv = ChannelInfo_clone(&o_conv);
16955         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16956         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
16957         return (uint32_t)ret_conv;
16958 }
16959
16960 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
16961         LDKDecodeError e_conv;
16962         e_conv.inner = (void*)(e & (~1));
16963         e_conv.is_owned = (e & 1) || (e == 0);
16964         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16965         e_conv = DecodeError_clone(&e_conv);
16966         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16967         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
16968         return (uint32_t)ret_conv;
16969 }
16970
16971 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
16972         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
16973         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
16974         return ret_val;
16975 }
16976
16977 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
16978         if ((_res & 1) != 0) return;
16979         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16980         CHECK_ACCESS(_res_ptr);
16981         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
16982         FREE((void*)_res);
16983         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
16984 }
16985
16986 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
16987         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16988         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
16989         return (uint32_t)ret_conv;
16990 }
16991 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16992         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
16993         uint32_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
16994         return ret_val;
16995 }
16996
16997 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
16998         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
16999         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17000         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
17001         return (uint32_t)ret_conv;
17002 }
17003
17004 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
17005         LDKRoutingFees o_conv;
17006         o_conv.inner = (void*)(o & (~1));
17007         o_conv.is_owned = (o & 1) || (o == 0);
17008         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17009         o_conv = RoutingFees_clone(&o_conv);
17010         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17011         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
17012         return (uint32_t)ret_conv;
17013 }
17014
17015 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
17016         LDKDecodeError e_conv;
17017         e_conv.inner = (void*)(e & (~1));
17018         e_conv.is_owned = (e & 1) || (e == 0);
17019         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17020         e_conv = DecodeError_clone(&e_conv);
17021         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17022         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
17023         return (uint32_t)ret_conv;
17024 }
17025
17026 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
17027         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
17028         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
17029         return ret_val;
17030 }
17031
17032 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
17033         if ((_res & 1) != 0) return;
17034         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17035         CHECK_ACCESS(_res_ptr);
17036         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
17037         FREE((void*)_res);
17038         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
17039 }
17040
17041 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
17042         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17043         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
17044         return (uint32_t)ret_conv;
17045 }
17046 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
17047         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
17048         uint32_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
17049         return ret_val;
17050 }
17051
17052 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
17053         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
17054         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17055         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
17056         return (uint32_t)ret_conv;
17057 }
17058
17059 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
17060         LDKNodeAnnouncementInfo o_conv;
17061         o_conv.inner = (void*)(o & (~1));
17062         o_conv.is_owned = (o & 1) || (o == 0);
17063         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17064         o_conv = NodeAnnouncementInfo_clone(&o_conv);
17065         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17066         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
17067         return (uint32_t)ret_conv;
17068 }
17069
17070 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
17071         LDKDecodeError e_conv;
17072         e_conv.inner = (void*)(e & (~1));
17073         e_conv.is_owned = (e & 1) || (e == 0);
17074         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17075         e_conv = DecodeError_clone(&e_conv);
17076         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17077         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
17078         return (uint32_t)ret_conv;
17079 }
17080
17081 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
17082         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
17083         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
17084         return ret_val;
17085 }
17086
17087 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
17088         if ((_res & 1) != 0) return;
17089         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17090         CHECK_ACCESS(_res_ptr);
17091         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
17092         FREE((void*)_res);
17093         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
17094 }
17095
17096 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
17097         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17098         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
17099         return (uint32_t)ret_conv;
17100 }
17101 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
17102         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
17103         uint32_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
17104         return ret_val;
17105 }
17106
17107 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
17108         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
17109         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17110         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
17111         return (uint32_t)ret_conv;
17112 }
17113
17114 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
17115         LDKCVec_u64Z _res_constr;
17116         _res_constr.datalen = _res->arr_len;
17117         if (_res_constr.datalen > 0)
17118                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17119         else
17120                 _res_constr.data = NULL;
17121         int64_t* _res_vals = _res->elems /* XXX _res leaks */;
17122         for (size_t i = 0; i < _res_constr.datalen; i++) {
17123                 int64_t _res_conv_8 = _res_vals[i];
17124                 _res_constr.data[i] = _res_conv_8;
17125         }
17126         CVec_u64Z_free(_res_constr);
17127 }
17128
17129 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
17130         LDKNodeInfo o_conv;
17131         o_conv.inner = (void*)(o & (~1));
17132         o_conv.is_owned = (o & 1) || (o == 0);
17133         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17134         o_conv = NodeInfo_clone(&o_conv);
17135         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17136         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
17137         return (uint32_t)ret_conv;
17138 }
17139
17140 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
17141         LDKDecodeError e_conv;
17142         e_conv.inner = (void*)(e & (~1));
17143         e_conv.is_owned = (e & 1) || (e == 0);
17144         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17145         e_conv = DecodeError_clone(&e_conv);
17146         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17147         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
17148         return (uint32_t)ret_conv;
17149 }
17150
17151 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
17152         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
17153         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
17154         return ret_val;
17155 }
17156
17157 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
17158         if ((_res & 1) != 0) return;
17159         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17160         CHECK_ACCESS(_res_ptr);
17161         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
17162         FREE((void*)_res);
17163         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
17164 }
17165
17166 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
17167         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17168         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
17169         return (uint32_t)ret_conv;
17170 }
17171 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
17172         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
17173         uint32_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
17174         return ret_val;
17175 }
17176
17177 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
17178         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
17179         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17180         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
17181         return (uint32_t)ret_conv;
17182 }
17183
17184 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
17185         LDKNetworkGraph o_conv;
17186         o_conv.inner = (void*)(o & (~1));
17187         o_conv.is_owned = (o & 1) || (o == 0);
17188         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17189         o_conv = NetworkGraph_clone(&o_conv);
17190         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17191         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
17192         return (uint32_t)ret_conv;
17193 }
17194
17195 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
17196         LDKDecodeError e_conv;
17197         e_conv.inner = (void*)(e & (~1));
17198         e_conv.is_owned = (e & 1) || (e == 0);
17199         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17200         e_conv = DecodeError_clone(&e_conv);
17201         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17202         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
17203         return (uint32_t)ret_conv;
17204 }
17205
17206 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
17207         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
17208         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
17209         return ret_val;
17210 }
17211
17212 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
17213         if ((_res & 1) != 0) return;
17214         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17215         CHECK_ACCESS(_res_ptr);
17216         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
17217         FREE((void*)_res);
17218         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
17219 }
17220
17221 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
17222         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17223         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
17224         return (uint32_t)ret_conv;
17225 }
17226 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr"))) TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr(uint32_t arg) {
17227         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
17228         uint32_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
17229         return ret_val;
17230 }
17231
17232 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
17233         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
17234         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17235         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
17236         return (uint32_t)ret_conv;
17237 }
17238
17239 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
17240         LDKCVec_NetAddressZ o_constr;
17241         o_constr.datalen = o->arr_len;
17242         if (o_constr.datalen > 0)
17243                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17244         else
17245                 o_constr.data = NULL;
17246         uint32_t* o_vals = o->elems /* XXX o leaks */;
17247         for (size_t m = 0; m < o_constr.datalen; m++) {
17248                 uint32_t o_conv_12 = o_vals[m];
17249                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
17250                 CHECK_ACCESS(o_conv_12_ptr);
17251                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
17252                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
17253                 o_constr.data[m] = o_conv_12_conv;
17254         }
17255         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17256         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
17257         uint32_t ret_ref = (uintptr_t)ret_copy;
17258         return ret_ref;
17259 }
17260
17261 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
17262         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17263         *ret_copy = COption_CVec_NetAddressZZ_none();
17264         uint32_t ret_ref = (uintptr_t)ret_copy;
17265         return ret_ref;
17266 }
17267
17268 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
17269         if ((_res & 1) != 0) return;
17270         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17271         CHECK_ACCESS(_res_ptr);
17272         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
17273         FREE((void*)_res);
17274         COption_CVec_NetAddressZZ_free(_res_conv);
17275 }
17276
17277 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
17278         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17279         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
17280 uint32_t ret_ref = (uintptr_t)ret_copy;
17281         return ret_ref;
17282 }
17283 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
17284         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
17285         uint32_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
17286         return ret_val;
17287 }
17288
17289 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
17290         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
17291         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17292         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
17293         uint32_t ret_ref = (uintptr_t)ret_copy;
17294         return ret_ref;
17295 }
17296
17297 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
17298         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17299         CHECK_ACCESS(o_ptr);
17300         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17301         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
17302         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17303         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
17304         return (uint32_t)ret_conv;
17305 }
17306
17307 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
17308         LDKDecodeError e_conv;
17309         e_conv.inner = (void*)(e & (~1));
17310         e_conv.is_owned = (e & 1) || (e == 0);
17311         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17312         e_conv = DecodeError_clone(&e_conv);
17313         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17314         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
17315         return (uint32_t)ret_conv;
17316 }
17317
17318 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
17319         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
17320         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
17321         return ret_val;
17322 }
17323
17324 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
17325         if ((_res & 1) != 0) return;
17326         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17327         CHECK_ACCESS(_res_ptr);
17328         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
17329         FREE((void*)_res);
17330         CResult_NetAddressDecodeErrorZ_free(_res_conv);
17331 }
17332
17333 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
17334         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17335         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
17336         return (uint32_t)ret_conv;
17337 }
17338 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
17339         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
17340         uint32_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
17341         return ret_val;
17342 }
17343
17344 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
17345         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
17346         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17347         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
17348         return (uint32_t)ret_conv;
17349 }
17350
17351 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
17352         LDKCVec_UpdateAddHTLCZ _res_constr;
17353         _res_constr.datalen = _res->arr_len;
17354         if (_res_constr.datalen > 0)
17355                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17356         else
17357                 _res_constr.data = NULL;
17358         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17359         for (size_t p = 0; p < _res_constr.datalen; p++) {
17360                 uint32_t _res_conv_15 = _res_vals[p];
17361                 LDKUpdateAddHTLC _res_conv_15_conv;
17362                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
17363                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
17364                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
17365                 _res_constr.data[p] = _res_conv_15_conv;
17366         }
17367         CVec_UpdateAddHTLCZ_free(_res_constr);
17368 }
17369
17370 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
17371         LDKCVec_UpdateFulfillHTLCZ _res_constr;
17372         _res_constr.datalen = _res->arr_len;
17373         if (_res_constr.datalen > 0)
17374                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17375         else
17376                 _res_constr.data = NULL;
17377         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17378         for (size_t t = 0; t < _res_constr.datalen; t++) {
17379                 uint32_t _res_conv_19 = _res_vals[t];
17380                 LDKUpdateFulfillHTLC _res_conv_19_conv;
17381                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
17382                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
17383                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
17384                 _res_constr.data[t] = _res_conv_19_conv;
17385         }
17386         CVec_UpdateFulfillHTLCZ_free(_res_constr);
17387 }
17388
17389 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
17390         LDKCVec_UpdateFailHTLCZ _res_constr;
17391         _res_constr.datalen = _res->arr_len;
17392         if (_res_constr.datalen > 0)
17393                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17394         else
17395                 _res_constr.data = NULL;
17396         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17397         for (size_t q = 0; q < _res_constr.datalen; q++) {
17398                 uint32_t _res_conv_16 = _res_vals[q];
17399                 LDKUpdateFailHTLC _res_conv_16_conv;
17400                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
17401                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
17402                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17403                 _res_constr.data[q] = _res_conv_16_conv;
17404         }
17405         CVec_UpdateFailHTLCZ_free(_res_constr);
17406 }
17407
17408 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
17409         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
17410         _res_constr.datalen = _res->arr_len;
17411         if (_res_constr.datalen > 0)
17412                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17413         else
17414                 _res_constr.data = NULL;
17415         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17416         for (size_t z = 0; z < _res_constr.datalen; z++) {
17417                 uint32_t _res_conv_25 = _res_vals[z];
17418                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
17419                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
17420                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
17421                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
17422                 _res_constr.data[z] = _res_conv_25_conv;
17423         }
17424         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
17425 }
17426
17427 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
17428         LDKAcceptChannel o_conv;
17429         o_conv.inner = (void*)(o & (~1));
17430         o_conv.is_owned = (o & 1) || (o == 0);
17431         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17432         o_conv = AcceptChannel_clone(&o_conv);
17433         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17434         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
17435         return (uint32_t)ret_conv;
17436 }
17437
17438 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
17439         LDKDecodeError e_conv;
17440         e_conv.inner = (void*)(e & (~1));
17441         e_conv.is_owned = (e & 1) || (e == 0);
17442         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17443         e_conv = DecodeError_clone(&e_conv);
17444         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17445         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
17446         return (uint32_t)ret_conv;
17447 }
17448
17449 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
17450         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
17451         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
17452         return ret_val;
17453 }
17454
17455 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
17456         if ((_res & 1) != 0) return;
17457         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17458         CHECK_ACCESS(_res_ptr);
17459         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
17460         FREE((void*)_res);
17461         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
17462 }
17463
17464 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
17465         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17466         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
17467         return (uint32_t)ret_conv;
17468 }
17469 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
17470         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
17471         uint32_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
17472         return ret_val;
17473 }
17474
17475 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
17476         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
17477         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17478         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
17479         return (uint32_t)ret_conv;
17480 }
17481
17482 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
17483         LDKAnnouncementSignatures o_conv;
17484         o_conv.inner = (void*)(o & (~1));
17485         o_conv.is_owned = (o & 1) || (o == 0);
17486         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17487         o_conv = AnnouncementSignatures_clone(&o_conv);
17488         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17489         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
17490         return (uint32_t)ret_conv;
17491 }
17492
17493 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
17494         LDKDecodeError e_conv;
17495         e_conv.inner = (void*)(e & (~1));
17496         e_conv.is_owned = (e & 1) || (e == 0);
17497         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17498         e_conv = DecodeError_clone(&e_conv);
17499         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17500         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
17501         return (uint32_t)ret_conv;
17502 }
17503
17504 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
17505         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
17506         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
17507         return ret_val;
17508 }
17509
17510 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
17511         if ((_res & 1) != 0) return;
17512         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17513         CHECK_ACCESS(_res_ptr);
17514         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
17515         FREE((void*)_res);
17516         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
17517 }
17518
17519 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
17520         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17521         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
17522         return (uint32_t)ret_conv;
17523 }
17524 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
17525         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
17526         uint32_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
17527         return ret_val;
17528 }
17529
17530 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
17531         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
17532         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17533         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
17534         return (uint32_t)ret_conv;
17535 }
17536
17537 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
17538         LDKChannelReestablish o_conv;
17539         o_conv.inner = (void*)(o & (~1));
17540         o_conv.is_owned = (o & 1) || (o == 0);
17541         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17542         o_conv = ChannelReestablish_clone(&o_conv);
17543         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17544         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
17545         return (uint32_t)ret_conv;
17546 }
17547
17548 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
17549         LDKDecodeError e_conv;
17550         e_conv.inner = (void*)(e & (~1));
17551         e_conv.is_owned = (e & 1) || (e == 0);
17552         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17553         e_conv = DecodeError_clone(&e_conv);
17554         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17555         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
17556         return (uint32_t)ret_conv;
17557 }
17558
17559 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
17560         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
17561         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
17562         return ret_val;
17563 }
17564
17565 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
17566         if ((_res & 1) != 0) return;
17567         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17568         CHECK_ACCESS(_res_ptr);
17569         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
17570         FREE((void*)_res);
17571         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
17572 }
17573
17574 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
17575         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17576         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
17577         return (uint32_t)ret_conv;
17578 }
17579 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
17580         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
17581         uint32_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
17582         return ret_val;
17583 }
17584
17585 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
17586         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
17587         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17588         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
17589         return (uint32_t)ret_conv;
17590 }
17591
17592 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
17593         LDKClosingSigned o_conv;
17594         o_conv.inner = (void*)(o & (~1));
17595         o_conv.is_owned = (o & 1) || (o == 0);
17596         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17597         o_conv = ClosingSigned_clone(&o_conv);
17598         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17599         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
17600         return (uint32_t)ret_conv;
17601 }
17602
17603 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
17604         LDKDecodeError e_conv;
17605         e_conv.inner = (void*)(e & (~1));
17606         e_conv.is_owned = (e & 1) || (e == 0);
17607         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17608         e_conv = DecodeError_clone(&e_conv);
17609         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17610         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
17611         return (uint32_t)ret_conv;
17612 }
17613
17614 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
17615         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
17616         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
17617         return ret_val;
17618 }
17619
17620 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
17621         if ((_res & 1) != 0) return;
17622         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17623         CHECK_ACCESS(_res_ptr);
17624         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
17625         FREE((void*)_res);
17626         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
17627 }
17628
17629 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
17630         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17631         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
17632         return (uint32_t)ret_conv;
17633 }
17634 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17635         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
17636         uint32_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
17637         return ret_val;
17638 }
17639
17640 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
17641         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
17642         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17643         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
17644         return (uint32_t)ret_conv;
17645 }
17646
17647 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
17648         LDKClosingSignedFeeRange o_conv;
17649         o_conv.inner = (void*)(o & (~1));
17650         o_conv.is_owned = (o & 1) || (o == 0);
17651         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17652         o_conv = ClosingSignedFeeRange_clone(&o_conv);
17653         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17654         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
17655         return (uint32_t)ret_conv;
17656 }
17657
17658 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
17659         LDKDecodeError e_conv;
17660         e_conv.inner = (void*)(e & (~1));
17661         e_conv.is_owned = (e & 1) || (e == 0);
17662         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17663         e_conv = DecodeError_clone(&e_conv);
17664         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17665         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
17666         return (uint32_t)ret_conv;
17667 }
17668
17669 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
17670         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
17671         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
17672         return ret_val;
17673 }
17674
17675 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
17676         if ((_res & 1) != 0) return;
17677         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17678         CHECK_ACCESS(_res_ptr);
17679         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
17680         FREE((void*)_res);
17681         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
17682 }
17683
17684 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
17685         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17686         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
17687         return (uint32_t)ret_conv;
17688 }
17689 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
17690         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
17691         uint32_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
17692         return ret_val;
17693 }
17694
17695 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
17696         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
17697         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17698         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
17699         return (uint32_t)ret_conv;
17700 }
17701
17702 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
17703         LDKCommitmentSigned o_conv;
17704         o_conv.inner = (void*)(o & (~1));
17705         o_conv.is_owned = (o & 1) || (o == 0);
17706         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17707         o_conv = CommitmentSigned_clone(&o_conv);
17708         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17709         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
17710         return (uint32_t)ret_conv;
17711 }
17712
17713 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
17714         LDKDecodeError e_conv;
17715         e_conv.inner = (void*)(e & (~1));
17716         e_conv.is_owned = (e & 1) || (e == 0);
17717         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17718         e_conv = DecodeError_clone(&e_conv);
17719         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17720         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
17721         return (uint32_t)ret_conv;
17722 }
17723
17724 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
17725         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
17726         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
17727         return ret_val;
17728 }
17729
17730 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
17731         if ((_res & 1) != 0) return;
17732         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17733         CHECK_ACCESS(_res_ptr);
17734         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
17735         FREE((void*)_res);
17736         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
17737 }
17738
17739 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
17740         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17741         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
17742         return (uint32_t)ret_conv;
17743 }
17744 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17745         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
17746         uint32_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
17747         return ret_val;
17748 }
17749
17750 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
17751         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
17752         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17753         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
17754         return (uint32_t)ret_conv;
17755 }
17756
17757 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
17758         LDKFundingCreated o_conv;
17759         o_conv.inner = (void*)(o & (~1));
17760         o_conv.is_owned = (o & 1) || (o == 0);
17761         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17762         o_conv = FundingCreated_clone(&o_conv);
17763         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17764         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
17765         return (uint32_t)ret_conv;
17766 }
17767
17768 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
17769         LDKDecodeError e_conv;
17770         e_conv.inner = (void*)(e & (~1));
17771         e_conv.is_owned = (e & 1) || (e == 0);
17772         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17773         e_conv = DecodeError_clone(&e_conv);
17774         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17775         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
17776         return (uint32_t)ret_conv;
17777 }
17778
17779 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
17780         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
17781         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
17782         return ret_val;
17783 }
17784
17785 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
17786         if ((_res & 1) != 0) return;
17787         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17788         CHECK_ACCESS(_res_ptr);
17789         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
17790         FREE((void*)_res);
17791         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
17792 }
17793
17794 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
17795         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17796         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
17797         return (uint32_t)ret_conv;
17798 }
17799 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
17800         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
17801         uint32_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
17802         return ret_val;
17803 }
17804
17805 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
17806         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
17807         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17808         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
17809         return (uint32_t)ret_conv;
17810 }
17811
17812 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
17813         LDKFundingSigned o_conv;
17814         o_conv.inner = (void*)(o & (~1));
17815         o_conv.is_owned = (o & 1) || (o == 0);
17816         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17817         o_conv = FundingSigned_clone(&o_conv);
17818         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17819         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
17820         return (uint32_t)ret_conv;
17821 }
17822
17823 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
17824         LDKDecodeError e_conv;
17825         e_conv.inner = (void*)(e & (~1));
17826         e_conv.is_owned = (e & 1) || (e == 0);
17827         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17828         e_conv = DecodeError_clone(&e_conv);
17829         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17830         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
17831         return (uint32_t)ret_conv;
17832 }
17833
17834 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
17835         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
17836         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
17837         return ret_val;
17838 }
17839
17840 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
17841         if ((_res & 1) != 0) return;
17842         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17843         CHECK_ACCESS(_res_ptr);
17844         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
17845         FREE((void*)_res);
17846         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
17847 }
17848
17849 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
17850         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17851         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
17852         return (uint32_t)ret_conv;
17853 }
17854 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17855         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
17856         uint32_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
17857         return ret_val;
17858 }
17859
17860 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
17861         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
17862         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17863         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
17864         return (uint32_t)ret_conv;
17865 }
17866
17867 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_ok"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
17868         LDKFundingLocked o_conv;
17869         o_conv.inner = (void*)(o & (~1));
17870         o_conv.is_owned = (o & 1) || (o == 0);
17871         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17872         o_conv = FundingLocked_clone(&o_conv);
17873         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17874         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
17875         return (uint32_t)ret_conv;
17876 }
17877
17878 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_err"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
17879         LDKDecodeError e_conv;
17880         e_conv.inner = (void*)(e & (~1));
17881         e_conv.is_owned = (e & 1) || (e == 0);
17882         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17883         e_conv = DecodeError_clone(&e_conv);
17884         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17885         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
17886         return (uint32_t)ret_conv;
17887 }
17888
17889 jboolean  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_is_ok"))) TS_CResult_FundingLockedDecodeErrorZ_is_ok(uint32_t o) {
17890         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
17891         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
17892         return ret_val;
17893 }
17894
17895 void  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_free"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
17896         if ((_res & 1) != 0) return;
17897         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17898         CHECK_ACCESS(_res_ptr);
17899         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
17900         FREE((void*)_res);
17901         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
17902 }
17903
17904 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
17905         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17906         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
17907         return (uint32_t)ret_conv;
17908 }
17909 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingLockedDecodeErrorZ_clone_ptr(uint32_t arg) {
17910         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
17911         uint32_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
17912         return ret_val;
17913 }
17914
17915 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
17916         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
17917         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17918         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
17919         return (uint32_t)ret_conv;
17920 }
17921
17922 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
17923         LDKInit o_conv;
17924         o_conv.inner = (void*)(o & (~1));
17925         o_conv.is_owned = (o & 1) || (o == 0);
17926         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17927         o_conv = Init_clone(&o_conv);
17928         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17929         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
17930         return (uint32_t)ret_conv;
17931 }
17932
17933 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
17934         LDKDecodeError e_conv;
17935         e_conv.inner = (void*)(e & (~1));
17936         e_conv.is_owned = (e & 1) || (e == 0);
17937         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17938         e_conv = DecodeError_clone(&e_conv);
17939         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17940         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
17941         return (uint32_t)ret_conv;
17942 }
17943
17944 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
17945         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
17946         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
17947         return ret_val;
17948 }
17949
17950 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
17951         if ((_res & 1) != 0) return;
17952         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17953         CHECK_ACCESS(_res_ptr);
17954         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
17955         FREE((void*)_res);
17956         CResult_InitDecodeErrorZ_free(_res_conv);
17957 }
17958
17959 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
17960         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17961         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
17962         return (uint32_t)ret_conv;
17963 }
17964 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
17965         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
17966         uint32_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
17967         return ret_val;
17968 }
17969
17970 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
17971         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
17972         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17973         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
17974         return (uint32_t)ret_conv;
17975 }
17976
17977 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
17978         LDKOpenChannel o_conv;
17979         o_conv.inner = (void*)(o & (~1));
17980         o_conv.is_owned = (o & 1) || (o == 0);
17981         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17982         o_conv = OpenChannel_clone(&o_conv);
17983         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17984         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
17985         return (uint32_t)ret_conv;
17986 }
17987
17988 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
17989         LDKDecodeError e_conv;
17990         e_conv.inner = (void*)(e & (~1));
17991         e_conv.is_owned = (e & 1) || (e == 0);
17992         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17993         e_conv = DecodeError_clone(&e_conv);
17994         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17995         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
17996         return (uint32_t)ret_conv;
17997 }
17998
17999 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
18000         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
18001         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
18002         return ret_val;
18003 }
18004
18005 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
18006         if ((_res & 1) != 0) return;
18007         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18008         CHECK_ACCESS(_res_ptr);
18009         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
18010         FREE((void*)_res);
18011         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
18012 }
18013
18014 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
18015         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18016         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
18017         return (uint32_t)ret_conv;
18018 }
18019 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
18020         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
18021         uint32_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
18022         return ret_val;
18023 }
18024
18025 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
18026         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
18027         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18028         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
18029         return (uint32_t)ret_conv;
18030 }
18031
18032 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
18033         LDKRevokeAndACK o_conv;
18034         o_conv.inner = (void*)(o & (~1));
18035         o_conv.is_owned = (o & 1) || (o == 0);
18036         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18037         o_conv = RevokeAndACK_clone(&o_conv);
18038         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18039         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
18040         return (uint32_t)ret_conv;
18041 }
18042
18043 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
18044         LDKDecodeError e_conv;
18045         e_conv.inner = (void*)(e & (~1));
18046         e_conv.is_owned = (e & 1) || (e == 0);
18047         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18048         e_conv = DecodeError_clone(&e_conv);
18049         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18050         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
18051         return (uint32_t)ret_conv;
18052 }
18053
18054 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
18055         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
18056         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
18057         return ret_val;
18058 }
18059
18060 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
18061         if ((_res & 1) != 0) return;
18062         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18063         CHECK_ACCESS(_res_ptr);
18064         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
18065         FREE((void*)_res);
18066         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
18067 }
18068
18069 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
18070         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18071         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
18072         return (uint32_t)ret_conv;
18073 }
18074 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
18075         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
18076         uint32_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
18077         return ret_val;
18078 }
18079
18080 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
18081         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
18082         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18083         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
18084         return (uint32_t)ret_conv;
18085 }
18086
18087 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
18088         LDKShutdown o_conv;
18089         o_conv.inner = (void*)(o & (~1));
18090         o_conv.is_owned = (o & 1) || (o == 0);
18091         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18092         o_conv = Shutdown_clone(&o_conv);
18093         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18094         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
18095         return (uint32_t)ret_conv;
18096 }
18097
18098 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
18099         LDKDecodeError e_conv;
18100         e_conv.inner = (void*)(e & (~1));
18101         e_conv.is_owned = (e & 1) || (e == 0);
18102         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18103         e_conv = DecodeError_clone(&e_conv);
18104         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18105         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
18106         return (uint32_t)ret_conv;
18107 }
18108
18109 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
18110         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
18111         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
18112         return ret_val;
18113 }
18114
18115 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
18116         if ((_res & 1) != 0) return;
18117         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18118         CHECK_ACCESS(_res_ptr);
18119         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
18120         FREE((void*)_res);
18121         CResult_ShutdownDecodeErrorZ_free(_res_conv);
18122 }
18123
18124 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
18125         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18126         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
18127         return (uint32_t)ret_conv;
18128 }
18129 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
18130         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
18131         uint32_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
18132         return ret_val;
18133 }
18134
18135 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
18136         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
18137         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18138         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
18139         return (uint32_t)ret_conv;
18140 }
18141
18142 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
18143         LDKUpdateFailHTLC o_conv;
18144         o_conv.inner = (void*)(o & (~1));
18145         o_conv.is_owned = (o & 1) || (o == 0);
18146         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18147         o_conv = UpdateFailHTLC_clone(&o_conv);
18148         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18149         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
18150         return (uint32_t)ret_conv;
18151 }
18152
18153 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
18154         LDKDecodeError e_conv;
18155         e_conv.inner = (void*)(e & (~1));
18156         e_conv.is_owned = (e & 1) || (e == 0);
18157         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18158         e_conv = DecodeError_clone(&e_conv);
18159         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18160         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
18161         return (uint32_t)ret_conv;
18162 }
18163
18164 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
18165         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
18166         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
18167         return ret_val;
18168 }
18169
18170 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
18171         if ((_res & 1) != 0) return;
18172         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18173         CHECK_ACCESS(_res_ptr);
18174         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
18175         FREE((void*)_res);
18176         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
18177 }
18178
18179 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
18180         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18181         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
18182         return (uint32_t)ret_conv;
18183 }
18184 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18185         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
18186         uint32_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
18187         return ret_val;
18188 }
18189
18190 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
18191         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
18192         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18193         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
18194         return (uint32_t)ret_conv;
18195 }
18196
18197 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
18198         LDKUpdateFailMalformedHTLC o_conv;
18199         o_conv.inner = (void*)(o & (~1));
18200         o_conv.is_owned = (o & 1) || (o == 0);
18201         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18202         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
18203         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18204         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
18205         return (uint32_t)ret_conv;
18206 }
18207
18208 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
18209         LDKDecodeError e_conv;
18210         e_conv.inner = (void*)(e & (~1));
18211         e_conv.is_owned = (e & 1) || (e == 0);
18212         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18213         e_conv = DecodeError_clone(&e_conv);
18214         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18215         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
18216         return (uint32_t)ret_conv;
18217 }
18218
18219 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
18220         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
18221         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
18222         return ret_val;
18223 }
18224
18225 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
18226         if ((_res & 1) != 0) return;
18227         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18228         CHECK_ACCESS(_res_ptr);
18229         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
18230         FREE((void*)_res);
18231         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
18232 }
18233
18234 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
18235         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18236         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
18237         return (uint32_t)ret_conv;
18238 }
18239 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18240         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
18241         uint32_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
18242         return ret_val;
18243 }
18244
18245 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
18246         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
18247         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18248         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
18249         return (uint32_t)ret_conv;
18250 }
18251
18252 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
18253         LDKUpdateFee o_conv;
18254         o_conv.inner = (void*)(o & (~1));
18255         o_conv.is_owned = (o & 1) || (o == 0);
18256         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18257         o_conv = UpdateFee_clone(&o_conv);
18258         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18259         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
18260         return (uint32_t)ret_conv;
18261 }
18262
18263 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
18264         LDKDecodeError e_conv;
18265         e_conv.inner = (void*)(e & (~1));
18266         e_conv.is_owned = (e & 1) || (e == 0);
18267         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18268         e_conv = DecodeError_clone(&e_conv);
18269         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18270         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
18271         return (uint32_t)ret_conv;
18272 }
18273
18274 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
18275         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
18276         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
18277         return ret_val;
18278 }
18279
18280 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
18281         if ((_res & 1) != 0) return;
18282         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18283         CHECK_ACCESS(_res_ptr);
18284         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
18285         FREE((void*)_res);
18286         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
18287 }
18288
18289 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
18290         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18291         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
18292         return (uint32_t)ret_conv;
18293 }
18294 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
18295         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
18296         uint32_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
18297         return ret_val;
18298 }
18299
18300 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
18301         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
18302         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18303         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
18304         return (uint32_t)ret_conv;
18305 }
18306
18307 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
18308         LDKUpdateFulfillHTLC o_conv;
18309         o_conv.inner = (void*)(o & (~1));
18310         o_conv.is_owned = (o & 1) || (o == 0);
18311         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18312         o_conv = UpdateFulfillHTLC_clone(&o_conv);
18313         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18314         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
18315         return (uint32_t)ret_conv;
18316 }
18317
18318 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
18319         LDKDecodeError e_conv;
18320         e_conv.inner = (void*)(e & (~1));
18321         e_conv.is_owned = (e & 1) || (e == 0);
18322         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18323         e_conv = DecodeError_clone(&e_conv);
18324         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18325         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
18326         return (uint32_t)ret_conv;
18327 }
18328
18329 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
18330         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
18331         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
18332         return ret_val;
18333 }
18334
18335 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
18336         if ((_res & 1) != 0) return;
18337         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18338         CHECK_ACCESS(_res_ptr);
18339         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
18340         FREE((void*)_res);
18341         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
18342 }
18343
18344 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
18345         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18346         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
18347         return (uint32_t)ret_conv;
18348 }
18349 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18350         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
18351         uint32_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
18352         return ret_val;
18353 }
18354
18355 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
18356         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
18357         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18358         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
18359         return (uint32_t)ret_conv;
18360 }
18361
18362 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
18363         LDKUpdateAddHTLC o_conv;
18364         o_conv.inner = (void*)(o & (~1));
18365         o_conv.is_owned = (o & 1) || (o == 0);
18366         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18367         o_conv = UpdateAddHTLC_clone(&o_conv);
18368         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18369         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
18370         return (uint32_t)ret_conv;
18371 }
18372
18373 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
18374         LDKDecodeError e_conv;
18375         e_conv.inner = (void*)(e & (~1));
18376         e_conv.is_owned = (e & 1) || (e == 0);
18377         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18378         e_conv = DecodeError_clone(&e_conv);
18379         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18380         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
18381         return (uint32_t)ret_conv;
18382 }
18383
18384 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
18385         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
18386         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
18387         return ret_val;
18388 }
18389
18390 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
18391         if ((_res & 1) != 0) return;
18392         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18393         CHECK_ACCESS(_res_ptr);
18394         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
18395         FREE((void*)_res);
18396         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
18397 }
18398
18399 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
18400         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18401         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
18402         return (uint32_t)ret_conv;
18403 }
18404 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18405         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
18406         uint32_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
18407         return ret_val;
18408 }
18409
18410 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
18411         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
18412         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18413         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
18414         return (uint32_t)ret_conv;
18415 }
18416
18417 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
18418         LDKPing o_conv;
18419         o_conv.inner = (void*)(o & (~1));
18420         o_conv.is_owned = (o & 1) || (o == 0);
18421         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18422         o_conv = Ping_clone(&o_conv);
18423         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18424         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
18425         return (uint32_t)ret_conv;
18426 }
18427
18428 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
18429         LDKDecodeError e_conv;
18430         e_conv.inner = (void*)(e & (~1));
18431         e_conv.is_owned = (e & 1) || (e == 0);
18432         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18433         e_conv = DecodeError_clone(&e_conv);
18434         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18435         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
18436         return (uint32_t)ret_conv;
18437 }
18438
18439 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
18440         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
18441         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
18442         return ret_val;
18443 }
18444
18445 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
18446         if ((_res & 1) != 0) return;
18447         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18448         CHECK_ACCESS(_res_ptr);
18449         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
18450         FREE((void*)_res);
18451         CResult_PingDecodeErrorZ_free(_res_conv);
18452 }
18453
18454 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
18455         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18456         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
18457         return (uint32_t)ret_conv;
18458 }
18459 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
18460         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
18461         uint32_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
18462         return ret_val;
18463 }
18464
18465 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
18466         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
18467         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18468         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
18469         return (uint32_t)ret_conv;
18470 }
18471
18472 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
18473         LDKPong o_conv;
18474         o_conv.inner = (void*)(o & (~1));
18475         o_conv.is_owned = (o & 1) || (o == 0);
18476         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18477         o_conv = Pong_clone(&o_conv);
18478         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18479         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
18480         return (uint32_t)ret_conv;
18481 }
18482
18483 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
18484         LDKDecodeError e_conv;
18485         e_conv.inner = (void*)(e & (~1));
18486         e_conv.is_owned = (e & 1) || (e == 0);
18487         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18488         e_conv = DecodeError_clone(&e_conv);
18489         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18490         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
18491         return (uint32_t)ret_conv;
18492 }
18493
18494 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
18495         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
18496         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
18497         return ret_val;
18498 }
18499
18500 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
18501         if ((_res & 1) != 0) return;
18502         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18503         CHECK_ACCESS(_res_ptr);
18504         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
18505         FREE((void*)_res);
18506         CResult_PongDecodeErrorZ_free(_res_conv);
18507 }
18508
18509 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
18510         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18511         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
18512         return (uint32_t)ret_conv;
18513 }
18514 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
18515         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
18516         uint32_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
18517         return ret_val;
18518 }
18519
18520 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
18521         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
18522         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18523         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
18524         return (uint32_t)ret_conv;
18525 }
18526
18527 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18528         LDKUnsignedChannelAnnouncement o_conv;
18529         o_conv.inner = (void*)(o & (~1));
18530         o_conv.is_owned = (o & 1) || (o == 0);
18531         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18532         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
18533         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18534         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
18535         return (uint32_t)ret_conv;
18536 }
18537
18538 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
18539         LDKDecodeError e_conv;
18540         e_conv.inner = (void*)(e & (~1));
18541         e_conv.is_owned = (e & 1) || (e == 0);
18542         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18543         e_conv = DecodeError_clone(&e_conv);
18544         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18545         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
18546         return (uint32_t)ret_conv;
18547 }
18548
18549 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18550         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
18551         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18552         return ret_val;
18553 }
18554
18555 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
18556         if ((_res & 1) != 0) return;
18557         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18558         CHECK_ACCESS(_res_ptr);
18559         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18560         FREE((void*)_res);
18561         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
18562 }
18563
18564 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18565         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18566         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
18567         return (uint32_t)ret_conv;
18568 }
18569 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18570         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18571         uint32_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18572         return ret_val;
18573 }
18574
18575 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18576         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18577         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18578         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18579         return (uint32_t)ret_conv;
18580 }
18581
18582 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18583         LDKChannelAnnouncement o_conv;
18584         o_conv.inner = (void*)(o & (~1));
18585         o_conv.is_owned = (o & 1) || (o == 0);
18586         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18587         o_conv = ChannelAnnouncement_clone(&o_conv);
18588         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18589         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
18590         return (uint32_t)ret_conv;
18591 }
18592
18593 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
18594         LDKDecodeError e_conv;
18595         e_conv.inner = (void*)(e & (~1));
18596         e_conv.is_owned = (e & 1) || (e == 0);
18597         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18598         e_conv = DecodeError_clone(&e_conv);
18599         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18600         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
18601         return (uint32_t)ret_conv;
18602 }
18603
18604 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18605         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
18606         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18607         return ret_val;
18608 }
18609
18610 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
18611         if ((_res & 1) != 0) return;
18612         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18613         CHECK_ACCESS(_res_ptr);
18614         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18615         FREE((void*)_res);
18616         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
18617 }
18618
18619 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18620         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18621         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
18622         return (uint32_t)ret_conv;
18623 }
18624 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18625         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18626         uint32_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18627         return ret_val;
18628 }
18629
18630 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18631         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18632         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18633         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18634         return (uint32_t)ret_conv;
18635 }
18636
18637 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18638         LDKUnsignedChannelUpdate o_conv;
18639         o_conv.inner = (void*)(o & (~1));
18640         o_conv.is_owned = (o & 1) || (o == 0);
18641         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18642         o_conv = UnsignedChannelUpdate_clone(&o_conv);
18643         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18644         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
18645         return (uint32_t)ret_conv;
18646 }
18647
18648 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
18649         LDKDecodeError e_conv;
18650         e_conv.inner = (void*)(e & (~1));
18651         e_conv.is_owned = (e & 1) || (e == 0);
18652         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18653         e_conv = DecodeError_clone(&e_conv);
18654         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18655         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
18656         return (uint32_t)ret_conv;
18657 }
18658
18659 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18660         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
18661         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
18662         return ret_val;
18663 }
18664
18665 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
18666         if ((_res & 1) != 0) return;
18667         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18668         CHECK_ACCESS(_res_ptr);
18669         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
18670         FREE((void*)_res);
18671         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
18672 }
18673
18674 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18675         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18676         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
18677         return (uint32_t)ret_conv;
18678 }
18679 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18680         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
18681         uint32_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18682         return ret_val;
18683 }
18684
18685 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18686         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
18687         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18688         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
18689         return (uint32_t)ret_conv;
18690 }
18691
18692 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18693         LDKChannelUpdate o_conv;
18694         o_conv.inner = (void*)(o & (~1));
18695         o_conv.is_owned = (o & 1) || (o == 0);
18696         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18697         o_conv = ChannelUpdate_clone(&o_conv);
18698         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18699         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
18700         return (uint32_t)ret_conv;
18701 }
18702
18703 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
18704         LDKDecodeError e_conv;
18705         e_conv.inner = (void*)(e & (~1));
18706         e_conv.is_owned = (e & 1) || (e == 0);
18707         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18708         e_conv = DecodeError_clone(&e_conv);
18709         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18710         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
18711         return (uint32_t)ret_conv;
18712 }
18713
18714 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18715         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
18716         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
18717         return ret_val;
18718 }
18719
18720 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
18721         if ((_res & 1) != 0) return;
18722         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18723         CHECK_ACCESS(_res_ptr);
18724         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
18725         FREE((void*)_res);
18726         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
18727 }
18728
18729 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18730         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18731         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
18732         return (uint32_t)ret_conv;
18733 }
18734 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18735         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
18736         uint32_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18737         return ret_val;
18738 }
18739
18740 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18741         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
18742         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18743         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
18744         return (uint32_t)ret_conv;
18745 }
18746
18747 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
18748         LDKErrorMessage o_conv;
18749         o_conv.inner = (void*)(o & (~1));
18750         o_conv.is_owned = (o & 1) || (o == 0);
18751         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18752         o_conv = ErrorMessage_clone(&o_conv);
18753         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18754         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
18755         return (uint32_t)ret_conv;
18756 }
18757
18758 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
18759         LDKDecodeError e_conv;
18760         e_conv.inner = (void*)(e & (~1));
18761         e_conv.is_owned = (e & 1) || (e == 0);
18762         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18763         e_conv = DecodeError_clone(&e_conv);
18764         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18765         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
18766         return (uint32_t)ret_conv;
18767 }
18768
18769 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
18770         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
18771         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
18772         return ret_val;
18773 }
18774
18775 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
18776         if ((_res & 1) != 0) return;
18777         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18778         CHECK_ACCESS(_res_ptr);
18779         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
18780         FREE((void*)_res);
18781         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
18782 }
18783
18784 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
18785         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18786         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
18787         return (uint32_t)ret_conv;
18788 }
18789 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18790         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
18791         uint32_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
18792         return ret_val;
18793 }
18794
18795 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
18796         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
18797         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18798         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
18799         return (uint32_t)ret_conv;
18800 }
18801
18802 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint32_t o) {
18803         LDKWarningMessage o_conv;
18804         o_conv.inner = (void*)(o & (~1));
18805         o_conv.is_owned = (o & 1) || (o == 0);
18806         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18807         o_conv = WarningMessage_clone(&o_conv);
18808         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18809         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
18810         return (uint32_t)ret_conv;
18811 }
18812
18813 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_err(uint32_t e) {
18814         LDKDecodeError e_conv;
18815         e_conv.inner = (void*)(e & (~1));
18816         e_conv.is_owned = (e & 1) || (e == 0);
18817         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18818         e_conv = DecodeError_clone(&e_conv);
18819         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18820         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
18821         return (uint32_t)ret_conv;
18822 }
18823
18824 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint32_t o) {
18825         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
18826         jboolean ret_val = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
18827         return ret_val;
18828 }
18829
18830 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_free(uint32_t _res) {
18831         if ((_res & 1) != 0) return;
18832         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18833         CHECK_ACCESS(_res_ptr);
18834         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
18835         FREE((void*)_res);
18836         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
18837 }
18838
18839 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
18840         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18841         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
18842         return (uint32_t)ret_conv;
18843 }
18844 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18845         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
18846         uint32_t ret_val = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
18847         return ret_val;
18848 }
18849
18850 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint32_t orig) {
18851         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
18852         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18853         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
18854         return (uint32_t)ret_conv;
18855 }
18856
18857 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18858         LDKUnsignedNodeAnnouncement o_conv;
18859         o_conv.inner = (void*)(o & (~1));
18860         o_conv.is_owned = (o & 1) || (o == 0);
18861         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18862         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
18863         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18864         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
18865         return (uint32_t)ret_conv;
18866 }
18867
18868 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
18869         LDKDecodeError e_conv;
18870         e_conv.inner = (void*)(e & (~1));
18871         e_conv.is_owned = (e & 1) || (e == 0);
18872         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18873         e_conv = DecodeError_clone(&e_conv);
18874         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18875         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
18876         return (uint32_t)ret_conv;
18877 }
18878
18879 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18880         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
18881         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18882         return ret_val;
18883 }
18884
18885 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
18886         if ((_res & 1) != 0) return;
18887         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18888         CHECK_ACCESS(_res_ptr);
18889         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
18890         FREE((void*)_res);
18891         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
18892 }
18893
18894 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18895         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18896         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
18897         return (uint32_t)ret_conv;
18898 }
18899 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18900         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
18901         uint32_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18902         return ret_val;
18903 }
18904
18905 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18906         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
18907         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18908         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
18909         return (uint32_t)ret_conv;
18910 }
18911
18912 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18913         LDKNodeAnnouncement o_conv;
18914         o_conv.inner = (void*)(o & (~1));
18915         o_conv.is_owned = (o & 1) || (o == 0);
18916         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18917         o_conv = NodeAnnouncement_clone(&o_conv);
18918         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18919         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
18920         return (uint32_t)ret_conv;
18921 }
18922
18923 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
18924         LDKDecodeError e_conv;
18925         e_conv.inner = (void*)(e & (~1));
18926         e_conv.is_owned = (e & 1) || (e == 0);
18927         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18928         e_conv = DecodeError_clone(&e_conv);
18929         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18930         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
18931         return (uint32_t)ret_conv;
18932 }
18933
18934 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18935         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
18936         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18937         return ret_val;
18938 }
18939
18940 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
18941         if ((_res & 1) != 0) return;
18942         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18943         CHECK_ACCESS(_res_ptr);
18944         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
18945         FREE((void*)_res);
18946         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
18947 }
18948
18949 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18950         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18951         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
18952         return (uint32_t)ret_conv;
18953 }
18954 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18955         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
18956         uint32_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18957         return ret_val;
18958 }
18959
18960 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18961         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
18962         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18963         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
18964         return (uint32_t)ret_conv;
18965 }
18966
18967 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
18968         LDKQueryShortChannelIds o_conv;
18969         o_conv.inner = (void*)(o & (~1));
18970         o_conv.is_owned = (o & 1) || (o == 0);
18971         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18972         o_conv = QueryShortChannelIds_clone(&o_conv);
18973         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18974         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
18975         return (uint32_t)ret_conv;
18976 }
18977
18978 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
18979         LDKDecodeError e_conv;
18980         e_conv.inner = (void*)(e & (~1));
18981         e_conv.is_owned = (e & 1) || (e == 0);
18982         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18983         e_conv = DecodeError_clone(&e_conv);
18984         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18985         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
18986         return (uint32_t)ret_conv;
18987 }
18988
18989 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
18990         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
18991         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
18992         return ret_val;
18993 }
18994
18995 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
18996         if ((_res & 1) != 0) return;
18997         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18998         CHECK_ACCESS(_res_ptr);
18999         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
19000         FREE((void*)_res);
19001         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
19002 }
19003
19004 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
19005         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19006         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
19007         return (uint32_t)ret_conv;
19008 }
19009 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
19010         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
19011         uint32_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
19012         return ret_val;
19013 }
19014
19015 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
19016         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
19017         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19018         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
19019         return (uint32_t)ret_conv;
19020 }
19021
19022 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
19023         LDKReplyShortChannelIdsEnd o_conv;
19024         o_conv.inner = (void*)(o & (~1));
19025         o_conv.is_owned = (o & 1) || (o == 0);
19026         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19027         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
19028         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19029         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
19030         return (uint32_t)ret_conv;
19031 }
19032
19033 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
19034         LDKDecodeError e_conv;
19035         e_conv.inner = (void*)(e & (~1));
19036         e_conv.is_owned = (e & 1) || (e == 0);
19037         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19038         e_conv = DecodeError_clone(&e_conv);
19039         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19040         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
19041         return (uint32_t)ret_conv;
19042 }
19043
19044 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
19045         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
19046         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
19047         return ret_val;
19048 }
19049
19050 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
19051         if ((_res & 1) != 0) return;
19052         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19053         CHECK_ACCESS(_res_ptr);
19054         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
19055         FREE((void*)_res);
19056         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
19057 }
19058
19059 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
19060         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19061         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
19062         return (uint32_t)ret_conv;
19063 }
19064 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
19065         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
19066         uint32_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
19067         return ret_val;
19068 }
19069
19070 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
19071         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
19072         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19073         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
19074         return (uint32_t)ret_conv;
19075 }
19076
19077 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
19078         LDKQueryChannelRange o_conv;
19079         o_conv.inner = (void*)(o & (~1));
19080         o_conv.is_owned = (o & 1) || (o == 0);
19081         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19082         o_conv = QueryChannelRange_clone(&o_conv);
19083         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19084         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
19085         return (uint32_t)ret_conv;
19086 }
19087
19088 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
19089         LDKDecodeError e_conv;
19090         e_conv.inner = (void*)(e & (~1));
19091         e_conv.is_owned = (e & 1) || (e == 0);
19092         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19093         e_conv = DecodeError_clone(&e_conv);
19094         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19095         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
19096         return (uint32_t)ret_conv;
19097 }
19098
19099 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
19100         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
19101         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
19102         return ret_val;
19103 }
19104
19105 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
19106         if ((_res & 1) != 0) return;
19107         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19108         CHECK_ACCESS(_res_ptr);
19109         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
19110         FREE((void*)_res);
19111         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
19112 }
19113
19114 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19115         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19116         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
19117         return (uint32_t)ret_conv;
19118 }
19119 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19120         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
19121         uint32_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19122         return ret_val;
19123 }
19124
19125 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19126         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
19127         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19128         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
19129         return (uint32_t)ret_conv;
19130 }
19131
19132 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
19133         LDKReplyChannelRange o_conv;
19134         o_conv.inner = (void*)(o & (~1));
19135         o_conv.is_owned = (o & 1) || (o == 0);
19136         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19137         o_conv = ReplyChannelRange_clone(&o_conv);
19138         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19139         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
19140         return (uint32_t)ret_conv;
19141 }
19142
19143 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
19144         LDKDecodeError e_conv;
19145         e_conv.inner = (void*)(e & (~1));
19146         e_conv.is_owned = (e & 1) || (e == 0);
19147         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19148         e_conv = DecodeError_clone(&e_conv);
19149         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19150         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
19151         return (uint32_t)ret_conv;
19152 }
19153
19154 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
19155         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
19156         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
19157         return ret_val;
19158 }
19159
19160 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
19161         if ((_res & 1) != 0) return;
19162         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19163         CHECK_ACCESS(_res_ptr);
19164         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
19165         FREE((void*)_res);
19166         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
19167 }
19168
19169 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19170         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19171         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
19172         return (uint32_t)ret_conv;
19173 }
19174 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19175         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
19176         uint32_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19177         return ret_val;
19178 }
19179
19180 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19181         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
19182         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19183         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
19184         return (uint32_t)ret_conv;
19185 }
19186
19187 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
19188         LDKGossipTimestampFilter o_conv;
19189         o_conv.inner = (void*)(o & (~1));
19190         o_conv.is_owned = (o & 1) || (o == 0);
19191         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19192         o_conv = GossipTimestampFilter_clone(&o_conv);
19193         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19194         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
19195         return (uint32_t)ret_conv;
19196 }
19197
19198 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
19199         LDKDecodeError e_conv;
19200         e_conv.inner = (void*)(e & (~1));
19201         e_conv.is_owned = (e & 1) || (e == 0);
19202         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19203         e_conv = DecodeError_clone(&e_conv);
19204         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19205         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
19206         return (uint32_t)ret_conv;
19207 }
19208
19209 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
19210         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
19211         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
19212         return ret_val;
19213 }
19214
19215 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
19216         if ((_res & 1) != 0) return;
19217         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19218         CHECK_ACCESS(_res_ptr);
19219         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
19220         FREE((void*)_res);
19221         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
19222 }
19223
19224 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
19225         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19226         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
19227         return (uint32_t)ret_conv;
19228 }
19229 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
19230         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
19231         uint32_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
19232         return ret_val;
19233 }
19234
19235 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
19236         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
19237         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19238         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
19239         return (uint32_t)ret_conv;
19240 }
19241
19242 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
19243         LDKInvoice o_conv;
19244         o_conv.inner = (void*)(o & (~1));
19245         o_conv.is_owned = (o & 1) || (o == 0);
19246         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19247         o_conv = Invoice_clone(&o_conv);
19248         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19249         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
19250         return (uint32_t)ret_conv;
19251 }
19252
19253 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
19254         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19255         CHECK_ACCESS(e_ptr);
19256         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
19257         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
19258         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19259         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
19260         return (uint32_t)ret_conv;
19261 }
19262
19263 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
19264         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
19265         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
19266         return ret_val;
19267 }
19268
19269 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
19270         if ((_res & 1) != 0) return;
19271         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19272         CHECK_ACCESS(_res_ptr);
19273         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
19274         FREE((void*)_res);
19275         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
19276 }
19277
19278 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
19279         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19280         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
19281         return (uint32_t)ret_conv;
19282 }
19283 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
19284         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
19285         uint32_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
19286         return ret_val;
19287 }
19288
19289 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
19290         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
19291         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19292         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
19293         return (uint32_t)ret_conv;
19294 }
19295
19296 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
19297         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19298         CHECK_ACCESS(o_ptr);
19299         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
19300         if (o_conv.free == LDKFilter_JCalls_free) {
19301                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19302                 LDKFilter_JCalls_cloned(&o_conv);
19303         }
19304         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19305         *ret_copy = COption_FilterZ_some(o_conv);
19306         uint32_t ret_ref = (uintptr_t)ret_copy;
19307         return ret_ref;
19308 }
19309
19310 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
19311         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19312         *ret_copy = COption_FilterZ_none();
19313         uint32_t ret_ref = (uintptr_t)ret_copy;
19314         return ret_ref;
19315 }
19316
19317 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
19318         if ((_res & 1) != 0) return;
19319         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19320         CHECK_ACCESS(_res_ptr);
19321         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
19322         FREE((void*)_res);
19323         COption_FilterZ_free(_res_conv);
19324 }
19325
19326 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
19327         LDKLockedChannelMonitor o_conv;
19328         o_conv.inner = (void*)(o & (~1));
19329         o_conv.is_owned = (o & 1) || (o == 0);
19330         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19331         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
19332         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19333         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
19334         return (uint32_t)ret_conv;
19335 }
19336
19337 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
19338         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19339         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
19340         return (uint32_t)ret_conv;
19341 }
19342
19343 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
19344         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
19345         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
19346         return ret_val;
19347 }
19348
19349 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
19350         if ((_res & 1) != 0) return;
19351         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19352         CHECK_ACCESS(_res_ptr);
19353         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
19354         FREE((void*)_res);
19355         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
19356 }
19357
19358 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
19359         LDKCVec_OutPointZ _res_constr;
19360         _res_constr.datalen = _res->arr_len;
19361         if (_res_constr.datalen > 0)
19362                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
19363         else
19364                 _res_constr.data = NULL;
19365         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
19366         for (size_t k = 0; k < _res_constr.datalen; k++) {
19367                 uint32_t _res_conv_10 = _res_vals[k];
19368                 LDKOutPoint _res_conv_10_conv;
19369                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
19370                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
19371                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
19372                 _res_constr.data[k] = _res_conv_10_conv;
19373         }
19374         CVec_OutPointZ_free(_res_constr);
19375 }
19376
19377 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
19378         if ((this_ptr & 1) != 0) return;
19379         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19380         CHECK_ACCESS(this_ptr_ptr);
19381         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
19382         FREE((void*)this_ptr);
19383         PaymentPurpose_free(this_ptr_conv);
19384 }
19385
19386 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
19387         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19388         *ret_copy = PaymentPurpose_clone(arg);
19389 uint32_t ret_ref = (uintptr_t)ret_copy;
19390         return ret_ref;
19391 }
19392 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
19393         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
19394         uint32_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
19395         return ret_val;
19396 }
19397
19398 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
19399         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
19400         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19401         *ret_copy = PaymentPurpose_clone(orig_conv);
19402         uint32_t ret_ref = (uintptr_t)ret_copy;
19403         return ret_ref;
19404 }
19405
19406 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
19407         LDKThirtyTwoBytes payment_preimage_ref;
19408         CHECK(payment_preimage->arr_len == 32);
19409         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19410         LDKThirtyTwoBytes payment_secret_ref;
19411         CHECK(payment_secret->arr_len == 32);
19412         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
19413         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19414         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
19415         uint32_t ret_ref = (uintptr_t)ret_copy;
19416         return ret_ref;
19417 }
19418
19419 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
19420         LDKThirtyTwoBytes a_ref;
19421         CHECK(a->arr_len == 32);
19422         memcpy(a_ref.data, a->elems, 32); FREE(a);
19423         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19424         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
19425         uint32_t ret_ref = (uintptr_t)ret_copy;
19426         return ret_ref;
19427 }
19428
19429 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
19430         if ((this_ptr & 1) != 0) return;
19431         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19432         CHECK_ACCESS(this_ptr_ptr);
19433         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
19434         FREE((void*)this_ptr);
19435         ClosureReason_free(this_ptr_conv);
19436 }
19437
19438 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
19439         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19440         *ret_copy = ClosureReason_clone(arg);
19441 uint32_t ret_ref = (uintptr_t)ret_copy;
19442         return ret_ref;
19443 }
19444 uint32_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
19445         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
19446         uint32_t ret_val = ClosureReason_clone_ptr(arg_conv);
19447         return ret_val;
19448 }
19449
19450 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
19451         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
19452         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19453         *ret_copy = ClosureReason_clone(orig_conv);
19454         uint32_t ret_ref = (uintptr_t)ret_copy;
19455         return ret_ref;
19456 }
19457
19458 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
19459         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
19460         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19461         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
19462         uint32_t ret_ref = (uintptr_t)ret_copy;
19463         return ret_ref;
19464 }
19465
19466 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
19467         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19468         *ret_copy = ClosureReason_holder_force_closed();
19469         uint32_t ret_ref = (uintptr_t)ret_copy;
19470         return ret_ref;
19471 }
19472
19473 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
19474         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19475         *ret_copy = ClosureReason_cooperative_closure();
19476         uint32_t ret_ref = (uintptr_t)ret_copy;
19477         return ret_ref;
19478 }
19479
19480 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
19481         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19482         *ret_copy = ClosureReason_commitment_tx_confirmed();
19483         uint32_t ret_ref = (uintptr_t)ret_copy;
19484         return ret_ref;
19485 }
19486
19487 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
19488         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19489         *ret_copy = ClosureReason_funding_timed_out();
19490         uint32_t ret_ref = (uintptr_t)ret_copy;
19491         return ret_ref;
19492 }
19493
19494 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
19495         LDKStr err_conv = str_ref_to_owned_c(err);
19496         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19497         *ret_copy = ClosureReason_processing_error(err_conv);
19498         uint32_t ret_ref = (uintptr_t)ret_copy;
19499         return ret_ref;
19500 }
19501
19502 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
19503         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19504         *ret_copy = ClosureReason_disconnected_peer();
19505         uint32_t ret_ref = (uintptr_t)ret_copy;
19506         return ret_ref;
19507 }
19508
19509 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
19510         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19511         *ret_copy = ClosureReason_outdated_channel_manager();
19512         uint32_t ret_ref = (uintptr_t)ret_copy;
19513         return ret_ref;
19514 }
19515
19516 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
19517         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
19518         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
19519         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19520         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19521         CVec_u8Z_free(ret_var);
19522         return ret_arr;
19523 }
19524
19525 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
19526         LDKu8slice ser_ref;
19527         ser_ref.datalen = ser->arr_len;
19528         ser_ref.data = ser->elems /* XXX ser leaks */;
19529         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19530         *ret_conv = ClosureReason_read(ser_ref);
19531         return (uint32_t)ret_conv;
19532 }
19533
19534 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
19535         if ((this_ptr & 1) != 0) return;
19536         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19537         CHECK_ACCESS(this_ptr_ptr);
19538         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
19539         FREE((void*)this_ptr);
19540         Event_free(this_ptr_conv);
19541 }
19542
19543 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
19544         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19545         *ret_copy = Event_clone(arg);
19546 uint32_t ret_ref = (uintptr_t)ret_copy;
19547         return ret_ref;
19548 }
19549 uint32_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
19550         LDKEvent* arg_conv = (LDKEvent*)arg;
19551         uint32_t ret_val = Event_clone_ptr(arg_conv);
19552         return ret_val;
19553 }
19554
19555 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
19556         LDKEvent* orig_conv = (LDKEvent*)orig;
19557         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19558         *ret_copy = Event_clone(orig_conv);
19559         uint32_t ret_ref = (uintptr_t)ret_copy;
19560         return ret_ref;
19561 }
19562
19563 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) {
19564         LDKThirtyTwoBytes temporary_channel_id_ref;
19565         CHECK(temporary_channel_id->arr_len == 32);
19566         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19567         LDKCVec_u8Z output_script_ref;
19568         output_script_ref.datalen = output_script->arr_len;
19569         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
19570         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
19571         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19572         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
19573         uint32_t ret_ref = (uintptr_t)ret_copy;
19574         return ret_ref;
19575 }
19576
19577 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
19578         LDKThirtyTwoBytes payment_hash_ref;
19579         CHECK(payment_hash->arr_len == 32);
19580         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19581         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
19582         CHECK_ACCESS(purpose_ptr);
19583         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
19584         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
19585         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19586         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
19587         uint32_t ret_ref = (uintptr_t)ret_copy;
19588         return ret_ref;
19589 }
19590
19591 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) {
19592         LDKThirtyTwoBytes payment_id_ref;
19593         CHECK(payment_id->arr_len == 32);
19594         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19595         LDKThirtyTwoBytes payment_preimage_ref;
19596         CHECK(payment_preimage->arr_len == 32);
19597         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19598         LDKThirtyTwoBytes payment_hash_ref;
19599         CHECK(payment_hash->arr_len == 32);
19600         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19601         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
19602         CHECK_ACCESS(fee_paid_msat_ptr);
19603         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
19604         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
19605         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19606         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
19607         uint32_t ret_ref = (uintptr_t)ret_copy;
19608         return ret_ref;
19609 }
19610
19611 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) {
19612         LDKThirtyTwoBytes payment_id_ref;
19613         CHECK(payment_id->arr_len == 32);
19614         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19615         LDKThirtyTwoBytes payment_hash_ref;
19616         CHECK(payment_hash->arr_len == 32);
19617         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19618         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
19619         CHECK_ACCESS(network_update_ptr);
19620         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
19621         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
19622         LDKCVec_RouteHopZ path_constr;
19623         path_constr.datalen = path->arr_len;
19624         if (path_constr.datalen > 0)
19625                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19626         else
19627                 path_constr.data = NULL;
19628         uint32_t* path_vals = path->elems /* XXX path leaks */;
19629         for (size_t k = 0; k < path_constr.datalen; k++) {
19630                 uint32_t path_conv_10 = path_vals[k];
19631                 LDKRouteHop path_conv_10_conv;
19632                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19633                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19634                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19635                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19636                 path_constr.data[k] = path_conv_10_conv;
19637         }
19638         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
19639         CHECK_ACCESS(short_channel_id_ptr);
19640         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
19641         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
19642         LDKRouteParameters retry_conv;
19643         retry_conv.inner = (void*)(retry & (~1));
19644         retry_conv.is_owned = (retry & 1) || (retry == 0);
19645         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
19646         retry_conv = RouteParameters_clone(&retry_conv);
19647         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19648         *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);
19649         uint32_t ret_ref = (uintptr_t)ret_copy;
19650         return ret_ref;
19651 }
19652
19653 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
19654         LDKThirtyTwoBytes payment_id_ref;
19655         CHECK(payment_id->arr_len == 32);
19656         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19657         LDKThirtyTwoBytes payment_hash_ref;
19658         CHECK(payment_hash->arr_len == 32);
19659         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19660         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19661         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
19662         uint32_t ret_ref = (uintptr_t)ret_copy;
19663         return ret_ref;
19664 }
19665
19666 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
19667         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19668         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
19669         uint32_t ret_ref = (uintptr_t)ret_copy;
19670         return ret_ref;
19671 }
19672
19673 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
19674         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
19675         outputs_constr.datalen = outputs->arr_len;
19676         if (outputs_constr.datalen > 0)
19677                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
19678         else
19679                 outputs_constr.data = NULL;
19680         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
19681         for (size_t b = 0; b < outputs_constr.datalen; b++) {
19682                 uint32_t outputs_conv_27 = outputs_vals[b];
19683                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
19684                 CHECK_ACCESS(outputs_conv_27_ptr);
19685                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
19686                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
19687                 outputs_constr.data[b] = outputs_conv_27_conv;
19688         }
19689         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19690         *ret_copy = Event_spendable_outputs(outputs_constr);
19691         uint32_t ret_ref = (uintptr_t)ret_copy;
19692         return ret_ref;
19693 }
19694
19695 uint32_t  __attribute__((export_name("TS_Event_payment_forwarded"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
19696         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
19697         CHECK_ACCESS(fee_earned_msat_ptr);
19698         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
19699         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
19700         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19701         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
19702         uint32_t ret_ref = (uintptr_t)ret_copy;
19703         return ret_ref;
19704 }
19705
19706 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) {
19707         LDKThirtyTwoBytes channel_id_ref;
19708         CHECK(channel_id->arr_len == 32);
19709         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19710         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
19711         CHECK_ACCESS(reason_ptr);
19712         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
19713         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
19714         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19715         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
19716         uint32_t ret_ref = (uintptr_t)ret_copy;
19717         return ret_ref;
19718 }
19719
19720 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
19721         LDKThirtyTwoBytes channel_id_ref;
19722         CHECK(channel_id->arr_len == 32);
19723         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19724         LDKTransaction transaction_ref;
19725         transaction_ref.datalen = transaction->arr_len;
19726         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
19727         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
19728         transaction_ref.data_is_owned = true;
19729         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19730         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
19731         uint32_t ret_ref = (uintptr_t)ret_copy;
19732         return ret_ref;
19733 }
19734
19735 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) {
19736         LDKThirtyTwoBytes payment_id_ref;
19737         CHECK(payment_id->arr_len == 32);
19738         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19739         LDKThirtyTwoBytes payment_hash_ref;
19740         CHECK(payment_hash->arr_len == 32);
19741         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19742         LDKCVec_RouteHopZ path_constr;
19743         path_constr.datalen = path->arr_len;
19744         if (path_constr.datalen > 0)
19745                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19746         else
19747                 path_constr.data = NULL;
19748         uint32_t* path_vals = path->elems /* XXX path leaks */;
19749         for (size_t k = 0; k < path_constr.datalen; k++) {
19750                 uint32_t path_conv_10 = path_vals[k];
19751                 LDKRouteHop path_conv_10_conv;
19752                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19753                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19754                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19755                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19756                 path_constr.data[k] = path_conv_10_conv;
19757         }
19758         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19759         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
19760         uint32_t ret_ref = (uintptr_t)ret_copy;
19761         return ret_ref;
19762 }
19763
19764 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) {
19765         LDKThirtyTwoBytes temporary_channel_id_ref;
19766         CHECK(temporary_channel_id->arr_len == 32);
19767         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19768         LDKPublicKey counterparty_node_id_ref;
19769         CHECK(counterparty_node_id->arr_len == 33);
19770         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
19771         LDKChannelTypeFeatures channel_type_conv;
19772         channel_type_conv.inner = (void*)(channel_type & (~1));
19773         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
19774         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
19775         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
19776         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19777         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
19778         uint32_t ret_ref = (uintptr_t)ret_copy;
19779         return ret_ref;
19780 }
19781
19782 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
19783         LDKEvent* obj_conv = (LDKEvent*)obj;
19784         LDKCVec_u8Z ret_var = Event_write(obj_conv);
19785         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19786         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19787         CVec_u8Z_free(ret_var);
19788         return ret_arr;
19789 }
19790
19791 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
19792         LDKu8slice ser_ref;
19793         ser_ref.datalen = ser->arr_len;
19794         ser_ref.data = ser->elems /* XXX ser leaks */;
19795         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19796         *ret_conv = Event_read(ser_ref);
19797         return (uint32_t)ret_conv;
19798 }
19799
19800 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
19801         if ((this_ptr & 1) != 0) return;
19802         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19803         CHECK_ACCESS(this_ptr_ptr);
19804         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
19805         FREE((void*)this_ptr);
19806         MessageSendEvent_free(this_ptr_conv);
19807 }
19808
19809 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
19810         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19811         *ret_copy = MessageSendEvent_clone(arg);
19812 uint32_t ret_ref = (uintptr_t)ret_copy;
19813         return ret_ref;
19814 }
19815 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
19816         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
19817         uint32_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
19818         return ret_val;
19819 }
19820
19821 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
19822         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
19823         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19824         *ret_copy = MessageSendEvent_clone(orig_conv);
19825         uint32_t ret_ref = (uintptr_t)ret_copy;
19826         return ret_ref;
19827 }
19828
19829 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
19830         LDKPublicKey node_id_ref;
19831         CHECK(node_id->arr_len == 33);
19832         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19833         LDKAcceptChannel msg_conv;
19834         msg_conv.inner = (void*)(msg & (~1));
19835         msg_conv.is_owned = (msg & 1) || (msg == 0);
19836         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19837         msg_conv = AcceptChannel_clone(&msg_conv);
19838         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19839         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
19840         uint32_t ret_ref = (uintptr_t)ret_copy;
19841         return ret_ref;
19842 }
19843
19844 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
19845         LDKPublicKey node_id_ref;
19846         CHECK(node_id->arr_len == 33);
19847         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19848         LDKOpenChannel msg_conv;
19849         msg_conv.inner = (void*)(msg & (~1));
19850         msg_conv.is_owned = (msg & 1) || (msg == 0);
19851         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19852         msg_conv = OpenChannel_clone(&msg_conv);
19853         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19854         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
19855         uint32_t ret_ref = (uintptr_t)ret_copy;
19856         return ret_ref;
19857 }
19858
19859 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
19860         LDKPublicKey node_id_ref;
19861         CHECK(node_id->arr_len == 33);
19862         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19863         LDKFundingCreated msg_conv;
19864         msg_conv.inner = (void*)(msg & (~1));
19865         msg_conv.is_owned = (msg & 1) || (msg == 0);
19866         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19867         msg_conv = FundingCreated_clone(&msg_conv);
19868         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19869         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
19870         uint32_t ret_ref = (uintptr_t)ret_copy;
19871         return ret_ref;
19872 }
19873
19874 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
19875         LDKPublicKey node_id_ref;
19876         CHECK(node_id->arr_len == 33);
19877         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19878         LDKFundingSigned msg_conv;
19879         msg_conv.inner = (void*)(msg & (~1));
19880         msg_conv.is_owned = (msg & 1) || (msg == 0);
19881         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19882         msg_conv = FundingSigned_clone(&msg_conv);
19883         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19884         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
19885         uint32_t ret_ref = (uintptr_t)ret_copy;
19886         return ret_ref;
19887 }
19888
19889 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_locked"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
19890         LDKPublicKey node_id_ref;
19891         CHECK(node_id->arr_len == 33);
19892         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19893         LDKFundingLocked msg_conv;
19894         msg_conv.inner = (void*)(msg & (~1));
19895         msg_conv.is_owned = (msg & 1) || (msg == 0);
19896         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19897         msg_conv = FundingLocked_clone(&msg_conv);
19898         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19899         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
19900         uint32_t ret_ref = (uintptr_t)ret_copy;
19901         return ret_ref;
19902 }
19903
19904 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
19905         LDKPublicKey node_id_ref;
19906         CHECK(node_id->arr_len == 33);
19907         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19908         LDKAnnouncementSignatures msg_conv;
19909         msg_conv.inner = (void*)(msg & (~1));
19910         msg_conv.is_owned = (msg & 1) || (msg == 0);
19911         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19912         msg_conv = AnnouncementSignatures_clone(&msg_conv);
19913         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19914         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
19915         uint32_t ret_ref = (uintptr_t)ret_copy;
19916         return ret_ref;
19917 }
19918
19919 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
19920         LDKPublicKey node_id_ref;
19921         CHECK(node_id->arr_len == 33);
19922         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19923         LDKCommitmentUpdate updates_conv;
19924         updates_conv.inner = (void*)(updates & (~1));
19925         updates_conv.is_owned = (updates & 1) || (updates == 0);
19926         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
19927         updates_conv = CommitmentUpdate_clone(&updates_conv);
19928         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19929         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
19930         uint32_t ret_ref = (uintptr_t)ret_copy;
19931         return ret_ref;
19932 }
19933
19934 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
19935         LDKPublicKey node_id_ref;
19936         CHECK(node_id->arr_len == 33);
19937         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19938         LDKRevokeAndACK msg_conv;
19939         msg_conv.inner = (void*)(msg & (~1));
19940         msg_conv.is_owned = (msg & 1) || (msg == 0);
19941         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19942         msg_conv = RevokeAndACK_clone(&msg_conv);
19943         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19944         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
19945         uint32_t ret_ref = (uintptr_t)ret_copy;
19946         return ret_ref;
19947 }
19948
19949 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
19950         LDKPublicKey node_id_ref;
19951         CHECK(node_id->arr_len == 33);
19952         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19953         LDKClosingSigned msg_conv;
19954         msg_conv.inner = (void*)(msg & (~1));
19955         msg_conv.is_owned = (msg & 1) || (msg == 0);
19956         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19957         msg_conv = ClosingSigned_clone(&msg_conv);
19958         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19959         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
19960         uint32_t ret_ref = (uintptr_t)ret_copy;
19961         return ret_ref;
19962 }
19963
19964 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
19965         LDKPublicKey node_id_ref;
19966         CHECK(node_id->arr_len == 33);
19967         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19968         LDKShutdown msg_conv;
19969         msg_conv.inner = (void*)(msg & (~1));
19970         msg_conv.is_owned = (msg & 1) || (msg == 0);
19971         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19972         msg_conv = Shutdown_clone(&msg_conv);
19973         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19974         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
19975         uint32_t ret_ref = (uintptr_t)ret_copy;
19976         return ret_ref;
19977 }
19978
19979 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
19980         LDKPublicKey node_id_ref;
19981         CHECK(node_id->arr_len == 33);
19982         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19983         LDKChannelReestablish msg_conv;
19984         msg_conv.inner = (void*)(msg & (~1));
19985         msg_conv.is_owned = (msg & 1) || (msg == 0);
19986         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19987         msg_conv = ChannelReestablish_clone(&msg_conv);
19988         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19989         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
19990         uint32_t ret_ref = (uintptr_t)ret_copy;
19991         return ret_ref;
19992 }
19993
19994 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
19995         LDKChannelAnnouncement msg_conv;
19996         msg_conv.inner = (void*)(msg & (~1));
19997         msg_conv.is_owned = (msg & 1) || (msg == 0);
19998         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19999         msg_conv = ChannelAnnouncement_clone(&msg_conv);
20000         LDKChannelUpdate update_msg_conv;
20001         update_msg_conv.inner = (void*)(update_msg & (~1));
20002         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
20003         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
20004         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
20005         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20006         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
20007         uint32_t ret_ref = (uintptr_t)ret_copy;
20008         return ret_ref;
20009 }
20010
20011 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
20012         LDKNodeAnnouncement msg_conv;
20013         msg_conv.inner = (void*)(msg & (~1));
20014         msg_conv.is_owned = (msg & 1) || (msg == 0);
20015         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20016         msg_conv = NodeAnnouncement_clone(&msg_conv);
20017         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20018         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
20019         uint32_t ret_ref = (uintptr_t)ret_copy;
20020         return ret_ref;
20021 }
20022
20023 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
20024         LDKChannelUpdate msg_conv;
20025         msg_conv.inner = (void*)(msg & (~1));
20026         msg_conv.is_owned = (msg & 1) || (msg == 0);
20027         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20028         msg_conv = ChannelUpdate_clone(&msg_conv);
20029         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20030         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
20031         uint32_t ret_ref = (uintptr_t)ret_copy;
20032         return ret_ref;
20033 }
20034
20035 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
20036         LDKPublicKey node_id_ref;
20037         CHECK(node_id->arr_len == 33);
20038         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20039         LDKChannelUpdate msg_conv;
20040         msg_conv.inner = (void*)(msg & (~1));
20041         msg_conv.is_owned = (msg & 1) || (msg == 0);
20042         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20043         msg_conv = ChannelUpdate_clone(&msg_conv);
20044         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20045         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
20046         uint32_t ret_ref = (uintptr_t)ret_copy;
20047         return ret_ref;
20048 }
20049
20050 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
20051         LDKPublicKey node_id_ref;
20052         CHECK(node_id->arr_len == 33);
20053         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20054         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
20055         CHECK_ACCESS(action_ptr);
20056         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
20057         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
20058         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20059         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
20060         uint32_t ret_ref = (uintptr_t)ret_copy;
20061         return ret_ref;
20062 }
20063
20064 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
20065         LDKPublicKey node_id_ref;
20066         CHECK(node_id->arr_len == 33);
20067         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20068         LDKQueryChannelRange msg_conv;
20069         msg_conv.inner = (void*)(msg & (~1));
20070         msg_conv.is_owned = (msg & 1) || (msg == 0);
20071         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20072         msg_conv = QueryChannelRange_clone(&msg_conv);
20073         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20074         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
20075         uint32_t ret_ref = (uintptr_t)ret_copy;
20076         return ret_ref;
20077 }
20078
20079 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
20080         LDKPublicKey node_id_ref;
20081         CHECK(node_id->arr_len == 33);
20082         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20083         LDKQueryShortChannelIds msg_conv;
20084         msg_conv.inner = (void*)(msg & (~1));
20085         msg_conv.is_owned = (msg & 1) || (msg == 0);
20086         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20087         msg_conv = QueryShortChannelIds_clone(&msg_conv);
20088         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20089         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
20090         uint32_t ret_ref = (uintptr_t)ret_copy;
20091         return ret_ref;
20092 }
20093
20094 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
20095         LDKPublicKey node_id_ref;
20096         CHECK(node_id->arr_len == 33);
20097         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20098         LDKReplyChannelRange msg_conv;
20099         msg_conv.inner = (void*)(msg & (~1));
20100         msg_conv.is_owned = (msg & 1) || (msg == 0);
20101         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20102         msg_conv = ReplyChannelRange_clone(&msg_conv);
20103         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20104         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
20105         uint32_t ret_ref = (uintptr_t)ret_copy;
20106         return ret_ref;
20107 }
20108
20109 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_gossip_timestamp_filter"))) TS_MessageSendEvent_send_gossip_timestamp_filter(int8_tArray node_id, uint32_t msg) {
20110         LDKPublicKey node_id_ref;
20111         CHECK(node_id->arr_len == 33);
20112         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20113         LDKGossipTimestampFilter msg_conv;
20114         msg_conv.inner = (void*)(msg & (~1));
20115         msg_conv.is_owned = (msg & 1) || (msg == 0);
20116         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20117         msg_conv = GossipTimestampFilter_clone(&msg_conv);
20118         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20119         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
20120         uint32_t ret_ref = (uintptr_t)ret_copy;
20121         return ret_ref;
20122 }
20123
20124 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
20125         if ((this_ptr & 1) != 0) return;
20126         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20127         CHECK_ACCESS(this_ptr_ptr);
20128         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
20129         FREE((void*)this_ptr);
20130         MessageSendEventsProvider_free(this_ptr_conv);
20131 }
20132
20133 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
20134         if ((this_ptr & 1) != 0) return;
20135         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20136         CHECK_ACCESS(this_ptr_ptr);
20137         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
20138         FREE((void*)this_ptr);
20139         EventsProvider_free(this_ptr_conv);
20140 }
20141
20142 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
20143         if ((this_ptr & 1) != 0) return;
20144         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20145         CHECK_ACCESS(this_ptr_ptr);
20146         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
20147         FREE((void*)this_ptr);
20148         EventHandler_free(this_ptr_conv);
20149 }
20150
20151 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
20152         if ((this_ptr & 1) != 0) return;
20153         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20154         CHECK_ACCESS(this_ptr_ptr);
20155         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
20156         FREE((void*)this_ptr);
20157         APIError_free(this_ptr_conv);
20158 }
20159
20160 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
20161         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20162         *ret_copy = APIError_clone(arg);
20163 uint32_t ret_ref = (uintptr_t)ret_copy;
20164         return ret_ref;
20165 }
20166 uint32_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
20167         LDKAPIError* arg_conv = (LDKAPIError*)arg;
20168         uint32_t ret_val = APIError_clone_ptr(arg_conv);
20169         return ret_val;
20170 }
20171
20172 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
20173         LDKAPIError* orig_conv = (LDKAPIError*)orig;
20174         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20175         *ret_copy = APIError_clone(orig_conv);
20176         uint32_t ret_ref = (uintptr_t)ret_copy;
20177         return ret_ref;
20178 }
20179
20180 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
20181         LDKStr err_conv = str_ref_to_owned_c(err);
20182         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20183         *ret_copy = APIError_apimisuse_error(err_conv);
20184         uint32_t ret_ref = (uintptr_t)ret_copy;
20185         return ret_ref;
20186 }
20187
20188 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
20189         LDKStr err_conv = str_ref_to_owned_c(err);
20190         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20191         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
20192         uint32_t ret_ref = (uintptr_t)ret_copy;
20193         return ret_ref;
20194 }
20195
20196 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
20197         LDKStr err_conv = str_ref_to_owned_c(err);
20198         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20199         *ret_copy = APIError_route_error(err_conv);
20200         uint32_t ret_ref = (uintptr_t)ret_copy;
20201         return ret_ref;
20202 }
20203
20204 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
20205         LDKStr err_conv = str_ref_to_owned_c(err);
20206         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20207         *ret_copy = APIError_channel_unavailable(err_conv);
20208         uint32_t ret_ref = (uintptr_t)ret_copy;
20209         return ret_ref;
20210 }
20211
20212 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
20213         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20214         *ret_copy = APIError_monitor_update_failed();
20215         uint32_t ret_ref = (uintptr_t)ret_copy;
20216         return ret_ref;
20217 }
20218
20219 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
20220         LDKShutdownScript script_conv;
20221         script_conv.inner = (void*)(script & (~1));
20222         script_conv.is_owned = (script & 1) || (script == 0);
20223         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
20224         script_conv = ShutdownScript_clone(&script_conv);
20225         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20226         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
20227         uint32_t ret_ref = (uintptr_t)ret_copy;
20228         return ret_ref;
20229 }
20230
20231 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
20232         LDKu8slice msg_ref;
20233         msg_ref.datalen = msg->arr_len;
20234         msg_ref.data = msg->elems /* XXX msg leaks */;
20235         unsigned char sk_arr[32];
20236         CHECK(sk->arr_len == 32);
20237         memcpy(sk_arr, sk->elems, 32); FREE(sk);
20238         unsigned char (*sk_ref)[32] = &sk_arr;
20239         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20240         *ret_conv = sign(msg_ref, sk_ref);
20241         return (uint32_t)ret_conv;
20242 }
20243
20244 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
20245         LDKu8slice msg_ref;
20246         msg_ref.datalen = msg->arr_len;
20247         msg_ref.data = msg->elems /* XXX msg leaks */;
20248         LDKStr sig_conv = str_ref_to_owned_c(sig);
20249         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
20250         *ret_conv = recover_pk(msg_ref, sig_conv);
20251         return (uint32_t)ret_conv;
20252 }
20253
20254 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
20255         LDKu8slice msg_ref;
20256         msg_ref.datalen = msg->arr_len;
20257         msg_ref.data = msg->elems /* XXX msg leaks */;
20258         LDKStr sig_conv = str_ref_to_owned_c(sig);
20259         LDKPublicKey pk_ref;
20260         CHECK(pk->arr_len == 33);
20261         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
20262         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
20263         return ret_val;
20264 }
20265
20266 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
20267         LDKu8slice hrp_bytes_ref;
20268         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
20269         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
20270         LDKCVec_u5Z data_without_signature_constr;
20271         data_without_signature_constr.datalen = data_without_signature->arr_len;
20272         if (data_without_signature_constr.datalen > 0)
20273                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
20274         else
20275                 data_without_signature_constr.data = NULL;
20276         int8_t* data_without_signature_vals = (void*) data_without_signature->elems /* XXX data_without_signature leaks */;
20277         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
20278                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
20279                 
20280                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
20281         }
20282         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
20283         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20284         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20285         CVec_u8Z_free(ret_var);
20286         return ret_arr;
20287 }
20288
20289 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
20290         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
20291         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
20292         return ret_conv;
20293 }
20294
20295 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
20296         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
20297         return ret_conv;
20298 }
20299
20300 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
20301         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
20302         return ret_conv;
20303 }
20304
20305 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
20306         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
20307         return ret_conv;
20308 }
20309
20310 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
20311         uint32_t ret_conv = LDKLevel_to_js(Level_info());
20312         return ret_conv;
20313 }
20314
20315 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
20316         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
20317         return ret_conv;
20318 }
20319
20320 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
20321         uint32_t ret_conv = LDKLevel_to_js(Level_error());
20322         return ret_conv;
20323 }
20324
20325 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
20326         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
20327         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
20328         jboolean ret_val = Level_eq(a_conv, b_conv);
20329         return ret_val;
20330 }
20331
20332 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
20333         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
20334         int64_t ret_val = Level_hash(o_conv);
20335         return ret_val;
20336 }
20337
20338 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
20339         uint32_t ret_conv = LDKLevel_to_js(Level_max());
20340         return ret_conv;
20341 }
20342
20343 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
20344         LDKRecord this_obj_conv;
20345         this_obj_conv.inner = (void*)(this_obj & (~1));
20346         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20348         Record_free(this_obj_conv);
20349 }
20350
20351 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
20352         LDKRecord this_ptr_conv;
20353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20354         this_ptr_conv.is_owned = false;
20355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20356         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
20357         return ret_conv;
20358 }
20359
20360 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
20361         LDKRecord this_ptr_conv;
20362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20363         this_ptr_conv.is_owned = false;
20364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20365         LDKLevel val_conv = LDKLevel_from_js(val);
20366         Record_set_level(&this_ptr_conv, val_conv);
20367 }
20368
20369 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
20370         LDKRecord this_ptr_conv;
20371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20372         this_ptr_conv.is_owned = false;
20373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20374         LDKStr ret_str = Record_get_args(&this_ptr_conv);
20375         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20376         Str_free(ret_str);
20377         return ret_conv;
20378 }
20379
20380 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
20381         LDKRecord this_ptr_conv;
20382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20383         this_ptr_conv.is_owned = false;
20384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20385         LDKStr val_conv = str_ref_to_owned_c(val);
20386         Record_set_args(&this_ptr_conv, val_conv);
20387 }
20388
20389 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
20390         LDKRecord this_ptr_conv;
20391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20392         this_ptr_conv.is_owned = false;
20393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20394         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
20395         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20396         Str_free(ret_str);
20397         return ret_conv;
20398 }
20399
20400 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
20401         LDKRecord this_ptr_conv;
20402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20403         this_ptr_conv.is_owned = false;
20404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20405         LDKStr val_conv = str_ref_to_owned_c(val);
20406         Record_set_module_path(&this_ptr_conv, val_conv);
20407 }
20408
20409 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
20410         LDKRecord this_ptr_conv;
20411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20412         this_ptr_conv.is_owned = false;
20413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20414         LDKStr ret_str = Record_get_file(&this_ptr_conv);
20415         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20416         Str_free(ret_str);
20417         return ret_conv;
20418 }
20419
20420 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
20421         LDKRecord this_ptr_conv;
20422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20423         this_ptr_conv.is_owned = false;
20424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20425         LDKStr val_conv = str_ref_to_owned_c(val);
20426         Record_set_file(&this_ptr_conv, val_conv);
20427 }
20428
20429 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
20430         LDKRecord this_ptr_conv;
20431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20432         this_ptr_conv.is_owned = false;
20433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20434         int32_t ret_val = Record_get_line(&this_ptr_conv);
20435         return ret_val;
20436 }
20437
20438 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
20439         LDKRecord this_ptr_conv;
20440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20441         this_ptr_conv.is_owned = false;
20442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20443         Record_set_line(&this_ptr_conv, val);
20444 }
20445
20446 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
20447         LDKRecord ret_var = Record_clone(arg);
20448 uint32_t ret_ref = 0;
20449 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20450 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20451 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20452 ret_ref = (uintptr_t)ret_var.inner;
20453 if (ret_var.is_owned) {
20454         ret_ref |= 1;
20455 }
20456         return ret_ref;
20457 }
20458 uint32_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
20459         LDKRecord arg_conv;
20460         arg_conv.inner = (void*)(arg & (~1));
20461         arg_conv.is_owned = false;
20462         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20463         uint32_t ret_val = Record_clone_ptr(&arg_conv);
20464         return ret_val;
20465 }
20466
20467 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
20468         LDKRecord orig_conv;
20469         orig_conv.inner = (void*)(orig & (~1));
20470         orig_conv.is_owned = false;
20471         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20472         LDKRecord ret_var = Record_clone(&orig_conv);
20473         uint32_t ret_ref = 0;
20474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20477         ret_ref = (uintptr_t)ret_var.inner;
20478         if (ret_var.is_owned) {
20479                 ret_ref |= 1;
20480         }
20481         return ret_ref;
20482 }
20483
20484 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
20485         if ((this_ptr & 1) != 0) return;
20486         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20487         CHECK_ACCESS(this_ptr_ptr);
20488         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
20489         FREE((void*)this_ptr);
20490         Logger_free(this_ptr_conv);
20491 }
20492
20493 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
20494         LDKChannelHandshakeConfig this_obj_conv;
20495         this_obj_conv.inner = (void*)(this_obj & (~1));
20496         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20498         ChannelHandshakeConfig_free(this_obj_conv);
20499 }
20500
20501 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
20502         LDKChannelHandshakeConfig 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         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
20507         return ret_val;
20508 }
20509
20510 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
20511         LDKChannelHandshakeConfig this_ptr_conv;
20512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20513         this_ptr_conv.is_owned = false;
20514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20515         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
20516 }
20517
20518 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
20519         LDKChannelHandshakeConfig this_ptr_conv;
20520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20521         this_ptr_conv.is_owned = false;
20522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20523         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
20524         return ret_val;
20525 }
20526
20527 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) {
20528         LDKChannelHandshakeConfig this_ptr_conv;
20529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20530         this_ptr_conv.is_owned = false;
20531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20532         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
20533 }
20534
20535 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
20536         LDKChannelHandshakeConfig this_ptr_conv;
20537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20538         this_ptr_conv.is_owned = false;
20539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20540         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
20541         return ret_val;
20542 }
20543
20544 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) {
20545         LDKChannelHandshakeConfig this_ptr_conv;
20546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20547         this_ptr_conv.is_owned = false;
20548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20549         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
20550 }
20551
20552 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_get_negotiate_scid_privacy(uint32_t this_ptr) {
20553         LDKChannelHandshakeConfig this_ptr_conv;
20554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20555         this_ptr_conv.is_owned = false;
20556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20557         jboolean ret_val = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
20558         return ret_val;
20559 }
20560
20561 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_set_negotiate_scid_privacy(uint32_t this_ptr, jboolean val) {
20562         LDKChannelHandshakeConfig this_ptr_conv;
20563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20564         this_ptr_conv.is_owned = false;
20565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20566         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
20567 }
20568
20569 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) {
20570         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, negotiate_scid_privacy_arg);
20571         uint32_t ret_ref = 0;
20572         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20573         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20575         ret_ref = (uintptr_t)ret_var.inner;
20576         if (ret_var.is_owned) {
20577                 ret_ref |= 1;
20578         }
20579         return ret_ref;
20580 }
20581
20582 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
20583         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
20584 uint32_t ret_ref = 0;
20585 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20586 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20587 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20588 ret_ref = (uintptr_t)ret_var.inner;
20589 if (ret_var.is_owned) {
20590         ret_ref |= 1;
20591 }
20592         return ret_ref;
20593 }
20594 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
20595         LDKChannelHandshakeConfig arg_conv;
20596         arg_conv.inner = (void*)(arg & (~1));
20597         arg_conv.is_owned = false;
20598         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20599         uint32_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
20600         return ret_val;
20601 }
20602
20603 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
20604         LDKChannelHandshakeConfig orig_conv;
20605         orig_conv.inner = (void*)(orig & (~1));
20606         orig_conv.is_owned = false;
20607         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20608         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
20609         uint32_t ret_ref = 0;
20610         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20611         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20613         ret_ref = (uintptr_t)ret_var.inner;
20614         if (ret_var.is_owned) {
20615                 ret_ref |= 1;
20616         }
20617         return ret_ref;
20618 }
20619
20620 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
20621         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
20622         uint32_t ret_ref = 0;
20623         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20624         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20626         ret_ref = (uintptr_t)ret_var.inner;
20627         if (ret_var.is_owned) {
20628                 ret_ref |= 1;
20629         }
20630         return ret_ref;
20631 }
20632
20633 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
20634         LDKChannelHandshakeLimits this_obj_conv;
20635         this_obj_conv.inner = (void*)(this_obj & (~1));
20636         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20638         ChannelHandshakeLimits_free(this_obj_conv);
20639 }
20640
20641 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
20642         LDKChannelHandshakeLimits this_ptr_conv;
20643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20644         this_ptr_conv.is_owned = false;
20645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20646         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
20647         return ret_val;
20648 }
20649
20650 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
20651         LDKChannelHandshakeLimits this_ptr_conv;
20652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20653         this_ptr_conv.is_owned = false;
20654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20655         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
20656 }
20657
20658 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
20659         LDKChannelHandshakeLimits this_ptr_conv;
20660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20661         this_ptr_conv.is_owned = false;
20662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20663         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
20664         return ret_val;
20665 }
20666
20667 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) {
20668         LDKChannelHandshakeLimits this_ptr_conv;
20669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20670         this_ptr_conv.is_owned = false;
20671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20672         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
20673 }
20674
20675 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) {
20676         LDKChannelHandshakeLimits this_ptr_conv;
20677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20678         this_ptr_conv.is_owned = false;
20679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20680         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
20681         return ret_val;
20682 }
20683
20684 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) {
20685         LDKChannelHandshakeLimits this_ptr_conv;
20686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20687         this_ptr_conv.is_owned = false;
20688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20689         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
20690 }
20691
20692 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
20693         LDKChannelHandshakeLimits this_ptr_conv;
20694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20695         this_ptr_conv.is_owned = false;
20696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20697         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
20698         return ret_val;
20699 }
20700
20701 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) {
20702         LDKChannelHandshakeLimits this_ptr_conv;
20703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20704         this_ptr_conv.is_owned = false;
20705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20706         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
20707 }
20708
20709 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
20710         LDKChannelHandshakeLimits this_ptr_conv;
20711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20712         this_ptr_conv.is_owned = false;
20713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20714         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
20715         return ret_val;
20716 }
20717
20718 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) {
20719         LDKChannelHandshakeLimits this_ptr_conv;
20720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20721         this_ptr_conv.is_owned = false;
20722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20723         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
20724 }
20725
20726 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
20727         LDKChannelHandshakeLimits this_ptr_conv;
20728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20729         this_ptr_conv.is_owned = false;
20730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20731         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
20732         return ret_val;
20733 }
20734
20735 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
20736         LDKChannelHandshakeLimits this_ptr_conv;
20737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20738         this_ptr_conv.is_owned = false;
20739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20740         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
20741 }
20742
20743 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
20744         LDKChannelHandshakeLimits this_ptr_conv;
20745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20746         this_ptr_conv.is_owned = false;
20747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20748         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
20749         return ret_val;
20750 }
20751
20752 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
20753         LDKChannelHandshakeLimits this_ptr_conv;
20754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20755         this_ptr_conv.is_owned = false;
20756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20757         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
20758 }
20759
20760 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
20761         LDKChannelHandshakeLimits this_ptr_conv;
20762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20763         this_ptr_conv.is_owned = false;
20764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20765         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
20766         return ret_val;
20767 }
20768
20769 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) {
20770         LDKChannelHandshakeLimits this_ptr_conv;
20771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20772         this_ptr_conv.is_owned = false;
20773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20774         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
20775 }
20776
20777 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) {
20778         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);
20779         uint32_t ret_ref = 0;
20780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20783         ret_ref = (uintptr_t)ret_var.inner;
20784         if (ret_var.is_owned) {
20785                 ret_ref |= 1;
20786         }
20787         return ret_ref;
20788 }
20789
20790 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
20791         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
20792 uint32_t ret_ref = 0;
20793 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20794 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20795 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20796 ret_ref = (uintptr_t)ret_var.inner;
20797 if (ret_var.is_owned) {
20798         ret_ref |= 1;
20799 }
20800         return ret_ref;
20801 }
20802 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
20803         LDKChannelHandshakeLimits arg_conv;
20804         arg_conv.inner = (void*)(arg & (~1));
20805         arg_conv.is_owned = false;
20806         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20807         uint32_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
20808         return ret_val;
20809 }
20810
20811 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
20812         LDKChannelHandshakeLimits orig_conv;
20813         orig_conv.inner = (void*)(orig & (~1));
20814         orig_conv.is_owned = false;
20815         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20816         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
20817         uint32_t ret_ref = 0;
20818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20821         ret_ref = (uintptr_t)ret_var.inner;
20822         if (ret_var.is_owned) {
20823                 ret_ref |= 1;
20824         }
20825         return ret_ref;
20826 }
20827
20828 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
20829         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
20830         uint32_t ret_ref = 0;
20831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20834         ret_ref = (uintptr_t)ret_var.inner;
20835         if (ret_var.is_owned) {
20836                 ret_ref |= 1;
20837         }
20838         return ret_ref;
20839 }
20840
20841 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
20842         LDKChannelConfig this_obj_conv;
20843         this_obj_conv.inner = (void*)(this_obj & (~1));
20844         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20846         ChannelConfig_free(this_obj_conv);
20847 }
20848
20849 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
20850         LDKChannelConfig this_ptr_conv;
20851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20852         this_ptr_conv.is_owned = false;
20853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20854         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
20855         return ret_val;
20856 }
20857
20858 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) {
20859         LDKChannelConfig this_ptr_conv;
20860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20861         this_ptr_conv.is_owned = false;
20862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20863         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
20864 }
20865
20866 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
20867         LDKChannelConfig this_ptr_conv;
20868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20869         this_ptr_conv.is_owned = false;
20870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20871         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
20872         return ret_val;
20873 }
20874
20875 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) {
20876         LDKChannelConfig this_ptr_conv;
20877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20878         this_ptr_conv.is_owned = false;
20879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20880         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
20881 }
20882
20883 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
20884         LDKChannelConfig this_ptr_conv;
20885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20886         this_ptr_conv.is_owned = false;
20887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20888         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
20889         return ret_val;
20890 }
20891
20892 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20893         LDKChannelConfig this_ptr_conv;
20894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20895         this_ptr_conv.is_owned = false;
20896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20897         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
20898 }
20899
20900 jboolean  __attribute__((export_name("TS_ChannelConfig_get_announced_channel"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
20901         LDKChannelConfig this_ptr_conv;
20902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20903         this_ptr_conv.is_owned = false;
20904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20905         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
20906         return ret_val;
20907 }
20908
20909 void  __attribute__((export_name("TS_ChannelConfig_set_announced_channel"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
20910         LDKChannelConfig this_ptr_conv;
20911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20912         this_ptr_conv.is_owned = false;
20913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20914         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
20915 }
20916
20917 jboolean  __attribute__((export_name("TS_ChannelConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
20918         LDKChannelConfig this_ptr_conv;
20919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20920         this_ptr_conv.is_owned = false;
20921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20922         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
20923         return ret_val;
20924 }
20925
20926 void  __attribute__((export_name("TS_ChannelConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
20927         LDKChannelConfig this_ptr_conv;
20928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20929         this_ptr_conv.is_owned = false;
20930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20931         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
20932 }
20933
20934 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) {
20935         LDKChannelConfig this_ptr_conv;
20936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20937         this_ptr_conv.is_owned = false;
20938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20939         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
20940         return ret_val;
20941 }
20942
20943 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) {
20944         LDKChannelConfig this_ptr_conv;
20945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20946         this_ptr_conv.is_owned = false;
20947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20948         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
20949 }
20950
20951 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) {
20952         LDKChannelConfig this_ptr_conv;
20953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20954         this_ptr_conv.is_owned = false;
20955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20956         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
20957         return ret_val;
20958 }
20959
20960 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) {
20961         LDKChannelConfig this_ptr_conv;
20962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20963         this_ptr_conv.is_owned = false;
20964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20965         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
20966 }
20967
20968 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) {
20969         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);
20970         uint32_t ret_ref = 0;
20971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20974         ret_ref = (uintptr_t)ret_var.inner;
20975         if (ret_var.is_owned) {
20976                 ret_ref |= 1;
20977         }
20978         return ret_ref;
20979 }
20980
20981 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
20982         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
20983 uint32_t ret_ref = 0;
20984 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20985 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20986 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20987 ret_ref = (uintptr_t)ret_var.inner;
20988 if (ret_var.is_owned) {
20989         ret_ref |= 1;
20990 }
20991         return ret_ref;
20992 }
20993 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
20994         LDKChannelConfig arg_conv;
20995         arg_conv.inner = (void*)(arg & (~1));
20996         arg_conv.is_owned = false;
20997         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20998         uint32_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
20999         return ret_val;
21000 }
21001
21002 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
21003         LDKChannelConfig orig_conv;
21004         orig_conv.inner = (void*)(orig & (~1));
21005         orig_conv.is_owned = false;
21006         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21007         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
21008         uint32_t ret_ref = 0;
21009         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21010         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21012         ret_ref = (uintptr_t)ret_var.inner;
21013         if (ret_var.is_owned) {
21014                 ret_ref |= 1;
21015         }
21016         return ret_ref;
21017 }
21018
21019 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
21020         LDKChannelConfig ret_var = ChannelConfig_default();
21021         uint32_t ret_ref = 0;
21022         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21023         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21025         ret_ref = (uintptr_t)ret_var.inner;
21026         if (ret_var.is_owned) {
21027                 ret_ref |= 1;
21028         }
21029         return ret_ref;
21030 }
21031
21032 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
21033         LDKChannelConfig obj_conv;
21034         obj_conv.inner = (void*)(obj & (~1));
21035         obj_conv.is_owned = false;
21036         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21037         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
21038         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21039         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21040         CVec_u8Z_free(ret_var);
21041         return ret_arr;
21042 }
21043
21044 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
21045         LDKu8slice ser_ref;
21046         ser_ref.datalen = ser->arr_len;
21047         ser_ref.data = ser->elems /* XXX ser leaks */;
21048         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21049         *ret_conv = ChannelConfig_read(ser_ref);
21050         return (uint32_t)ret_conv;
21051 }
21052
21053 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
21054         LDKUserConfig this_obj_conv;
21055         this_obj_conv.inner = (void*)(this_obj & (~1));
21056         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21058         UserConfig_free(this_obj_conv);
21059 }
21060
21061 uint32_t  __attribute__((export_name("TS_UserConfig_get_own_channel_config"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
21062         LDKUserConfig this_ptr_conv;
21063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21064         this_ptr_conv.is_owned = false;
21065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21066         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
21067         uint32_t ret_ref = 0;
21068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21071         ret_ref = (uintptr_t)ret_var.inner;
21072         if (ret_var.is_owned) {
21073                 ret_ref |= 1;
21074         }
21075         return ret_ref;
21076 }
21077
21078 void  __attribute__((export_name("TS_UserConfig_set_own_channel_config"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
21079         LDKUserConfig this_ptr_conv;
21080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21081         this_ptr_conv.is_owned = false;
21082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21083         LDKChannelHandshakeConfig val_conv;
21084         val_conv.inner = (void*)(val & (~1));
21085         val_conv.is_owned = (val & 1) || (val == 0);
21086         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21087         val_conv = ChannelHandshakeConfig_clone(&val_conv);
21088         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
21089 }
21090
21091 uint32_t  __attribute__((export_name("TS_UserConfig_get_peer_channel_config_limits"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
21092         LDKUserConfig this_ptr_conv;
21093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21094         this_ptr_conv.is_owned = false;
21095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21096         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
21097         uint32_t ret_ref = 0;
21098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21101         ret_ref = (uintptr_t)ret_var.inner;
21102         if (ret_var.is_owned) {
21103                 ret_ref |= 1;
21104         }
21105         return ret_ref;
21106 }
21107
21108 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) {
21109         LDKUserConfig this_ptr_conv;
21110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21111         this_ptr_conv.is_owned = false;
21112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21113         LDKChannelHandshakeLimits val_conv;
21114         val_conv.inner = (void*)(val & (~1));
21115         val_conv.is_owned = (val & 1) || (val == 0);
21116         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21117         val_conv = ChannelHandshakeLimits_clone(&val_conv);
21118         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
21119 }
21120
21121 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_options"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
21122         LDKUserConfig this_ptr_conv;
21123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21124         this_ptr_conv.is_owned = false;
21125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21126         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
21127         uint32_t ret_ref = 0;
21128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21131         ret_ref = (uintptr_t)ret_var.inner;
21132         if (ret_var.is_owned) {
21133                 ret_ref |= 1;
21134         }
21135         return ret_ref;
21136 }
21137
21138 void  __attribute__((export_name("TS_UserConfig_set_channel_options"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
21139         LDKUserConfig this_ptr_conv;
21140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21141         this_ptr_conv.is_owned = false;
21142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21143         LDKChannelConfig val_conv;
21144         val_conv.inner = (void*)(val & (~1));
21145         val_conv.is_owned = (val & 1) || (val == 0);
21146         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21147         val_conv = ChannelConfig_clone(&val_conv);
21148         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
21149 }
21150
21151 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
21152         LDKUserConfig this_ptr_conv;
21153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21154         this_ptr_conv.is_owned = false;
21155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21156         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
21157         return ret_val;
21158 }
21159
21160 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) {
21161         LDKUserConfig this_ptr_conv;
21162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21163         this_ptr_conv.is_owned = false;
21164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21165         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
21166 }
21167
21168 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
21169         LDKUserConfig this_ptr_conv;
21170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21171         this_ptr_conv.is_owned = false;
21172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21173         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
21174         return ret_val;
21175 }
21176
21177 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
21178         LDKUserConfig this_ptr_conv;
21179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21180         this_ptr_conv.is_owned = false;
21181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21182         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
21183 }
21184
21185 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint32_t this_ptr) {
21186         LDKUserConfig this_ptr_conv;
21187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21188         this_ptr_conv.is_owned = false;
21189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21190         jboolean ret_val = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
21191         return ret_val;
21192 }
21193
21194 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
21195         LDKUserConfig this_ptr_conv;
21196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21197         this_ptr_conv.is_owned = false;
21198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21199         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
21200 }
21201
21202 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) {
21203         LDKChannelHandshakeConfig own_channel_config_arg_conv;
21204         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
21205         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
21206         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
21207         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
21208         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
21209         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
21210         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
21211         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
21212         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
21213         LDKChannelConfig channel_options_arg_conv;
21214         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
21215         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
21216         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
21217         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
21218         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);
21219         uint32_t ret_ref = 0;
21220         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21221         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21223         ret_ref = (uintptr_t)ret_var.inner;
21224         if (ret_var.is_owned) {
21225                 ret_ref |= 1;
21226         }
21227         return ret_ref;
21228 }
21229
21230 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
21231         LDKUserConfig ret_var = UserConfig_clone(arg);
21232 uint32_t ret_ref = 0;
21233 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21234 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21235 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21236 ret_ref = (uintptr_t)ret_var.inner;
21237 if (ret_var.is_owned) {
21238         ret_ref |= 1;
21239 }
21240         return ret_ref;
21241 }
21242 uint32_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
21243         LDKUserConfig arg_conv;
21244         arg_conv.inner = (void*)(arg & (~1));
21245         arg_conv.is_owned = false;
21246         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21247         uint32_t ret_val = UserConfig_clone_ptr(&arg_conv);
21248         return ret_val;
21249 }
21250
21251 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
21252         LDKUserConfig orig_conv;
21253         orig_conv.inner = (void*)(orig & (~1));
21254         orig_conv.is_owned = false;
21255         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21256         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
21257         uint32_t ret_ref = 0;
21258         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21259         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21260         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21261         ret_ref = (uintptr_t)ret_var.inner;
21262         if (ret_var.is_owned) {
21263                 ret_ref |= 1;
21264         }
21265         return ret_ref;
21266 }
21267
21268 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
21269         LDKUserConfig ret_var = UserConfig_default();
21270         uint32_t ret_ref = 0;
21271         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21272         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21274         ret_ref = (uintptr_t)ret_var.inner;
21275         if (ret_var.is_owned) {
21276                 ret_ref |= 1;
21277         }
21278         return ret_ref;
21279 }
21280
21281 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
21282         LDKBestBlock this_obj_conv;
21283         this_obj_conv.inner = (void*)(this_obj & (~1));
21284         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21286         BestBlock_free(this_obj_conv);
21287 }
21288
21289 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
21290         LDKBestBlock ret_var = BestBlock_clone(arg);
21291 uint32_t ret_ref = 0;
21292 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21293 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21294 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21295 ret_ref = (uintptr_t)ret_var.inner;
21296 if (ret_var.is_owned) {
21297         ret_ref |= 1;
21298 }
21299         return ret_ref;
21300 }
21301 uint32_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
21302         LDKBestBlock arg_conv;
21303         arg_conv.inner = (void*)(arg & (~1));
21304         arg_conv.is_owned = false;
21305         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21306         uint32_t ret_val = BestBlock_clone_ptr(&arg_conv);
21307         return ret_val;
21308 }
21309
21310 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
21311         LDKBestBlock orig_conv;
21312         orig_conv.inner = (void*)(orig & (~1));
21313         orig_conv.is_owned = false;
21314         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21315         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
21316         uint32_t ret_ref = 0;
21317         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21318         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21320         ret_ref = (uintptr_t)ret_var.inner;
21321         if (ret_var.is_owned) {
21322                 ret_ref |= 1;
21323         }
21324         return ret_ref;
21325 }
21326
21327 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
21328         LDKNetwork network_conv = LDKNetwork_from_js(network);
21329         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
21330         uint32_t ret_ref = 0;
21331         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21332         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21334         ret_ref = (uintptr_t)ret_var.inner;
21335         if (ret_var.is_owned) {
21336                 ret_ref |= 1;
21337         }
21338         return ret_ref;
21339 }
21340
21341 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
21342         LDKThirtyTwoBytes block_hash_ref;
21343         CHECK(block_hash->arr_len == 32);
21344         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
21345         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
21346         uint32_t ret_ref = 0;
21347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21350         ret_ref = (uintptr_t)ret_var.inner;
21351         if (ret_var.is_owned) {
21352                 ret_ref |= 1;
21353         }
21354         return ret_ref;
21355 }
21356
21357 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
21358         LDKBestBlock this_arg_conv;
21359         this_arg_conv.inner = (void*)(this_arg & (~1));
21360         this_arg_conv.is_owned = false;
21361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21362         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21363         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
21364         return ret_arr;
21365 }
21366
21367 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
21368         LDKBestBlock this_arg_conv;
21369         this_arg_conv.inner = (void*)(this_arg & (~1));
21370         this_arg_conv.is_owned = false;
21371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21372         int32_t ret_val = BestBlock_height(&this_arg_conv);
21373         return ret_val;
21374 }
21375
21376 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
21377         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
21378         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
21379         return ret_conv;
21380 }
21381
21382 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
21383         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
21384         return ret_conv;
21385 }
21386
21387 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
21388         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
21389         return ret_conv;
21390 }
21391
21392 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
21393         if ((this_ptr & 1) != 0) return;
21394         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21395         CHECK_ACCESS(this_ptr_ptr);
21396         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
21397         FREE((void*)this_ptr);
21398         Access_free(this_ptr_conv);
21399 }
21400
21401 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
21402         if ((this_ptr & 1) != 0) return;
21403         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21404         CHECK_ACCESS(this_ptr_ptr);
21405         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
21406         FREE((void*)this_ptr);
21407         Listen_free(this_ptr_conv);
21408 }
21409
21410 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
21411         if ((this_ptr & 1) != 0) return;
21412         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21413         CHECK_ACCESS(this_ptr_ptr);
21414         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
21415         FREE((void*)this_ptr);
21416         Confirm_free(this_ptr_conv);
21417 }
21418
21419 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
21420         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
21421         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
21422         return ret_conv;
21423 }
21424
21425 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
21426         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
21427         return ret_conv;
21428 }
21429
21430 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
21431         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
21432         return ret_conv;
21433 }
21434
21435 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
21436         if ((this_ptr & 1) != 0) return;
21437         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21438         CHECK_ACCESS(this_ptr_ptr);
21439         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
21440         FREE((void*)this_ptr);
21441         Watch_free(this_ptr_conv);
21442 }
21443
21444 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
21445         if ((this_ptr & 1) != 0) return;
21446         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21447         CHECK_ACCESS(this_ptr_ptr);
21448         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
21449         FREE((void*)this_ptr);
21450         Filter_free(this_ptr_conv);
21451 }
21452
21453 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
21454         LDKWatchedOutput this_obj_conv;
21455         this_obj_conv.inner = (void*)(this_obj & (~1));
21456         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21458         WatchedOutput_free(this_obj_conv);
21459 }
21460
21461 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
21462         LDKWatchedOutput this_ptr_conv;
21463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21464         this_ptr_conv.is_owned = false;
21465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21466         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21467         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
21468         return ret_arr;
21469 }
21470
21471 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
21472         LDKWatchedOutput this_ptr_conv;
21473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21474         this_ptr_conv.is_owned = false;
21475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21476         LDKThirtyTwoBytes val_ref;
21477         CHECK(val->arr_len == 32);
21478         memcpy(val_ref.data, val->elems, 32); FREE(val);
21479         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
21480 }
21481
21482 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
21483         LDKWatchedOutput this_ptr_conv;
21484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21485         this_ptr_conv.is_owned = false;
21486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21487         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
21488         uint32_t ret_ref = 0;
21489         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21490         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21492         ret_ref = (uintptr_t)ret_var.inner;
21493         if (ret_var.is_owned) {
21494                 ret_ref |= 1;
21495         }
21496         return ret_ref;
21497 }
21498
21499 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
21500         LDKWatchedOutput this_ptr_conv;
21501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21502         this_ptr_conv.is_owned = false;
21503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21504         LDKOutPoint val_conv;
21505         val_conv.inner = (void*)(val & (~1));
21506         val_conv.is_owned = (val & 1) || (val == 0);
21507         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21508         val_conv = OutPoint_clone(&val_conv);
21509         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
21510 }
21511
21512 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
21513         LDKWatchedOutput this_ptr_conv;
21514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21515         this_ptr_conv.is_owned = false;
21516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21517         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
21518         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21519         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21520         return ret_arr;
21521 }
21522
21523 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
21524         LDKWatchedOutput this_ptr_conv;
21525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21526         this_ptr_conv.is_owned = false;
21527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21528         LDKCVec_u8Z val_ref;
21529         val_ref.datalen = val->arr_len;
21530         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
21531         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
21532         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
21533 }
21534
21535 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) {
21536         LDKThirtyTwoBytes block_hash_arg_ref;
21537         CHECK(block_hash_arg->arr_len == 32);
21538         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
21539         LDKOutPoint outpoint_arg_conv;
21540         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
21541         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
21542         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
21543         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
21544         LDKCVec_u8Z script_pubkey_arg_ref;
21545         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
21546         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
21547         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
21548         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
21549         uint32_t ret_ref = 0;
21550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21553         ret_ref = (uintptr_t)ret_var.inner;
21554         if (ret_var.is_owned) {
21555                 ret_ref |= 1;
21556         }
21557         return ret_ref;
21558 }
21559
21560 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
21561         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
21562 uint32_t ret_ref = 0;
21563 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21564 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21565 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21566 ret_ref = (uintptr_t)ret_var.inner;
21567 if (ret_var.is_owned) {
21568         ret_ref |= 1;
21569 }
21570         return ret_ref;
21571 }
21572 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
21573         LDKWatchedOutput arg_conv;
21574         arg_conv.inner = (void*)(arg & (~1));
21575         arg_conv.is_owned = false;
21576         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21577         uint32_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
21578         return ret_val;
21579 }
21580
21581 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
21582         LDKWatchedOutput orig_conv;
21583         orig_conv.inner = (void*)(orig & (~1));
21584         orig_conv.is_owned = false;
21585         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21586         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
21587         uint32_t ret_ref = 0;
21588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21591         ret_ref = (uintptr_t)ret_var.inner;
21592         if (ret_var.is_owned) {
21593                 ret_ref |= 1;
21594         }
21595         return ret_ref;
21596 }
21597
21598 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
21599         LDKWatchedOutput o_conv;
21600         o_conv.inner = (void*)(o & (~1));
21601         o_conv.is_owned = false;
21602         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21603         int64_t ret_val = WatchedOutput_hash(&o_conv);
21604         return ret_val;
21605 }
21606
21607 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
21608         if ((this_ptr & 1) != 0) return;
21609         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21610         CHECK_ACCESS(this_ptr_ptr);
21611         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
21612         FREE((void*)this_ptr);
21613         BroadcasterInterface_free(this_ptr_conv);
21614 }
21615
21616 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
21617         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
21618         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
21619         return ret_conv;
21620 }
21621
21622 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
21623         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
21624         return ret_conv;
21625 }
21626
21627 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
21628         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
21629         return ret_conv;
21630 }
21631
21632 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
21633         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
21634         return ret_conv;
21635 }
21636
21637 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
21638         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
21639         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
21640         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
21641         return ret_val;
21642 }
21643
21644 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
21645         if ((this_ptr & 1) != 0) return;
21646         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21647         CHECK_ACCESS(this_ptr_ptr);
21648         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
21649         FREE((void*)this_ptr);
21650         FeeEstimator_free(this_ptr_conv);
21651 }
21652
21653 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
21654         LDKMonitorUpdateId this_obj_conv;
21655         this_obj_conv.inner = (void*)(this_obj & (~1));
21656         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21658         MonitorUpdateId_free(this_obj_conv);
21659 }
21660
21661 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
21662         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
21663 uint32_t ret_ref = 0;
21664 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21665 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21666 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21667 ret_ref = (uintptr_t)ret_var.inner;
21668 if (ret_var.is_owned) {
21669         ret_ref |= 1;
21670 }
21671         return ret_ref;
21672 }
21673 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
21674         LDKMonitorUpdateId arg_conv;
21675         arg_conv.inner = (void*)(arg & (~1));
21676         arg_conv.is_owned = false;
21677         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21678         uint32_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
21679         return ret_val;
21680 }
21681
21682 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
21683         LDKMonitorUpdateId orig_conv;
21684         orig_conv.inner = (void*)(orig & (~1));
21685         orig_conv.is_owned = false;
21686         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21687         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
21688         uint32_t ret_ref = 0;
21689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21692         ret_ref = (uintptr_t)ret_var.inner;
21693         if (ret_var.is_owned) {
21694                 ret_ref |= 1;
21695         }
21696         return ret_ref;
21697 }
21698
21699 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
21700         LDKMonitorUpdateId o_conv;
21701         o_conv.inner = (void*)(o & (~1));
21702         o_conv.is_owned = false;
21703         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21704         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
21705         return ret_val;
21706 }
21707
21708 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
21709         LDKMonitorUpdateId a_conv;
21710         a_conv.inner = (void*)(a & (~1));
21711         a_conv.is_owned = false;
21712         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21713         LDKMonitorUpdateId b_conv;
21714         b_conv.inner = (void*)(b & (~1));
21715         b_conv.is_owned = false;
21716         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21717         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
21718         return ret_val;
21719 }
21720
21721 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
21722         if ((this_ptr & 1) != 0) return;
21723         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21724         CHECK_ACCESS(this_ptr_ptr);
21725         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
21726         FREE((void*)this_ptr);
21727         Persist_free(this_ptr_conv);
21728 }
21729
21730 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
21731         LDKLockedChannelMonitor this_obj_conv;
21732         this_obj_conv.inner = (void*)(this_obj & (~1));
21733         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21735         LockedChannelMonitor_free(this_obj_conv);
21736 }
21737
21738 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
21739         LDKChainMonitor this_obj_conv;
21740         this_obj_conv.inner = (void*)(this_obj & (~1));
21741         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21743         ChainMonitor_free(this_obj_conv);
21744 }
21745
21746 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) {
21747         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
21748         CHECK_ACCESS(chain_source_ptr);
21749         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
21750         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
21751         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
21752                 // Manually implement clone for Java trait instances
21753                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
21754                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21755                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
21756                 }
21757         }
21758         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
21759         CHECK_ACCESS(broadcaster_ptr);
21760         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
21761         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
21762                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21763                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
21764         }
21765         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
21766         CHECK_ACCESS(logger_ptr);
21767         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21768         if (logger_conv.free == LDKLogger_JCalls_free) {
21769                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21770                 LDKLogger_JCalls_cloned(&logger_conv);
21771         }
21772         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
21773         CHECK_ACCESS(feeest_ptr);
21774         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
21775         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
21776                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21777                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
21778         }
21779         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
21780         CHECK_ACCESS(persister_ptr);
21781         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
21782         if (persister_conv.free == LDKPersist_JCalls_free) {
21783                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21784                 LDKPersist_JCalls_cloned(&persister_conv);
21785         }
21786         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
21787         uint32_t ret_ref = 0;
21788         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21789         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21791         ret_ref = (uintptr_t)ret_var.inner;
21792         if (ret_var.is_owned) {
21793                 ret_ref |= 1;
21794         }
21795         return ret_ref;
21796 }
21797
21798 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
21799         LDKChainMonitor this_arg_conv;
21800         this_arg_conv.inner = (void*)(this_arg & (~1));
21801         this_arg_conv.is_owned = false;
21802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21803         LDKCVec_ChannelDetailsZ ignored_channels_constr;
21804         ignored_channels_constr.datalen = ignored_channels->arr_len;
21805         if (ignored_channels_constr.datalen > 0)
21806                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
21807         else
21808                 ignored_channels_constr.data = NULL;
21809         uint32_t* ignored_channels_vals = ignored_channels->elems /* XXX ignored_channels leaks */;
21810         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
21811                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
21812                 LDKChannelDetails ignored_channels_conv_16_conv;
21813                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
21814                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
21815                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
21816                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
21817                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
21818         }
21819         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
21820         uint32_tArray ret_arr = NULL;
21821         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21822         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21823         for (size_t j = 0; j < ret_var.datalen; j++) {
21824                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21825                 *ret_conv_9_copy = ret_var.data[j];
21826                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
21827                 ret_arr_ptr[j] = ret_conv_9_ref;
21828         }
21829         
21830         FREE(ret_var.data);
21831         return ret_arr;
21832 }
21833
21834 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
21835         LDKChainMonitor this_arg_conv;
21836         this_arg_conv.inner = (void*)(this_arg & (~1));
21837         this_arg_conv.is_owned = false;
21838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21839         LDKOutPoint funding_txo_conv;
21840         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21841         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21842         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21843         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21844         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
21845         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
21846         return (uint32_t)ret_conv;
21847 }
21848
21849 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
21850         LDKChainMonitor this_arg_conv;
21851         this_arg_conv.inner = (void*)(this_arg & (~1));
21852         this_arg_conv.is_owned = false;
21853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21854         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
21855         uint32_tArray ret_arr = NULL;
21856         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21857         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21858         for (size_t k = 0; k < ret_var.datalen; k++) {
21859                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
21860                 uint32_t ret_conv_10_ref = 0;
21861                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21862                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21863                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
21864                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
21865                 if (ret_conv_10_var.is_owned) {
21866                         ret_conv_10_ref |= 1;
21867                 }
21868                 ret_arr_ptr[k] = ret_conv_10_ref;
21869         }
21870         
21871         FREE(ret_var.data);
21872         return ret_arr;
21873 }
21874
21875 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) {
21876         LDKChainMonitor this_arg_conv;
21877         this_arg_conv.inner = (void*)(this_arg & (~1));
21878         this_arg_conv.is_owned = false;
21879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21880         LDKOutPoint funding_txo_conv;
21881         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21882         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21883         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21884         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21885         LDKMonitorUpdateId completed_update_id_conv;
21886         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
21887         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
21888         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
21889         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
21890         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21891         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
21892         return (uint32_t)ret_conv;
21893 }
21894
21895 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
21896         LDKChainMonitor this_arg_conv;
21897         this_arg_conv.inner = (void*)(this_arg & (~1));
21898         this_arg_conv.is_owned = false;
21899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21900         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
21901         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
21902         return (uint32_t)ret_ret;
21903 }
21904
21905 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
21906         LDKChainMonitor this_arg_conv;
21907         this_arg_conv.inner = (void*)(this_arg & (~1));
21908         this_arg_conv.is_owned = false;
21909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21910         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
21911         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
21912         return (uint32_t)ret_ret;
21913 }
21914
21915 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
21916         LDKChainMonitor this_arg_conv;
21917         this_arg_conv.inner = (void*)(this_arg & (~1));
21918         this_arg_conv.is_owned = false;
21919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21920         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
21921         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
21922         return (uint32_t)ret_ret;
21923 }
21924
21925 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
21926         LDKChainMonitor this_arg_conv;
21927         this_arg_conv.inner = (void*)(this_arg & (~1));
21928         this_arg_conv.is_owned = false;
21929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21930         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
21931         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
21932         return (uint32_t)ret_ret;
21933 }
21934
21935 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
21936         LDKChannelMonitorUpdate this_obj_conv;
21937         this_obj_conv.inner = (void*)(this_obj & (~1));
21938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21940         ChannelMonitorUpdate_free(this_obj_conv);
21941 }
21942
21943 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
21944         LDKChannelMonitorUpdate this_ptr_conv;
21945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21946         this_ptr_conv.is_owned = false;
21947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21948         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
21949         return ret_val;
21950 }
21951
21952 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
21953         LDKChannelMonitorUpdate this_ptr_conv;
21954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21955         this_ptr_conv.is_owned = false;
21956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21957         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
21958 }
21959
21960 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
21961         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
21962 uint32_t ret_ref = 0;
21963 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21964 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21965 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21966 ret_ref = (uintptr_t)ret_var.inner;
21967 if (ret_var.is_owned) {
21968         ret_ref |= 1;
21969 }
21970         return ret_ref;
21971 }
21972 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
21973         LDKChannelMonitorUpdate arg_conv;
21974         arg_conv.inner = (void*)(arg & (~1));
21975         arg_conv.is_owned = false;
21976         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21977         uint32_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
21978         return ret_val;
21979 }
21980
21981 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
21982         LDKChannelMonitorUpdate orig_conv;
21983         orig_conv.inner = (void*)(orig & (~1));
21984         orig_conv.is_owned = false;
21985         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21986         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
21987         uint32_t ret_ref = 0;
21988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21991         ret_ref = (uintptr_t)ret_var.inner;
21992         if (ret_var.is_owned) {
21993                 ret_ref |= 1;
21994         }
21995         return ret_ref;
21996 }
21997
21998 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
21999         LDKChannelMonitorUpdate obj_conv;
22000         obj_conv.inner = (void*)(obj & (~1));
22001         obj_conv.is_owned = false;
22002         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22003         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
22004         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22005         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22006         CVec_u8Z_free(ret_var);
22007         return ret_arr;
22008 }
22009
22010 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
22011         LDKu8slice ser_ref;
22012         ser_ref.datalen = ser->arr_len;
22013         ser_ref.data = ser->elems /* XXX ser leaks */;
22014         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22015         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
22016         return (uint32_t)ret_conv;
22017 }
22018
22019 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
22020         if ((this_ptr & 1) != 0) return;
22021         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22022         CHECK_ACCESS(this_ptr_ptr);
22023         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
22024         FREE((void*)this_ptr);
22025         MonitorEvent_free(this_ptr_conv);
22026 }
22027
22028 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
22029         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22030         *ret_copy = MonitorEvent_clone(arg);
22031 uint32_t ret_ref = (uintptr_t)ret_copy;
22032         return ret_ref;
22033 }
22034 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
22035         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
22036         uint32_t ret_val = MonitorEvent_clone_ptr(arg_conv);
22037         return ret_val;
22038 }
22039
22040 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
22041         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
22042         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22043         *ret_copy = MonitorEvent_clone(orig_conv);
22044         uint32_t ret_ref = (uintptr_t)ret_copy;
22045         return ret_ref;
22046 }
22047
22048 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
22049         LDKHTLCUpdate a_conv;
22050         a_conv.inner = (void*)(a & (~1));
22051         a_conv.is_owned = (a & 1) || (a == 0);
22052         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22053         a_conv = HTLCUpdate_clone(&a_conv);
22054         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22055         *ret_copy = MonitorEvent_htlcevent(a_conv);
22056         uint32_t ret_ref = (uintptr_t)ret_copy;
22057         return ret_ref;
22058 }
22059
22060 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
22061         LDKOutPoint a_conv;
22062         a_conv.inner = (void*)(a & (~1));
22063         a_conv.is_owned = (a & 1) || (a == 0);
22064         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22065         a_conv = OutPoint_clone(&a_conv);
22066         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22067         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
22068         uint32_t ret_ref = (uintptr_t)ret_copy;
22069         return ret_ref;
22070 }
22071
22072 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
22073         LDKOutPoint funding_txo_conv;
22074         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22075         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22076         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22077         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22078         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22079         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
22080         uint32_t ret_ref = (uintptr_t)ret_copy;
22081         return ret_ref;
22082 }
22083
22084 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
22085         LDKOutPoint a_conv;
22086         a_conv.inner = (void*)(a & (~1));
22087         a_conv.is_owned = (a & 1) || (a == 0);
22088         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22089         a_conv = OutPoint_clone(&a_conv);
22090         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22091         *ret_copy = MonitorEvent_update_failed(a_conv);
22092         uint32_t ret_ref = (uintptr_t)ret_copy;
22093         return ret_ref;
22094 }
22095
22096 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
22097         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
22098         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
22099         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22100         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22101         CVec_u8Z_free(ret_var);
22102         return ret_arr;
22103 }
22104
22105 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
22106         LDKu8slice ser_ref;
22107         ser_ref.datalen = ser->arr_len;
22108         ser_ref.data = ser->elems /* XXX ser leaks */;
22109         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22110         *ret_conv = MonitorEvent_read(ser_ref);
22111         return (uint32_t)ret_conv;
22112 }
22113
22114 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
22115         LDKHTLCUpdate this_obj_conv;
22116         this_obj_conv.inner = (void*)(this_obj & (~1));
22117         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22119         HTLCUpdate_free(this_obj_conv);
22120 }
22121
22122 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
22123         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
22124 uint32_t ret_ref = 0;
22125 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22126 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22127 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22128 ret_ref = (uintptr_t)ret_var.inner;
22129 if (ret_var.is_owned) {
22130         ret_ref |= 1;
22131 }
22132         return ret_ref;
22133 }
22134 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
22135         LDKHTLCUpdate arg_conv;
22136         arg_conv.inner = (void*)(arg & (~1));
22137         arg_conv.is_owned = false;
22138         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22139         uint32_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
22140         return ret_val;
22141 }
22142
22143 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
22144         LDKHTLCUpdate orig_conv;
22145         orig_conv.inner = (void*)(orig & (~1));
22146         orig_conv.is_owned = false;
22147         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22148         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
22149         uint32_t ret_ref = 0;
22150         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22151         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22153         ret_ref = (uintptr_t)ret_var.inner;
22154         if (ret_var.is_owned) {
22155                 ret_ref |= 1;
22156         }
22157         return ret_ref;
22158 }
22159
22160 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
22161         LDKHTLCUpdate obj_conv;
22162         obj_conv.inner = (void*)(obj & (~1));
22163         obj_conv.is_owned = false;
22164         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22165         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
22166         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22167         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22168         CVec_u8Z_free(ret_var);
22169         return ret_arr;
22170 }
22171
22172 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
22173         LDKu8slice ser_ref;
22174         ser_ref.datalen = ser->arr_len;
22175         ser_ref.data = ser->elems /* XXX ser leaks */;
22176         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22177         *ret_conv = HTLCUpdate_read(ser_ref);
22178         return (uint32_t)ret_conv;
22179 }
22180
22181 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
22182         if ((this_ptr & 1) != 0) return;
22183         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22184         CHECK_ACCESS(this_ptr_ptr);
22185         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
22186         FREE((void*)this_ptr);
22187         Balance_free(this_ptr_conv);
22188 }
22189
22190 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
22191         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22192         *ret_copy = Balance_clone(arg);
22193 uint32_t ret_ref = (uintptr_t)ret_copy;
22194         return ret_ref;
22195 }
22196 uint32_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
22197         LDKBalance* arg_conv = (LDKBalance*)arg;
22198         uint32_t ret_val = Balance_clone_ptr(arg_conv);
22199         return ret_val;
22200 }
22201
22202 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
22203         LDKBalance* orig_conv = (LDKBalance*)orig;
22204         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22205         *ret_copy = Balance_clone(orig_conv);
22206         uint32_t ret_ref = (uintptr_t)ret_copy;
22207         return ret_ref;
22208 }
22209
22210 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
22211         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22212         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
22213         uint32_t ret_ref = (uintptr_t)ret_copy;
22214         return ret_ref;
22215 }
22216
22217 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
22218         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22219         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
22220         uint32_t ret_ref = (uintptr_t)ret_copy;
22221         return ret_ref;
22222 }
22223
22224 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
22225         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22226         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
22227         uint32_t ret_ref = (uintptr_t)ret_copy;
22228         return ret_ref;
22229 }
22230
22231 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) {
22232         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22233         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
22234         uint32_t ret_ref = (uintptr_t)ret_copy;
22235         return ret_ref;
22236 }
22237
22238 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
22239         LDKBalance* a_conv = (LDKBalance*)a;
22240         LDKBalance* b_conv = (LDKBalance*)b;
22241         jboolean ret_val = Balance_eq(a_conv, b_conv);
22242         return ret_val;
22243 }
22244
22245 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
22246         LDKChannelMonitor this_obj_conv;
22247         this_obj_conv.inner = (void*)(this_obj & (~1));
22248         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22250         ChannelMonitor_free(this_obj_conv);
22251 }
22252
22253 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
22254         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
22255 uint32_t ret_ref = 0;
22256 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22257 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22258 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22259 ret_ref = (uintptr_t)ret_var.inner;
22260 if (ret_var.is_owned) {
22261         ret_ref |= 1;
22262 }
22263         return ret_ref;
22264 }
22265 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
22266         LDKChannelMonitor arg_conv;
22267         arg_conv.inner = (void*)(arg & (~1));
22268         arg_conv.is_owned = false;
22269         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22270         uint32_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
22271         return ret_val;
22272 }
22273
22274 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
22275         LDKChannelMonitor orig_conv;
22276         orig_conv.inner = (void*)(orig & (~1));
22277         orig_conv.is_owned = false;
22278         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22279         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
22280         uint32_t ret_ref = 0;
22281         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22282         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22284         ret_ref = (uintptr_t)ret_var.inner;
22285         if (ret_var.is_owned) {
22286                 ret_ref |= 1;
22287         }
22288         return ret_ref;
22289 }
22290
22291 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
22292         LDKChannelMonitor obj_conv;
22293         obj_conv.inner = (void*)(obj & (~1));
22294         obj_conv.is_owned = false;
22295         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22296         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
22297         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22298         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22299         CVec_u8Z_free(ret_var);
22300         return ret_arr;
22301 }
22302
22303 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) {
22304         LDKChannelMonitor this_arg_conv;
22305         this_arg_conv.inner = (void*)(this_arg & (~1));
22306         this_arg_conv.is_owned = false;
22307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22308         LDKChannelMonitorUpdate updates_conv;
22309         updates_conv.inner = (void*)(updates & (~1));
22310         updates_conv.is_owned = false;
22311         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
22312         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22313         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
22314         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
22315         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22316         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
22317         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
22318         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22319         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22320         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22321         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
22322         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
22323         return (uint32_t)ret_conv;
22324 }
22325
22326 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
22327         LDKChannelMonitor this_arg_conv;
22328         this_arg_conv.inner = (void*)(this_arg & (~1));
22329         this_arg_conv.is_owned = false;
22330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22331         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
22332         return ret_val;
22333 }
22334
22335 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
22336         LDKChannelMonitor this_arg_conv;
22337         this_arg_conv.inner = (void*)(this_arg & (~1));
22338         this_arg_conv.is_owned = false;
22339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22340         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22341         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
22342         return ((uint32_t)ret_conv);
22343 }
22344
22345 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
22346         LDKChannelMonitor this_arg_conv;
22347         this_arg_conv.inner = (void*)(this_arg & (~1));
22348         this_arg_conv.is_owned = false;
22349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22350         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
22351         uint32_tArray ret_arr = NULL;
22352         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22353         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22354         for (size_t o = 0; o < ret_var.datalen; o++) {
22355                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22356                 *ret_conv_40_conv = ret_var.data[o];
22357                 ret_arr_ptr[o] = ((uint32_t)ret_conv_40_conv);
22358         }
22359         
22360         FREE(ret_var.data);
22361         return ret_arr;
22362 }
22363
22364 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
22365         LDKChannelMonitor this_arg_conv;
22366         this_arg_conv.inner = (void*)(this_arg & (~1));
22367         this_arg_conv.is_owned = false;
22368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22369         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
22370         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
22371         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
22372         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
22373 }
22374
22375 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) {
22376         LDKChannelMonitor this_arg_conv;
22377         this_arg_conv.inner = (void*)(this_arg & (~1));
22378         this_arg_conv.is_owned = false;
22379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22380         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
22381         uint32_tArray ret_arr = NULL;
22382         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22383         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22384         for (size_t o = 0; o < ret_var.datalen; o++) {
22385                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22386                 *ret_conv_14_copy = ret_var.data[o];
22387                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
22388                 ret_arr_ptr[o] = ret_conv_14_ref;
22389         }
22390         
22391         FREE(ret_var.data);
22392         return ret_arr;
22393 }
22394
22395 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
22396         LDKChannelMonitor this_arg_conv;
22397         this_arg_conv.inner = (void*)(this_arg & (~1));
22398         this_arg_conv.is_owned = false;
22399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22400         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
22401         uint32_tArray ret_arr = NULL;
22402         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22403         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22404         for (size_t h = 0; h < ret_var.datalen; h++) {
22405                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22406                 *ret_conv_7_copy = ret_var.data[h];
22407                 uint32_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
22408                 ret_arr_ptr[h] = ret_conv_7_ref;
22409         }
22410         
22411         FREE(ret_var.data);
22412         return ret_arr;
22413 }
22414
22415 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) {
22416         LDKChannelMonitor this_arg_conv;
22417         this_arg_conv.inner = (void*)(this_arg & (~1));
22418         this_arg_conv.is_owned = false;
22419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22420         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22421         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22422         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22423         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
22424         ptrArray ret_arr = NULL;
22425         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22426         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22427         for (size_t m = 0; m < ret_var.datalen; m++) {
22428                 LDKTransaction ret_conv_12_var = ret_var.data[m];
22429                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
22430                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
22431                 Transaction_free(ret_conv_12_var);
22432                 ret_arr_ptr[m] = ret_conv_12_arr;
22433         }
22434         
22435         FREE(ret_var.data);
22436         return ret_arr;
22437 }
22438
22439 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) {
22440         LDKChannelMonitor this_arg_conv;
22441         this_arg_conv.inner = (void*)(this_arg & (~1));
22442         this_arg_conv.is_owned = false;
22443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22444         unsigned char header_arr[80];
22445         CHECK(header->arr_len == 80);
22446         memcpy(header_arr, header->elems, 80); FREE(header);
22447         unsigned char (*header_ref)[80] = &header_arr;
22448         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22449         txdata_constr.datalen = txdata->arr_len;
22450         if (txdata_constr.datalen > 0)
22451                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22452         else
22453                 txdata_constr.data = NULL;
22454         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22455         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22456                 uint32_t txdata_conv_28 = txdata_vals[c];
22457                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22458                 CHECK_ACCESS(txdata_conv_28_ptr);
22459                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22460                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22461                 txdata_constr.data[c] = txdata_conv_28_conv;
22462         }
22463         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22464         CHECK_ACCESS(broadcaster_ptr);
22465         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22466         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22467                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22468                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22469         }
22470         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22471         CHECK_ACCESS(fee_estimator_ptr);
22472         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22473         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22474                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22475                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22476         }
22477         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22478         CHECK_ACCESS(logger_ptr);
22479         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22480         if (logger_conv.free == LDKLogger_JCalls_free) {
22481                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22482                 LDKLogger_JCalls_cloned(&logger_conv);
22483         }
22484         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);
22485         uint32_tArray ret_arr = NULL;
22486         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22487         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22488         for (size_t n = 0; n < ret_var.datalen; n++) {
22489                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22490                 *ret_conv_39_conv = ret_var.data[n];
22491                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22492         }
22493         
22494         FREE(ret_var.data);
22495         return ret_arr;
22496 }
22497
22498 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) {
22499         LDKChannelMonitor this_arg_conv;
22500         this_arg_conv.inner = (void*)(this_arg & (~1));
22501         this_arg_conv.is_owned = false;
22502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22503         unsigned char header_arr[80];
22504         CHECK(header->arr_len == 80);
22505         memcpy(header_arr, header->elems, 80); FREE(header);
22506         unsigned char (*header_ref)[80] = &header_arr;
22507         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22508         CHECK_ACCESS(broadcaster_ptr);
22509         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22510         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22511                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22512                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22513         }
22514         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22515         CHECK_ACCESS(fee_estimator_ptr);
22516         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22517         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22518                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22519                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22520         }
22521         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22522         CHECK_ACCESS(logger_ptr);
22523         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22524         if (logger_conv.free == LDKLogger_JCalls_free) {
22525                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22526                 LDKLogger_JCalls_cloned(&logger_conv);
22527         }
22528         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22529 }
22530
22531 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) {
22532         LDKChannelMonitor this_arg_conv;
22533         this_arg_conv.inner = (void*)(this_arg & (~1));
22534         this_arg_conv.is_owned = false;
22535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22536         unsigned char header_arr[80];
22537         CHECK(header->arr_len == 80);
22538         memcpy(header_arr, header->elems, 80); FREE(header);
22539         unsigned char (*header_ref)[80] = &header_arr;
22540         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22541         txdata_constr.datalen = txdata->arr_len;
22542         if (txdata_constr.datalen > 0)
22543                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22544         else
22545                 txdata_constr.data = NULL;
22546         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22547         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22548                 uint32_t txdata_conv_28 = txdata_vals[c];
22549                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22550                 CHECK_ACCESS(txdata_conv_28_ptr);
22551                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22552                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22553                 txdata_constr.data[c] = txdata_conv_28_conv;
22554         }
22555         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22556         CHECK_ACCESS(broadcaster_ptr);
22557         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22558         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22559                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22560                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22561         }
22562         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22563         CHECK_ACCESS(fee_estimator_ptr);
22564         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22565         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22566                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22567                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22568         }
22569         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22570         CHECK_ACCESS(logger_ptr);
22571         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22572         if (logger_conv.free == LDKLogger_JCalls_free) {
22573                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22574                 LDKLogger_JCalls_cloned(&logger_conv);
22575         }
22576         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);
22577         uint32_tArray ret_arr = NULL;
22578         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22579         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22580         for (size_t n = 0; n < ret_var.datalen; n++) {
22581                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22582                 *ret_conv_39_conv = ret_var.data[n];
22583                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22584         }
22585         
22586         FREE(ret_var.data);
22587         return ret_arr;
22588 }
22589
22590 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) {
22591         LDKChannelMonitor this_arg_conv;
22592         this_arg_conv.inner = (void*)(this_arg & (~1));
22593         this_arg_conv.is_owned = false;
22594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22595         unsigned char txid_arr[32];
22596         CHECK(txid->arr_len == 32);
22597         memcpy(txid_arr, txid->elems, 32); FREE(txid);
22598         unsigned char (*txid_ref)[32] = &txid_arr;
22599         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22600         CHECK_ACCESS(broadcaster_ptr);
22601         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22602         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22603                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22604                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22605         }
22606         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22607         CHECK_ACCESS(fee_estimator_ptr);
22608         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22609         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22610                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22611                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22612         }
22613         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22614         CHECK_ACCESS(logger_ptr);
22615         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22616         if (logger_conv.free == LDKLogger_JCalls_free) {
22617                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22618                 LDKLogger_JCalls_cloned(&logger_conv);
22619         }
22620         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
22621 }
22622
22623 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) {
22624         LDKChannelMonitor this_arg_conv;
22625         this_arg_conv.inner = (void*)(this_arg & (~1));
22626         this_arg_conv.is_owned = false;
22627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22628         unsigned char header_arr[80];
22629         CHECK(header->arr_len == 80);
22630         memcpy(header_arr, header->elems, 80); FREE(header);
22631         unsigned char (*header_ref)[80] = &header_arr;
22632         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22633         CHECK_ACCESS(broadcaster_ptr);
22634         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22635         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22636                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22637                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22638         }
22639         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22640         CHECK_ACCESS(fee_estimator_ptr);
22641         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22642         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22643                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22644                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22645         }
22646         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22647         CHECK_ACCESS(logger_ptr);
22648         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22649         if (logger_conv.free == LDKLogger_JCalls_free) {
22650                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22651                 LDKLogger_JCalls_cloned(&logger_conv);
22652         }
22653         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22654         uint32_tArray ret_arr = NULL;
22655         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22656         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22657         for (size_t n = 0; n < ret_var.datalen; n++) {
22658                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22659                 *ret_conv_39_conv = ret_var.data[n];
22660                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22661         }
22662         
22663         FREE(ret_var.data);
22664         return ret_arr;
22665 }
22666
22667 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
22668         LDKChannelMonitor this_arg_conv;
22669         this_arg_conv.inner = (void*)(this_arg & (~1));
22670         this_arg_conv.is_owned = false;
22671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22672         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
22673         ptrArray ret_arr = NULL;
22674         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22675         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22676         for (size_t m = 0; m < ret_var.datalen; m++) {
22677                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
22678                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
22679                 ret_arr_ptr[m] = ret_conv_12_arr;
22680         }
22681         
22682         FREE(ret_var.data);
22683         return ret_arr;
22684 }
22685
22686 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
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         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
22692         uint32_t ret_ref = 0;
22693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22696         ret_ref = (uintptr_t)ret_var.inner;
22697         if (ret_var.is_owned) {
22698                 ret_ref |= 1;
22699         }
22700         return ret_ref;
22701 }
22702
22703 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
22704         LDKChannelMonitor this_arg_conv;
22705         this_arg_conv.inner = (void*)(this_arg & (~1));
22706         this_arg_conv.is_owned = false;
22707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22708         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
22709         uint32_tArray ret_arr = NULL;
22710         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22711         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22712         for (size_t j = 0; j < ret_var.datalen; j++) {
22713                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22714                 *ret_conv_9_copy = ret_var.data[j];
22715                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
22716                 ret_arr_ptr[j] = ret_conv_9_ref;
22717         }
22718         
22719         FREE(ret_var.data);
22720         return ret_arr;
22721 }
22722
22723 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
22724         LDKu8slice ser_ref;
22725         ser_ref.datalen = ser->arr_len;
22726         ser_ref.data = ser->elems /* XXX ser leaks */;
22727         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
22728         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
22729         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
22730         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22731         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
22732         return (uint32_t)ret_conv;
22733 }
22734
22735 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
22736         LDKOutPoint this_obj_conv;
22737         this_obj_conv.inner = (void*)(this_obj & (~1));
22738         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22740         OutPoint_free(this_obj_conv);
22741 }
22742
22743 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
22744         LDKOutPoint this_ptr_conv;
22745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22746         this_ptr_conv.is_owned = false;
22747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22748         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22749         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
22750         return ret_arr;
22751 }
22752
22753 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
22754         LDKOutPoint this_ptr_conv;
22755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22756         this_ptr_conv.is_owned = false;
22757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22758         LDKThirtyTwoBytes val_ref;
22759         CHECK(val->arr_len == 32);
22760         memcpy(val_ref.data, val->elems, 32); FREE(val);
22761         OutPoint_set_txid(&this_ptr_conv, val_ref);
22762 }
22763
22764 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
22765         LDKOutPoint this_ptr_conv;
22766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22767         this_ptr_conv.is_owned = false;
22768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22769         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
22770         return ret_val;
22771 }
22772
22773 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
22774         LDKOutPoint this_ptr_conv;
22775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22776         this_ptr_conv.is_owned = false;
22777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22778         OutPoint_set_index(&this_ptr_conv, val);
22779 }
22780
22781 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
22782         LDKThirtyTwoBytes txid_arg_ref;
22783         CHECK(txid_arg->arr_len == 32);
22784         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
22785         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
22786         uint32_t ret_ref = 0;
22787         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22788         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22790         ret_ref = (uintptr_t)ret_var.inner;
22791         if (ret_var.is_owned) {
22792                 ret_ref |= 1;
22793         }
22794         return ret_ref;
22795 }
22796
22797 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
22798         LDKOutPoint ret_var = OutPoint_clone(arg);
22799 uint32_t ret_ref = 0;
22800 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22801 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22802 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22803 ret_ref = (uintptr_t)ret_var.inner;
22804 if (ret_var.is_owned) {
22805         ret_ref |= 1;
22806 }
22807         return ret_ref;
22808 }
22809 uint32_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
22810         LDKOutPoint arg_conv;
22811         arg_conv.inner = (void*)(arg & (~1));
22812         arg_conv.is_owned = false;
22813         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22814         uint32_t ret_val = OutPoint_clone_ptr(&arg_conv);
22815         return ret_val;
22816 }
22817
22818 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
22819         LDKOutPoint orig_conv;
22820         orig_conv.inner = (void*)(orig & (~1));
22821         orig_conv.is_owned = false;
22822         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22823         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
22824         uint32_t ret_ref = 0;
22825         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22826         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22828         ret_ref = (uintptr_t)ret_var.inner;
22829         if (ret_var.is_owned) {
22830                 ret_ref |= 1;
22831         }
22832         return ret_ref;
22833 }
22834
22835 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
22836         LDKOutPoint a_conv;
22837         a_conv.inner = (void*)(a & (~1));
22838         a_conv.is_owned = false;
22839         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22840         LDKOutPoint b_conv;
22841         b_conv.inner = (void*)(b & (~1));
22842         b_conv.is_owned = false;
22843         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22844         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
22845         return ret_val;
22846 }
22847
22848 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
22849         LDKOutPoint o_conv;
22850         o_conv.inner = (void*)(o & (~1));
22851         o_conv.is_owned = false;
22852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22853         int64_t ret_val = OutPoint_hash(&o_conv);
22854         return ret_val;
22855 }
22856
22857 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
22858         LDKOutPoint this_arg_conv;
22859         this_arg_conv.inner = (void*)(this_arg & (~1));
22860         this_arg_conv.is_owned = false;
22861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22862         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22863         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
22864         return ret_arr;
22865 }
22866
22867 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
22868         LDKOutPoint obj_conv;
22869         obj_conv.inner = (void*)(obj & (~1));
22870         obj_conv.is_owned = false;
22871         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22872         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
22873         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22874         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22875         CVec_u8Z_free(ret_var);
22876         return ret_arr;
22877 }
22878
22879 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
22880         LDKu8slice ser_ref;
22881         ser_ref.datalen = ser->arr_len;
22882         ser_ref.data = ser->elems /* XXX ser leaks */;
22883         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22884         *ret_conv = OutPoint_read(ser_ref);
22885         return (uint32_t)ret_conv;
22886 }
22887
22888 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
22889         LDKDelayedPaymentOutputDescriptor this_obj_conv;
22890         this_obj_conv.inner = (void*)(this_obj & (~1));
22891         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22893         DelayedPaymentOutputDescriptor_free(this_obj_conv);
22894 }
22895
22896 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
22897         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22899         this_ptr_conv.is_owned = false;
22900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22901         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22902         uint32_t ret_ref = 0;
22903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22906         ret_ref = (uintptr_t)ret_var.inner;
22907         if (ret_var.is_owned) {
22908                 ret_ref |= 1;
22909         }
22910         return ret_ref;
22911 }
22912
22913 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
22914         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22916         this_ptr_conv.is_owned = false;
22917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22918         LDKOutPoint val_conv;
22919         val_conv.inner = (void*)(val & (~1));
22920         val_conv.is_owned = (val & 1) || (val == 0);
22921         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22922         val_conv = OutPoint_clone(&val_conv);
22923         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22924 }
22925
22926 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
22927         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22929         this_ptr_conv.is_owned = false;
22930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22931         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22932         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
22933         return ret_arr;
22934 }
22935
22936 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
22937         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22939         this_ptr_conv.is_owned = false;
22940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22941         LDKPublicKey val_ref;
22942         CHECK(val->arr_len == 33);
22943         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
22944         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
22945 }
22946
22947 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
22948         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22950         this_ptr_conv.is_owned = false;
22951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22952         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
22953         return ret_val;
22954 }
22955
22956 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
22957         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22959         this_ptr_conv.is_owned = false;
22960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22961         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
22962 }
22963
22964 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
22965         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22967         this_ptr_conv.is_owned = false;
22968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22969         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22970         CHECK_ACCESS(val_ptr);
22971         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
22972         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
22973         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
22974 }
22975
22976 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
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         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22982         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
22983         return ret_arr;
22984 }
22985
22986 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
22987         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22989         this_ptr_conv.is_owned = false;
22990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22991         LDKPublicKey val_ref;
22992         CHECK(val->arr_len == 33);
22993         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
22994         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
22995 }
22996
22997 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
22998         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23000         this_ptr_conv.is_owned = false;
23001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23002         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23003         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
23004         return ret_arr;
23005 }
23006
23007 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
23008         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23010         this_ptr_conv.is_owned = false;
23011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23012         LDKThirtyTwoBytes val_ref;
23013         CHECK(val->arr_len == 32);
23014         memcpy(val_ref.data, val->elems, 32); FREE(val);
23015         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
23016 }
23017
23018 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
23019         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23021         this_ptr_conv.is_owned = false;
23022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23023         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
23024         return ret_val;
23025 }
23026
23027 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_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         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
23033 }
23034
23035 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) {
23036         LDKOutPoint outpoint_arg_conv;
23037         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23038         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23039         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23040         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23041         LDKPublicKey per_commitment_point_arg_ref;
23042         CHECK(per_commitment_point_arg->arr_len == 33);
23043         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
23044         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
23045         CHECK_ACCESS(output_arg_ptr);
23046         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
23047         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
23048         LDKPublicKey revocation_pubkey_arg_ref;
23049         CHECK(revocation_pubkey_arg->arr_len == 33);
23050         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
23051         LDKThirtyTwoBytes channel_keys_id_arg_ref;
23052         CHECK(channel_keys_id_arg->arr_len == 32);
23053         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
23054         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);
23055         uint32_t ret_ref = 0;
23056         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23057         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23059         ret_ref = (uintptr_t)ret_var.inner;
23060         if (ret_var.is_owned) {
23061                 ret_ref |= 1;
23062         }
23063         return ret_ref;
23064 }
23065
23066 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
23067         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
23068 uint32_t ret_ref = 0;
23069 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23070 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23071 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23072 ret_ref = (uintptr_t)ret_var.inner;
23073 if (ret_var.is_owned) {
23074         ret_ref |= 1;
23075 }
23076         return ret_ref;
23077 }
23078 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
23079         LDKDelayedPaymentOutputDescriptor arg_conv;
23080         arg_conv.inner = (void*)(arg & (~1));
23081         arg_conv.is_owned = false;
23082         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23083         uint32_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
23084         return ret_val;
23085 }
23086
23087 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
23088         LDKDelayedPaymentOutputDescriptor orig_conv;
23089         orig_conv.inner = (void*)(orig & (~1));
23090         orig_conv.is_owned = false;
23091         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23092         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
23093         uint32_t ret_ref = 0;
23094         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23095         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23097         ret_ref = (uintptr_t)ret_var.inner;
23098         if (ret_var.is_owned) {
23099                 ret_ref |= 1;
23100         }
23101         return ret_ref;
23102 }
23103
23104 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
23105         LDKDelayedPaymentOutputDescriptor obj_conv;
23106         obj_conv.inner = (void*)(obj & (~1));
23107         obj_conv.is_owned = false;
23108         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23109         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
23110         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23111         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23112         CVec_u8Z_free(ret_var);
23113         return ret_arr;
23114 }
23115
23116 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
23117         LDKu8slice ser_ref;
23118         ser_ref.datalen = ser->arr_len;
23119         ser_ref.data = ser->elems /* XXX ser leaks */;
23120         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
23121         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
23122         return (uint32_t)ret_conv;
23123 }
23124
23125 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
23126         LDKStaticPaymentOutputDescriptor this_obj_conv;
23127         this_obj_conv.inner = (void*)(this_obj & (~1));
23128         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23130         StaticPaymentOutputDescriptor_free(this_obj_conv);
23131 }
23132
23133 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
23134         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23136         this_ptr_conv.is_owned = false;
23137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23138         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
23139         uint32_t ret_ref = 0;
23140         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23141         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23143         ret_ref = (uintptr_t)ret_var.inner;
23144         if (ret_var.is_owned) {
23145                 ret_ref |= 1;
23146         }
23147         return ret_ref;
23148 }
23149
23150 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
23151         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23153         this_ptr_conv.is_owned = false;
23154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23155         LDKOutPoint val_conv;
23156         val_conv.inner = (void*)(val & (~1));
23157         val_conv.is_owned = (val & 1) || (val == 0);
23158         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23159         val_conv = OutPoint_clone(&val_conv);
23160         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
23161 }
23162
23163 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
23164         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23166         this_ptr_conv.is_owned = false;
23167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23168         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
23169         CHECK_ACCESS(val_ptr);
23170         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
23171         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
23172         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
23173 }
23174
23175 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
23176         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23178         this_ptr_conv.is_owned = false;
23179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23180         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23181         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
23182         return ret_arr;
23183 }
23184
23185 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
23186         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23188         this_ptr_conv.is_owned = false;
23189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23190         LDKThirtyTwoBytes val_ref;
23191         CHECK(val->arr_len == 32);
23192         memcpy(val_ref.data, val->elems, 32); FREE(val);
23193         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
23194 }
23195
23196 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(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         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
23202         return ret_val;
23203 }
23204
23205 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
23206         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23208         this_ptr_conv.is_owned = false;
23209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23210         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
23211 }
23212
23213 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) {
23214         LDKOutPoint outpoint_arg_conv;
23215         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23216         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23217         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23218         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23219         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
23220         CHECK_ACCESS(output_arg_ptr);
23221         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
23222         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
23223         LDKThirtyTwoBytes channel_keys_id_arg_ref;
23224         CHECK(channel_keys_id_arg->arr_len == 32);
23225         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
23226         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
23227         uint32_t ret_ref = 0;
23228         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23229         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23231         ret_ref = (uintptr_t)ret_var.inner;
23232         if (ret_var.is_owned) {
23233                 ret_ref |= 1;
23234         }
23235         return ret_ref;
23236 }
23237
23238 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
23239         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
23240 uint32_t ret_ref = 0;
23241 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23242 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23243 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23244 ret_ref = (uintptr_t)ret_var.inner;
23245 if (ret_var.is_owned) {
23246         ret_ref |= 1;
23247 }
23248         return ret_ref;
23249 }
23250 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
23251         LDKStaticPaymentOutputDescriptor arg_conv;
23252         arg_conv.inner = (void*)(arg & (~1));
23253         arg_conv.is_owned = false;
23254         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23255         uint32_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
23256         return ret_val;
23257 }
23258
23259 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
23260         LDKStaticPaymentOutputDescriptor orig_conv;
23261         orig_conv.inner = (void*)(orig & (~1));
23262         orig_conv.is_owned = false;
23263         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23264         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
23265         uint32_t ret_ref = 0;
23266         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23267         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23269         ret_ref = (uintptr_t)ret_var.inner;
23270         if (ret_var.is_owned) {
23271                 ret_ref |= 1;
23272         }
23273         return ret_ref;
23274 }
23275
23276 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
23277         LDKStaticPaymentOutputDescriptor obj_conv;
23278         obj_conv.inner = (void*)(obj & (~1));
23279         obj_conv.is_owned = false;
23280         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23281         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
23282         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23283         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23284         CVec_u8Z_free(ret_var);
23285         return ret_arr;
23286 }
23287
23288 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
23289         LDKu8slice ser_ref;
23290         ser_ref.datalen = ser->arr_len;
23291         ser_ref.data = ser->elems /* XXX ser leaks */;
23292         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
23293         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
23294         return (uint32_t)ret_conv;
23295 }
23296
23297 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
23298         if ((this_ptr & 1) != 0) return;
23299         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23300         CHECK_ACCESS(this_ptr_ptr);
23301         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
23302         FREE((void*)this_ptr);
23303         SpendableOutputDescriptor_free(this_ptr_conv);
23304 }
23305
23306 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
23307         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23308         *ret_copy = SpendableOutputDescriptor_clone(arg);
23309 uint32_t ret_ref = (uintptr_t)ret_copy;
23310         return ret_ref;
23311 }
23312 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
23313         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
23314         uint32_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
23315         return ret_val;
23316 }
23317
23318 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
23319         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
23320         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23321         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
23322         uint32_t ret_ref = (uintptr_t)ret_copy;
23323         return ret_ref;
23324 }
23325
23326 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
23327         LDKOutPoint outpoint_conv;
23328         outpoint_conv.inner = (void*)(outpoint & (~1));
23329         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
23330         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
23331         outpoint_conv = OutPoint_clone(&outpoint_conv);
23332         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
23333         CHECK_ACCESS(output_ptr);
23334         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
23335         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
23336         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23337         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
23338         uint32_t ret_ref = (uintptr_t)ret_copy;
23339         return ret_ref;
23340 }
23341
23342 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
23343         LDKDelayedPaymentOutputDescriptor a_conv;
23344         a_conv.inner = (void*)(a & (~1));
23345         a_conv.is_owned = (a & 1) || (a == 0);
23346         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23347         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
23348         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23349         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
23350         uint32_t ret_ref = (uintptr_t)ret_copy;
23351         return ret_ref;
23352 }
23353
23354 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
23355         LDKStaticPaymentOutputDescriptor a_conv;
23356         a_conv.inner = (void*)(a & (~1));
23357         a_conv.is_owned = (a & 1) || (a == 0);
23358         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23359         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
23360         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23361         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
23362         uint32_t ret_ref = (uintptr_t)ret_copy;
23363         return ret_ref;
23364 }
23365
23366 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
23367         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
23368         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
23369         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23370         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23371         CVec_u8Z_free(ret_var);
23372         return ret_arr;
23373 }
23374
23375 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
23376         LDKu8slice ser_ref;
23377         ser_ref.datalen = ser->arr_len;
23378         ser_ref.data = ser->elems /* XXX ser leaks */;
23379         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
23380         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
23381         return (uint32_t)ret_conv;
23382 }
23383
23384 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
23385         if ((this_ptr & 1) != 0) return;
23386         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23387         CHECK_ACCESS(this_ptr_ptr);
23388         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
23389         FREE((void*)this_ptr);
23390         BaseSign_free(this_ptr_conv);
23391 }
23392
23393 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
23394         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23395         *ret_ret = Sign_clone(arg);
23396         return (uint32_t)ret_ret;
23397 }
23398 uint32_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
23399         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
23400         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23401         LDKSign* arg_conv = (LDKSign*)arg_ptr;
23402         uint32_t ret_val = Sign_clone_ptr(arg_conv);
23403         return ret_val;
23404 }
23405
23406 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
23407         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
23408         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
23409         LDKSign* orig_conv = (LDKSign*)orig_ptr;
23410         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23411         *ret_ret = Sign_clone(orig_conv);
23412         return (uint32_t)ret_ret;
23413 }
23414
23415 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
23416         if ((this_ptr & 1) != 0) return;
23417         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23418         CHECK_ACCESS(this_ptr_ptr);
23419         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
23420         FREE((void*)this_ptr);
23421         Sign_free(this_ptr_conv);
23422 }
23423
23424 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint32_t orig) {
23425         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
23426         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
23427         return ret_conv;
23428 }
23429
23430 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
23431         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
23432         return ret_conv;
23433 }
23434
23435 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
23436         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
23437         return ret_conv;
23438 }
23439
23440 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
23441         if ((this_ptr & 1) != 0) return;
23442         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23443         CHECK_ACCESS(this_ptr_ptr);
23444         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
23445         FREE((void*)this_ptr);
23446         KeysInterface_free(this_ptr_conv);
23447 }
23448
23449 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
23450         LDKInMemorySigner this_obj_conv;
23451         this_obj_conv.inner = (void*)(this_obj & (~1));
23452         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23454         InMemorySigner_free(this_obj_conv);
23455 }
23456
23457 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
23458         LDKInMemorySigner this_ptr_conv;
23459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23460         this_ptr_conv.is_owned = false;
23461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23462         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23463         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
23464         return ret_arr;
23465 }
23466
23467 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
23468         LDKInMemorySigner this_ptr_conv;
23469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23470         this_ptr_conv.is_owned = false;
23471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23472         LDKSecretKey val_ref;
23473         CHECK(val->arr_len == 32);
23474         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23475         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
23476 }
23477
23478 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
23479         LDKInMemorySigner this_ptr_conv;
23480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23481         this_ptr_conv.is_owned = false;
23482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23483         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23484         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
23485         return ret_arr;
23486 }
23487
23488 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
23489         LDKInMemorySigner this_ptr_conv;
23490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23491         this_ptr_conv.is_owned = false;
23492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23493         LDKSecretKey val_ref;
23494         CHECK(val->arr_len == 32);
23495         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23496         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
23497 }
23498
23499 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
23500         LDKInMemorySigner this_ptr_conv;
23501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23502         this_ptr_conv.is_owned = false;
23503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23504         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23505         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
23506         return ret_arr;
23507 }
23508
23509 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
23510         LDKInMemorySigner this_ptr_conv;
23511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23512         this_ptr_conv.is_owned = false;
23513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23514         LDKSecretKey val_ref;
23515         CHECK(val->arr_len == 32);
23516         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23517         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
23518 }
23519
23520 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_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_delayed_payment_base_key(&this_ptr_conv), 32);
23527         return ret_arr;
23528 }
23529
23530 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) {
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_delayed_payment_base_key(&this_ptr_conv, val_ref);
23539 }
23540
23541 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_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_htlc_base_key(&this_ptr_conv), 32);
23548         return ret_arr;
23549 }
23550
23551 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_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_htlc_base_key(&this_ptr_conv, val_ref);
23560 }
23561
23562 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(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_commitment_seed(&this_ptr_conv), 32);
23569         return ret_arr;
23570 }
23571
23572 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(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         LDKThirtyTwoBytes val_ref;
23578         CHECK(val->arr_len == 32);
23579         memcpy(val_ref.data, val->elems, 32); FREE(val);
23580         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
23581 }
23582
23583 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
23584         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
23585 uint32_t ret_ref = 0;
23586 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23587 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23588 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23589 ret_ref = (uintptr_t)ret_var.inner;
23590 if (ret_var.is_owned) {
23591         ret_ref |= 1;
23592 }
23593         return ret_ref;
23594 }
23595 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
23596         LDKInMemorySigner arg_conv;
23597         arg_conv.inner = (void*)(arg & (~1));
23598         arg_conv.is_owned = false;
23599         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23600         uint32_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
23601         return ret_val;
23602 }
23603
23604 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
23605         LDKInMemorySigner orig_conv;
23606         orig_conv.inner = (void*)(orig & (~1));
23607         orig_conv.is_owned = false;
23608         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23609         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
23610         uint32_t ret_ref = 0;
23611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23614         ret_ref = (uintptr_t)ret_var.inner;
23615         if (ret_var.is_owned) {
23616                 ret_ref |= 1;
23617         }
23618         return ret_ref;
23619 }
23620
23621 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) {
23622         LDKSecretKey node_secret_ref;
23623         CHECK(node_secret->arr_len == 32);
23624         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
23625         LDKSecretKey funding_key_ref;
23626         CHECK(funding_key->arr_len == 32);
23627         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
23628         LDKSecretKey revocation_base_key_ref;
23629         CHECK(revocation_base_key->arr_len == 32);
23630         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
23631         LDKSecretKey payment_key_ref;
23632         CHECK(payment_key->arr_len == 32);
23633         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
23634         LDKSecretKey delayed_payment_base_key_ref;
23635         CHECK(delayed_payment_base_key->arr_len == 32);
23636         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
23637         LDKSecretKey htlc_base_key_ref;
23638         CHECK(htlc_base_key->arr_len == 32);
23639         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
23640         LDKThirtyTwoBytes commitment_seed_ref;
23641         CHECK(commitment_seed->arr_len == 32);
23642         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
23643         LDKThirtyTwoBytes channel_keys_id_ref;
23644         CHECK(channel_keys_id->arr_len == 32);
23645         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
23646         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);
23647         uint32_t ret_ref = 0;
23648         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23649         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23651         ret_ref = (uintptr_t)ret_var.inner;
23652         if (ret_var.is_owned) {
23653                 ret_ref |= 1;
23654         }
23655         return ret_ref;
23656 }
23657
23658 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
23659         LDKInMemorySigner this_arg_conv;
23660         this_arg_conv.inner = (void*)(this_arg & (~1));
23661         this_arg_conv.is_owned = false;
23662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23663         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
23664         uint32_t ret_ref = 0;
23665         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23666         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23668         ret_ref = (uintptr_t)ret_var.inner;
23669         if (ret_var.is_owned) {
23670                 ret_ref |= 1;
23671         }
23672         return ret_ref;
23673 }
23674
23675 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
23676         LDKInMemorySigner this_arg_conv;
23677         this_arg_conv.inner = (void*)(this_arg & (~1));
23678         this_arg_conv.is_owned = false;
23679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23680         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
23681         return ret_val;
23682 }
23683
23684 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
23685         LDKInMemorySigner this_arg_conv;
23686         this_arg_conv.inner = (void*)(this_arg & (~1));
23687         this_arg_conv.is_owned = false;
23688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23689         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
23690         return ret_val;
23691 }
23692
23693 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
23694         LDKInMemorySigner this_arg_conv;
23695         this_arg_conv.inner = (void*)(this_arg & (~1));
23696         this_arg_conv.is_owned = false;
23697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23698         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
23699         return ret_val;
23700 }
23701
23702 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
23703         LDKInMemorySigner this_arg_conv;
23704         this_arg_conv.inner = (void*)(this_arg & (~1));
23705         this_arg_conv.is_owned = false;
23706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23707         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
23708         uint32_t ret_ref = 0;
23709         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23710         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23712         ret_ref = (uintptr_t)ret_var.inner;
23713         if (ret_var.is_owned) {
23714                 ret_ref |= 1;
23715         }
23716         return ret_ref;
23717 }
23718
23719 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
23720         LDKInMemorySigner this_arg_conv;
23721         this_arg_conv.inner = (void*)(this_arg & (~1));
23722         this_arg_conv.is_owned = false;
23723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23724         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
23725         uint32_t ret_ref = 0;
23726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23729         ret_ref = (uintptr_t)ret_var.inner;
23730         if (ret_var.is_owned) {
23731                 ret_ref |= 1;
23732         }
23733         return ret_ref;
23734 }
23735
23736 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
23737         LDKInMemorySigner this_arg_conv;
23738         this_arg_conv.inner = (void*)(this_arg & (~1));
23739         this_arg_conv.is_owned = false;
23740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23741         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
23742         return ret_val;
23743 }
23744
23745 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) {
23746         LDKInMemorySigner this_arg_conv;
23747         this_arg_conv.inner = (void*)(this_arg & (~1));
23748         this_arg_conv.is_owned = false;
23749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23750         LDKTransaction spend_tx_ref;
23751         spend_tx_ref.datalen = spend_tx->arr_len;
23752         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23753         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23754         spend_tx_ref.data_is_owned = true;
23755         LDKStaticPaymentOutputDescriptor descriptor_conv;
23756         descriptor_conv.inner = (void*)(descriptor & (~1));
23757         descriptor_conv.is_owned = false;
23758         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23759         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23760         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23761         return (uint32_t)ret_conv;
23762 }
23763
23764 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) {
23765         LDKInMemorySigner this_arg_conv;
23766         this_arg_conv.inner = (void*)(this_arg & (~1));
23767         this_arg_conv.is_owned = false;
23768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23769         LDKTransaction spend_tx_ref;
23770         spend_tx_ref.datalen = spend_tx->arr_len;
23771         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23772         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23773         spend_tx_ref.data_is_owned = true;
23774         LDKDelayedPaymentOutputDescriptor descriptor_conv;
23775         descriptor_conv.inner = (void*)(descriptor & (~1));
23776         descriptor_conv.is_owned = false;
23777         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23778         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23779         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23780         return (uint32_t)ret_conv;
23781 }
23782
23783 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
23784         LDKInMemorySigner this_arg_conv;
23785         this_arg_conv.inner = (void*)(this_arg & (~1));
23786         this_arg_conv.is_owned = false;
23787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23788         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
23789         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
23790         return (uint32_t)ret_ret;
23791 }
23792
23793 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
23794         LDKInMemorySigner this_arg_conv;
23795         this_arg_conv.inner = (void*)(this_arg & (~1));
23796         this_arg_conv.is_owned = false;
23797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23798         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23799         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
23800         return (uint32_t)ret_ret;
23801 }
23802
23803 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
23804         LDKInMemorySigner obj_conv;
23805         obj_conv.inner = (void*)(obj & (~1));
23806         obj_conv.is_owned = false;
23807         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23808         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
23809         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23810         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23811         CVec_u8Z_free(ret_var);
23812         return ret_arr;
23813 }
23814
23815 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
23816         LDKu8slice ser_ref;
23817         ser_ref.datalen = ser->arr_len;
23818         ser_ref.data = ser->elems /* XXX ser leaks */;
23819         LDKSecretKey arg_ref;
23820         CHECK(arg->arr_len == 32);
23821         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
23822         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
23823         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
23824         return (uint32_t)ret_conv;
23825 }
23826
23827 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
23828         LDKKeysManager this_obj_conv;
23829         this_obj_conv.inner = (void*)(this_obj & (~1));
23830         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23832         KeysManager_free(this_obj_conv);
23833 }
23834
23835 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
23836         unsigned char seed_arr[32];
23837         CHECK(seed->arr_len == 32);
23838         memcpy(seed_arr, seed->elems, 32); FREE(seed);
23839         unsigned char (*seed_ref)[32] = &seed_arr;
23840         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
23841         uint32_t ret_ref = 0;
23842         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23843         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23845         ret_ref = (uintptr_t)ret_var.inner;
23846         if (ret_var.is_owned) {
23847                 ret_ref |= 1;
23848         }
23849         return ret_ref;
23850 }
23851
23852 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) {
23853         LDKKeysManager this_arg_conv;
23854         this_arg_conv.inner = (void*)(this_arg & (~1));
23855         this_arg_conv.is_owned = false;
23856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23857         unsigned char params_arr[32];
23858         CHECK(params->arr_len == 32);
23859         memcpy(params_arr, params->elems, 32); FREE(params);
23860         unsigned char (*params_ref)[32] = &params_arr;
23861         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
23862         uint32_t ret_ref = 0;
23863         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23864         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23866         ret_ref = (uintptr_t)ret_var.inner;
23867         if (ret_var.is_owned) {
23868                 ret_ref |= 1;
23869         }
23870         return ret_ref;
23871 }
23872
23873 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) {
23874         LDKKeysManager this_arg_conv;
23875         this_arg_conv.inner = (void*)(this_arg & (~1));
23876         this_arg_conv.is_owned = false;
23877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23878         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23879         descriptors_constr.datalen = descriptors->arr_len;
23880         if (descriptors_constr.datalen > 0)
23881                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23882         else
23883                 descriptors_constr.data = NULL;
23884         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
23885         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23886                 uint32_t descriptors_conv_27 = descriptors_vals[b];
23887                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
23888                 CHECK_ACCESS(descriptors_conv_27_ptr);
23889                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23890                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
23891                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23892         }
23893         LDKCVec_TxOutZ outputs_constr;
23894         outputs_constr.datalen = outputs->arr_len;
23895         if (outputs_constr.datalen > 0)
23896                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23897         else
23898                 outputs_constr.data = NULL;
23899         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
23900         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23901                 uint32_t outputs_conv_7 = outputs_vals[h];
23902                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
23903                 CHECK_ACCESS(outputs_conv_7_ptr);
23904                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
23905                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
23906                 outputs_constr.data[h] = outputs_conv_7_conv;
23907         }
23908         LDKCVec_u8Z change_destination_script_ref;
23909         change_destination_script_ref.datalen = change_destination_script->arr_len;
23910         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
23911         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
23912         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
23913         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
23914         return (uint32_t)ret_conv;
23915 }
23916
23917 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
23918         LDKKeysManager this_arg_conv;
23919         this_arg_conv.inner = (void*)(this_arg & (~1));
23920         this_arg_conv.is_owned = false;
23921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23922         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23923         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
23924         return (uint32_t)ret_ret;
23925 }
23926
23927 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint32_t this_obj) {
23928         LDKPhantomKeysManager this_obj_conv;
23929         this_obj_conv.inner = (void*)(this_obj & (~1));
23930         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23932         PhantomKeysManager_free(this_obj_conv);
23933 }
23934
23935 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint32_t this_arg) {
23936         LDKPhantomKeysManager this_arg_conv;
23937         this_arg_conv.inner = (void*)(this_arg & (~1));
23938         this_arg_conv.is_owned = false;
23939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23940         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23941         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
23942         return (uint32_t)ret_ret;
23943 }
23944
23945 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) {
23946         unsigned char seed_arr[32];
23947         CHECK(seed->arr_len == 32);
23948         memcpy(seed_arr, seed->elems, 32); FREE(seed);
23949         unsigned char (*seed_ref)[32] = &seed_arr;
23950         unsigned char cross_node_seed_arr[32];
23951         CHECK(cross_node_seed->arr_len == 32);
23952         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
23953         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
23954         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
23955         uint32_t ret_ref = 0;
23956         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23957         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23959         ret_ref = (uintptr_t)ret_var.inner;
23960         if (ret_var.is_owned) {
23961                 ret_ref |= 1;
23962         }
23963         return ret_ref;
23964 }
23965
23966 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) {
23967         LDKPhantomKeysManager this_arg_conv;
23968         this_arg_conv.inner = (void*)(this_arg & (~1));
23969         this_arg_conv.is_owned = false;
23970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23971         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23972         descriptors_constr.datalen = descriptors->arr_len;
23973         if (descriptors_constr.datalen > 0)
23974                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23975         else
23976                 descriptors_constr.data = NULL;
23977         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
23978         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23979                 uint32_t descriptors_conv_27 = descriptors_vals[b];
23980                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
23981                 CHECK_ACCESS(descriptors_conv_27_ptr);
23982                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23983                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
23984                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23985         }
23986         LDKCVec_TxOutZ outputs_constr;
23987         outputs_constr.datalen = outputs->arr_len;
23988         if (outputs_constr.datalen > 0)
23989                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23990         else
23991                 outputs_constr.data = NULL;
23992         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
23993         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23994                 uint32_t outputs_conv_7 = outputs_vals[h];
23995                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
23996                 CHECK_ACCESS(outputs_conv_7_ptr);
23997                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
23998                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
23999                 outputs_constr.data[h] = outputs_conv_7_conv;
24000         }
24001         LDKCVec_u8Z change_destination_script_ref;
24002         change_destination_script_ref.datalen = change_destination_script->arr_len;
24003         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
24004         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
24005         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
24006         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
24007         return (uint32_t)ret_conv;
24008 }
24009
24010 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) {
24011         LDKPhantomKeysManager this_arg_conv;
24012         this_arg_conv.inner = (void*)(this_arg & (~1));
24013         this_arg_conv.is_owned = false;
24014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24015         unsigned char params_arr[32];
24016         CHECK(params->arr_len == 32);
24017         memcpy(params_arr, params->elems, 32); FREE(params);
24018         unsigned char (*params_ref)[32] = &params_arr;
24019         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
24020         uint32_t ret_ref = 0;
24021         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24022         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24024         ret_ref = (uintptr_t)ret_var.inner;
24025         if (ret_var.is_owned) {
24026                 ret_ref |= 1;
24027         }
24028         return ret_ref;
24029 }
24030
24031 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
24032         LDKChannelManager this_obj_conv;
24033         this_obj_conv.inner = (void*)(this_obj & (~1));
24034         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24036         ChannelManager_free(this_obj_conv);
24037 }
24038
24039 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
24040         LDKChainParameters this_obj_conv;
24041         this_obj_conv.inner = (void*)(this_obj & (~1));
24042         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24044         ChainParameters_free(this_obj_conv);
24045 }
24046
24047 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
24048         LDKChainParameters this_ptr_conv;
24049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24050         this_ptr_conv.is_owned = false;
24051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24052         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
24053         return ret_conv;
24054 }
24055
24056 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
24057         LDKChainParameters this_ptr_conv;
24058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24059         this_ptr_conv.is_owned = false;
24060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24061         LDKNetwork val_conv = LDKNetwork_from_js(val);
24062         ChainParameters_set_network(&this_ptr_conv, val_conv);
24063 }
24064
24065 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
24066         LDKChainParameters this_ptr_conv;
24067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24068         this_ptr_conv.is_owned = false;
24069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24070         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
24071         uint32_t ret_ref = 0;
24072         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24073         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24075         ret_ref = (uintptr_t)ret_var.inner;
24076         if (ret_var.is_owned) {
24077                 ret_ref |= 1;
24078         }
24079         return ret_ref;
24080 }
24081
24082 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
24083         LDKChainParameters this_ptr_conv;
24084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24085         this_ptr_conv.is_owned = false;
24086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24087         LDKBestBlock val_conv;
24088         val_conv.inner = (void*)(val & (~1));
24089         val_conv.is_owned = (val & 1) || (val == 0);
24090         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24091         val_conv = BestBlock_clone(&val_conv);
24092         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
24093 }
24094
24095 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
24096         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
24097         LDKBestBlock best_block_arg_conv;
24098         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
24099         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
24100         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
24101         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
24102         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
24103         uint32_t ret_ref = 0;
24104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24107         ret_ref = (uintptr_t)ret_var.inner;
24108         if (ret_var.is_owned) {
24109                 ret_ref |= 1;
24110         }
24111         return ret_ref;
24112 }
24113
24114 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
24115         LDKChainParameters ret_var = ChainParameters_clone(arg);
24116 uint32_t ret_ref = 0;
24117 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24118 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24119 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24120 ret_ref = (uintptr_t)ret_var.inner;
24121 if (ret_var.is_owned) {
24122         ret_ref |= 1;
24123 }
24124         return ret_ref;
24125 }
24126 uint32_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
24127         LDKChainParameters arg_conv;
24128         arg_conv.inner = (void*)(arg & (~1));
24129         arg_conv.is_owned = false;
24130         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24131         uint32_t ret_val = ChainParameters_clone_ptr(&arg_conv);
24132         return ret_val;
24133 }
24134
24135 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
24136         LDKChainParameters orig_conv;
24137         orig_conv.inner = (void*)(orig & (~1));
24138         orig_conv.is_owned = false;
24139         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24140         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
24141         uint32_t ret_ref = 0;
24142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24145         ret_ref = (uintptr_t)ret_var.inner;
24146         if (ret_var.is_owned) {
24147                 ret_ref |= 1;
24148         }
24149         return ret_ref;
24150 }
24151
24152 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
24153         LDKCounterpartyForwardingInfo this_obj_conv;
24154         this_obj_conv.inner = (void*)(this_obj & (~1));
24155         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24157         CounterpartyForwardingInfo_free(this_obj_conv);
24158 }
24159
24160 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
24161         LDKCounterpartyForwardingInfo this_ptr_conv;
24162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24163         this_ptr_conv.is_owned = false;
24164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24165         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
24166         return ret_val;
24167 }
24168
24169 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
24170         LDKCounterpartyForwardingInfo this_ptr_conv;
24171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24172         this_ptr_conv.is_owned = false;
24173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24174         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
24175 }
24176
24177 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
24178         LDKCounterpartyForwardingInfo this_ptr_conv;
24179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24180         this_ptr_conv.is_owned = false;
24181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24182         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
24183         return ret_val;
24184 }
24185
24186 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
24187         LDKCounterpartyForwardingInfo this_ptr_conv;
24188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24189         this_ptr_conv.is_owned = false;
24190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24191         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
24192 }
24193
24194 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
24195         LDKCounterpartyForwardingInfo this_ptr_conv;
24196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24197         this_ptr_conv.is_owned = false;
24198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24199         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
24200         return ret_val;
24201 }
24202
24203 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
24204         LDKCounterpartyForwardingInfo this_ptr_conv;
24205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24206         this_ptr_conv.is_owned = false;
24207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24208         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
24209 }
24210
24211 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) {
24212         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
24213         uint32_t ret_ref = 0;
24214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24217         ret_ref = (uintptr_t)ret_var.inner;
24218         if (ret_var.is_owned) {
24219                 ret_ref |= 1;
24220         }
24221         return ret_ref;
24222 }
24223
24224 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
24225         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
24226 uint32_t ret_ref = 0;
24227 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24228 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24229 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24230 ret_ref = (uintptr_t)ret_var.inner;
24231 if (ret_var.is_owned) {
24232         ret_ref |= 1;
24233 }
24234         return ret_ref;
24235 }
24236 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
24237         LDKCounterpartyForwardingInfo arg_conv;
24238         arg_conv.inner = (void*)(arg & (~1));
24239         arg_conv.is_owned = false;
24240         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24241         uint32_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
24242         return ret_val;
24243 }
24244
24245 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
24246         LDKCounterpartyForwardingInfo orig_conv;
24247         orig_conv.inner = (void*)(orig & (~1));
24248         orig_conv.is_owned = false;
24249         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24250         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
24251         uint32_t ret_ref = 0;
24252         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24253         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24255         ret_ref = (uintptr_t)ret_var.inner;
24256         if (ret_var.is_owned) {
24257                 ret_ref |= 1;
24258         }
24259         return ret_ref;
24260 }
24261
24262 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
24263         LDKChannelCounterparty this_obj_conv;
24264         this_obj_conv.inner = (void*)(this_obj & (~1));
24265         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24267         ChannelCounterparty_free(this_obj_conv);
24268 }
24269
24270 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
24271         LDKChannelCounterparty this_ptr_conv;
24272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24273         this_ptr_conv.is_owned = false;
24274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24275         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24276         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
24277         return ret_arr;
24278 }
24279
24280 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
24281         LDKChannelCounterparty this_ptr_conv;
24282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24283         this_ptr_conv.is_owned = false;
24284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24285         LDKPublicKey val_ref;
24286         CHECK(val->arr_len == 33);
24287         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24288         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
24289 }
24290
24291 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
24292         LDKChannelCounterparty this_ptr_conv;
24293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24294         this_ptr_conv.is_owned = false;
24295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24296         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
24297         uint32_t ret_ref = 0;
24298         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24299         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24301         ret_ref = (uintptr_t)ret_var.inner;
24302         if (ret_var.is_owned) {
24303                 ret_ref |= 1;
24304         }
24305         return ret_ref;
24306 }
24307
24308 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
24309         LDKChannelCounterparty this_ptr_conv;
24310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24311         this_ptr_conv.is_owned = false;
24312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24313         LDKInitFeatures val_conv;
24314         val_conv.inner = (void*)(val & (~1));
24315         val_conv.is_owned = (val & 1) || (val == 0);
24316         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24317         val_conv = InitFeatures_clone(&val_conv);
24318         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
24319 }
24320
24321 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
24322         LDKChannelCounterparty this_ptr_conv;
24323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24324         this_ptr_conv.is_owned = false;
24325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24326         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
24327         return ret_val;
24328 }
24329
24330 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
24331         LDKChannelCounterparty this_ptr_conv;
24332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24333         this_ptr_conv.is_owned = false;
24334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24335         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
24336 }
24337
24338 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
24339         LDKChannelCounterparty this_ptr_conv;
24340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24341         this_ptr_conv.is_owned = false;
24342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24343         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
24344         uint32_t ret_ref = 0;
24345         if ((uintptr_t)ret_var.inner > 4096) {
24346                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24347                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24349                 ret_ref = (uintptr_t)ret_var.inner;
24350                 if (ret_var.is_owned) {
24351                         ret_ref |= 1;
24352                 }
24353         }
24354         return ret_ref;
24355 }
24356
24357 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
24358         LDKChannelCounterparty this_ptr_conv;
24359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24360         this_ptr_conv.is_owned = false;
24361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24362         LDKCounterpartyForwardingInfo val_conv;
24363         val_conv.inner = (void*)(val & (~1));
24364         val_conv.is_owned = (val & 1) || (val == 0);
24365         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24366         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
24367         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
24368 }
24369
24370 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) {
24371         LDKPublicKey node_id_arg_ref;
24372         CHECK(node_id_arg->arr_len == 33);
24373         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
24374         LDKInitFeatures features_arg_conv;
24375         features_arg_conv.inner = (void*)(features_arg & (~1));
24376         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24377         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
24378         features_arg_conv = InitFeatures_clone(&features_arg_conv);
24379         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
24380         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
24381         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
24382         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
24383         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
24384         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
24385         uint32_t ret_ref = 0;
24386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24389         ret_ref = (uintptr_t)ret_var.inner;
24390         if (ret_var.is_owned) {
24391                 ret_ref |= 1;
24392         }
24393         return ret_ref;
24394 }
24395
24396 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
24397         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
24398 uint32_t ret_ref = 0;
24399 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24400 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24401 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24402 ret_ref = (uintptr_t)ret_var.inner;
24403 if (ret_var.is_owned) {
24404         ret_ref |= 1;
24405 }
24406         return ret_ref;
24407 }
24408 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
24409         LDKChannelCounterparty arg_conv;
24410         arg_conv.inner = (void*)(arg & (~1));
24411         arg_conv.is_owned = false;
24412         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24413         uint32_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
24414         return ret_val;
24415 }
24416
24417 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
24418         LDKChannelCounterparty orig_conv;
24419         orig_conv.inner = (void*)(orig & (~1));
24420         orig_conv.is_owned = false;
24421         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24422         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
24423         uint32_t ret_ref = 0;
24424         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24425         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24427         ret_ref = (uintptr_t)ret_var.inner;
24428         if (ret_var.is_owned) {
24429                 ret_ref |= 1;
24430         }
24431         return ret_ref;
24432 }
24433
24434 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
24435         LDKChannelDetails this_obj_conv;
24436         this_obj_conv.inner = (void*)(this_obj & (~1));
24437         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24439         ChannelDetails_free(this_obj_conv);
24440 }
24441
24442 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
24443         LDKChannelDetails this_ptr_conv;
24444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24445         this_ptr_conv.is_owned = false;
24446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24447         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24448         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
24449         return ret_arr;
24450 }
24451
24452 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24453         LDKChannelDetails this_ptr_conv;
24454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24455         this_ptr_conv.is_owned = false;
24456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24457         LDKThirtyTwoBytes val_ref;
24458         CHECK(val->arr_len == 32);
24459         memcpy(val_ref.data, val->elems, 32); FREE(val);
24460         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
24461 }
24462
24463 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
24464         LDKChannelDetails this_ptr_conv;
24465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24466         this_ptr_conv.is_owned = false;
24467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24468         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
24469         uint32_t ret_ref = 0;
24470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24473         ret_ref = (uintptr_t)ret_var.inner;
24474         if (ret_var.is_owned) {
24475                 ret_ref |= 1;
24476         }
24477         return ret_ref;
24478 }
24479
24480 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
24481         LDKChannelDetails this_ptr_conv;
24482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24483         this_ptr_conv.is_owned = false;
24484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24485         LDKChannelCounterparty val_conv;
24486         val_conv.inner = (void*)(val & (~1));
24487         val_conv.is_owned = (val & 1) || (val == 0);
24488         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24489         val_conv = ChannelCounterparty_clone(&val_conv);
24490         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
24491 }
24492
24493 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
24494         LDKChannelDetails this_ptr_conv;
24495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24496         this_ptr_conv.is_owned = false;
24497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24498         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
24499         uint32_t ret_ref = 0;
24500         if ((uintptr_t)ret_var.inner > 4096) {
24501                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24502                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24504                 ret_ref = (uintptr_t)ret_var.inner;
24505                 if (ret_var.is_owned) {
24506                         ret_ref |= 1;
24507                 }
24508         }
24509         return ret_ref;
24510 }
24511
24512 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
24513         LDKChannelDetails this_ptr_conv;
24514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24515         this_ptr_conv.is_owned = false;
24516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24517         LDKOutPoint val_conv;
24518         val_conv.inner = (void*)(val & (~1));
24519         val_conv.is_owned = (val & 1) || (val == 0);
24520         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24521         val_conv = OutPoint_clone(&val_conv);
24522         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
24523 }
24524
24525 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_channel_type"))) TS_ChannelDetails_get_channel_type(uint32_t this_ptr) {
24526         LDKChannelDetails this_ptr_conv;
24527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24528         this_ptr_conv.is_owned = false;
24529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24530         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
24531         uint32_t ret_ref = 0;
24532         if ((uintptr_t)ret_var.inner > 4096) {
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         }
24541         return ret_ref;
24542 }
24543
24544 void  __attribute__((export_name("TS_ChannelDetails_set_channel_type"))) TS_ChannelDetails_set_channel_type(uint32_t this_ptr, uint32_t val) {
24545         LDKChannelDetails this_ptr_conv;
24546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24547         this_ptr_conv.is_owned = false;
24548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24549         LDKChannelTypeFeatures val_conv;
24550         val_conv.inner = (void*)(val & (~1));
24551         val_conv.is_owned = (val & 1) || (val == 0);
24552         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24553         val_conv = ChannelTypeFeatures_clone(&val_conv);
24554         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
24555 }
24556
24557 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
24558         LDKChannelDetails this_ptr_conv;
24559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24560         this_ptr_conv.is_owned = false;
24561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24562         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24563         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
24564         uint32_t ret_ref = (uintptr_t)ret_copy;
24565         return ret_ref;
24566 }
24567
24568 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
24569         LDKChannelDetails this_ptr_conv;
24570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24571         this_ptr_conv.is_owned = false;
24572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24573         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24574         CHECK_ACCESS(val_ptr);
24575         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24576         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24577         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
24578 }
24579
24580 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_scid_alias"))) TS_ChannelDetails_get_inbound_scid_alias(uint32_t this_ptr) {
24581         LDKChannelDetails this_ptr_conv;
24582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24583         this_ptr_conv.is_owned = false;
24584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24585         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24586         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
24587         uint32_t ret_ref = (uintptr_t)ret_copy;
24588         return ret_ref;
24589 }
24590
24591 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_scid_alias"))) TS_ChannelDetails_set_inbound_scid_alias(uint32_t this_ptr, uint32_t val) {
24592         LDKChannelDetails this_ptr_conv;
24593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24594         this_ptr_conv.is_owned = false;
24595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24596         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24597         CHECK_ACCESS(val_ptr);
24598         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24599         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24600         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
24601 }
24602
24603 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
24604         LDKChannelDetails this_ptr_conv;
24605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24606         this_ptr_conv.is_owned = false;
24607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24608         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
24609         return ret_val;
24610 }
24611
24612 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24613         LDKChannelDetails this_ptr_conv;
24614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24615         this_ptr_conv.is_owned = false;
24616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24617         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
24618 }
24619
24620 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(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_unspendable_punishment_reserve(&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_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(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_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
24641 }
24642
24643 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(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         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
24649         return ret_val;
24650 }
24651
24652 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
24653         LDKChannelDetails this_ptr_conv;
24654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24655         this_ptr_conv.is_owned = false;
24656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24657         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
24658 }
24659
24660 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
24661         LDKChannelDetails this_ptr_conv;
24662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24663         this_ptr_conv.is_owned = false;
24664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24665         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
24666         return ret_val;
24667 }
24668
24669 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
24670         LDKChannelDetails this_ptr_conv;
24671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24672         this_ptr_conv.is_owned = false;
24673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24674         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
24675 }
24676
24677 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
24678         LDKChannelDetails this_ptr_conv;
24679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24680         this_ptr_conv.is_owned = false;
24681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24682         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
24683         return ret_val;
24684 }
24685
24686 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24687         LDKChannelDetails this_ptr_conv;
24688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24689         this_ptr_conv.is_owned = false;
24690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24691         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
24692 }
24693
24694 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
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         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
24700         return ret_val;
24701 }
24702
24703 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24704         LDKChannelDetails this_ptr_conv;
24705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24706         this_ptr_conv.is_owned = false;
24707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24708         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
24709 }
24710
24711 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
24712         LDKChannelDetails this_ptr_conv;
24713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24714         this_ptr_conv.is_owned = false;
24715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24716         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
24717         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
24718         uint32_t ret_ref = (uintptr_t)ret_copy;
24719         return ret_ref;
24720 }
24721
24722 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
24723         LDKChannelDetails this_ptr_conv;
24724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24725         this_ptr_conv.is_owned = false;
24726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24727         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24728         CHECK_ACCESS(val_ptr);
24729         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
24730         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
24731         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
24732 }
24733
24734 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
24735         LDKChannelDetails this_ptr_conv;
24736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24737         this_ptr_conv.is_owned = false;
24738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24739         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
24740         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
24741         uint32_t ret_ref = (uintptr_t)ret_copy;
24742         return ret_ref;
24743 }
24744
24745 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) {
24746         LDKChannelDetails this_ptr_conv;
24747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24748         this_ptr_conv.is_owned = false;
24749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24750         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24751         CHECK_ACCESS(val_ptr);
24752         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
24753         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
24754         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
24755 }
24756
24757 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(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         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
24763         return ret_val;
24764 }
24765
24766 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean 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_is_outbound(&this_ptr_conv, val);
24772 }
24773
24774 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_funding_locked"))) TS_ChannelDetails_get_is_funding_locked(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         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
24780         return ret_val;
24781 }
24782
24783 void  __attribute__((export_name("TS_ChannelDetails_set_is_funding_locked"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
24784         LDKChannelDetails this_ptr_conv;
24785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24786         this_ptr_conv.is_owned = false;
24787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24788         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
24789 }
24790
24791 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
24792         LDKChannelDetails this_ptr_conv;
24793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24794         this_ptr_conv.is_owned = false;
24795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24796         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
24797         return ret_val;
24798 }
24799
24800 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
24801         LDKChannelDetails this_ptr_conv;
24802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24803         this_ptr_conv.is_owned = false;
24804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24805         ChannelDetails_set_is_usable(&this_ptr_conv, val);
24806 }
24807
24808 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
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         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
24814         return ret_val;
24815 }
24816
24817 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
24818         LDKChannelDetails this_ptr_conv;
24819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24820         this_ptr_conv.is_owned = false;
24821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24822         ChannelDetails_set_is_public(&this_ptr_conv, val);
24823 }
24824
24825 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) {
24826         LDKThirtyTwoBytes channel_id_arg_ref;
24827         CHECK(channel_id_arg->arr_len == 32);
24828         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24829         LDKChannelCounterparty counterparty_arg_conv;
24830         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
24831         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
24832         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
24833         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
24834         LDKOutPoint funding_txo_arg_conv;
24835         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
24836         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
24837         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
24838         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
24839         LDKChannelTypeFeatures channel_type_arg_conv;
24840         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
24841         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
24842         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
24843         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
24844         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
24845         CHECK_ACCESS(short_channel_id_arg_ptr);
24846         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
24847         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
24848         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
24849         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
24850         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
24851         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
24852         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
24853         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
24854         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
24855         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
24856         CHECK_ACCESS(confirmations_required_arg_ptr);
24857         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
24858         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
24859         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
24860         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
24861         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
24862         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
24863         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);
24864         uint32_t ret_ref = 0;
24865         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24866         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24868         ret_ref = (uintptr_t)ret_var.inner;
24869         if (ret_var.is_owned) {
24870                 ret_ref |= 1;
24871         }
24872         return ret_ref;
24873 }
24874
24875 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
24876         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
24877 uint32_t ret_ref = 0;
24878 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24879 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24880 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24881 ret_ref = (uintptr_t)ret_var.inner;
24882 if (ret_var.is_owned) {
24883         ret_ref |= 1;
24884 }
24885         return ret_ref;
24886 }
24887 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
24888         LDKChannelDetails arg_conv;
24889         arg_conv.inner = (void*)(arg & (~1));
24890         arg_conv.is_owned = false;
24891         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24892         uint32_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
24893         return ret_val;
24894 }
24895
24896 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
24897         LDKChannelDetails orig_conv;
24898         orig_conv.inner = (void*)(orig & (~1));
24899         orig_conv.is_owned = false;
24900         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24901         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
24902         uint32_t ret_ref = 0;
24903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24906         ret_ref = (uintptr_t)ret_var.inner;
24907         if (ret_var.is_owned) {
24908                 ret_ref |= 1;
24909         }
24910         return ret_ref;
24911 }
24912
24913 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_payment_scid"))) TS_ChannelDetails_get_inbound_payment_scid(uint32_t this_arg) {
24914         LDKChannelDetails this_arg_conv;
24915         this_arg_conv.inner = (void*)(this_arg & (~1));
24916         this_arg_conv.is_owned = false;
24917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24918         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24919         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
24920         uint32_t ret_ref = (uintptr_t)ret_copy;
24921         return ret_ref;
24922 }
24923
24924 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
24925         if ((this_ptr & 1) != 0) return;
24926         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24927         CHECK_ACCESS(this_ptr_ptr);
24928         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
24929         FREE((void*)this_ptr);
24930         PaymentSendFailure_free(this_ptr_conv);
24931 }
24932
24933 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
24934         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24935         *ret_copy = PaymentSendFailure_clone(arg);
24936 uint32_t ret_ref = (uintptr_t)ret_copy;
24937         return ret_ref;
24938 }
24939 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
24940         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
24941         uint32_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
24942         return ret_val;
24943 }
24944
24945 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
24946         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
24947         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24948         *ret_copy = PaymentSendFailure_clone(orig_conv);
24949         uint32_t ret_ref = (uintptr_t)ret_copy;
24950         return ret_ref;
24951 }
24952
24953 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
24954         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
24955         CHECK_ACCESS(a_ptr);
24956         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
24957         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
24958         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24959         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
24960         uint32_t ret_ref = (uintptr_t)ret_copy;
24961         return ret_ref;
24962 }
24963
24964 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
24965         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
24966         a_constr.datalen = a->arr_len;
24967         if (a_constr.datalen > 0)
24968                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
24969         else
24970                 a_constr.data = NULL;
24971         uint32_t* a_vals = a->elems /* XXX a leaks */;
24972         for (size_t w = 0; w < a_constr.datalen; w++) {
24973                 uint32_t a_conv_22 = a_vals[w];
24974                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
24975                 CHECK_ACCESS(a_conv_22_ptr);
24976                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
24977                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
24978                 a_constr.data[w] = a_conv_22_conv;
24979         }
24980         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24981         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
24982         uint32_t ret_ref = (uintptr_t)ret_copy;
24983         return ret_ref;
24984 }
24985
24986 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
24987         LDKCVec_APIErrorZ a_constr;
24988         a_constr.datalen = a->arr_len;
24989         if (a_constr.datalen > 0)
24990                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
24991         else
24992                 a_constr.data = NULL;
24993         uint32_t* a_vals = a->elems /* XXX a leaks */;
24994         for (size_t k = 0; k < a_constr.datalen; k++) {
24995                 uint32_t a_conv_10 = a_vals[k];
24996                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
24997                 CHECK_ACCESS(a_conv_10_ptr);
24998                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
24999                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
25000                 a_constr.data[k] = a_conv_10_conv;
25001         }
25002         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25003         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
25004         uint32_t ret_ref = (uintptr_t)ret_copy;
25005         return ret_ref;
25006 }
25007
25008 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) {
25009         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
25010         results_constr.datalen = results->arr_len;
25011         if (results_constr.datalen > 0)
25012                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
25013         else
25014                 results_constr.data = NULL;
25015         uint32_t* results_vals = results->elems /* XXX results leaks */;
25016         for (size_t w = 0; w < results_constr.datalen; w++) {
25017                 uint32_t results_conv_22 = results_vals[w];
25018                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
25019                 CHECK_ACCESS(results_conv_22_ptr);
25020                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
25021                 results_constr.data[w] = results_conv_22_conv;
25022         }
25023         LDKRouteParameters failed_paths_retry_conv;
25024         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
25025         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
25026         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
25027         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
25028         LDKThirtyTwoBytes payment_id_ref;
25029         CHECK(payment_id->arr_len == 32);
25030         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25031         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25032         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
25033         uint32_t ret_ref = (uintptr_t)ret_copy;
25034         return ret_ref;
25035 }
25036
25037 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint32_t this_obj) {
25038         LDKPhantomRouteHints this_obj_conv;
25039         this_obj_conv.inner = (void*)(this_obj & (~1));
25040         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25042         PhantomRouteHints_free(this_obj_conv);
25043 }
25044
25045 uint32_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint32_t this_ptr) {
25046         LDKPhantomRouteHints this_ptr_conv;
25047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25048         this_ptr_conv.is_owned = false;
25049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25050         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
25051         uint32_tArray ret_arr = NULL;
25052         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25053         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25054         for (size_t q = 0; q < ret_var.datalen; q++) {
25055                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25056                 uint32_t ret_conv_16_ref = 0;
25057                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25058                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25059                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25060                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25061                 if (ret_conv_16_var.is_owned) {
25062                         ret_conv_16_ref |= 1;
25063                 }
25064                 ret_arr_ptr[q] = ret_conv_16_ref;
25065         }
25066         
25067         FREE(ret_var.data);
25068         return ret_arr;
25069 }
25070
25071 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint32_t this_ptr, uint32_tArray val) {
25072         LDKPhantomRouteHints this_ptr_conv;
25073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25074         this_ptr_conv.is_owned = false;
25075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25076         LDKCVec_ChannelDetailsZ val_constr;
25077         val_constr.datalen = val->arr_len;
25078         if (val_constr.datalen > 0)
25079                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25080         else
25081                 val_constr.data = NULL;
25082         uint32_t* val_vals = val->elems /* XXX val leaks */;
25083         for (size_t q = 0; q < val_constr.datalen; q++) {
25084                 uint32_t val_conv_16 = val_vals[q];
25085                 LDKChannelDetails val_conv_16_conv;
25086                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
25087                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
25088                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
25089                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
25090                 val_constr.data[q] = val_conv_16_conv;
25091         }
25092         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
25093 }
25094
25095 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint32_t this_ptr) {
25096         LDKPhantomRouteHints this_ptr_conv;
25097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25098         this_ptr_conv.is_owned = false;
25099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25100         int64_t ret_val = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
25101         return ret_val;
25102 }
25103
25104 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint32_t this_ptr, int64_t val) {
25105         LDKPhantomRouteHints this_ptr_conv;
25106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25107         this_ptr_conv.is_owned = false;
25108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25109         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
25110 }
25111
25112 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint32_t this_ptr) {
25113         LDKPhantomRouteHints this_ptr_conv;
25114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25115         this_ptr_conv.is_owned = false;
25116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25117         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25118         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
25119         return ret_arr;
25120 }
25121
25122 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint32_t this_ptr, int8_tArray val) {
25123         LDKPhantomRouteHints this_ptr_conv;
25124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25125         this_ptr_conv.is_owned = false;
25126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25127         LDKPublicKey val_ref;
25128         CHECK(val->arr_len == 33);
25129         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25130         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
25131 }
25132
25133 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) {
25134         LDKCVec_ChannelDetailsZ channels_arg_constr;
25135         channels_arg_constr.datalen = channels_arg->arr_len;
25136         if (channels_arg_constr.datalen > 0)
25137                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25138         else
25139                 channels_arg_constr.data = NULL;
25140         uint32_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
25141         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
25142                 uint32_t channels_arg_conv_16 = channels_arg_vals[q];
25143                 LDKChannelDetails channels_arg_conv_16_conv;
25144                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
25145                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
25146                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
25147                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
25148                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
25149         }
25150         LDKPublicKey real_node_pubkey_arg_ref;
25151         CHECK(real_node_pubkey_arg->arr_len == 33);
25152         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
25153         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
25154         uint32_t ret_ref = 0;
25155         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25156         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25158         ret_ref = (uintptr_t)ret_var.inner;
25159         if (ret_var.is_owned) {
25160                 ret_ref |= 1;
25161         }
25162         return ret_ref;
25163 }
25164
25165 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
25166         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
25167 uint32_t ret_ref = 0;
25168 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25169 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25170 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25171 ret_ref = (uintptr_t)ret_var.inner;
25172 if (ret_var.is_owned) {
25173         ret_ref |= 1;
25174 }
25175         return ret_ref;
25176 }
25177 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint32_t arg) {
25178         LDKPhantomRouteHints arg_conv;
25179         arg_conv.inner = (void*)(arg & (~1));
25180         arg_conv.is_owned = false;
25181         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25182         uint32_t ret_val = PhantomRouteHints_clone_ptr(&arg_conv);
25183         return ret_val;
25184 }
25185
25186 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint32_t orig) {
25187         LDKPhantomRouteHints orig_conv;
25188         orig_conv.inner = (void*)(orig & (~1));
25189         orig_conv.is_owned = false;
25190         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25191         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
25192         uint32_t ret_ref = 0;
25193         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25194         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25196         ret_ref = (uintptr_t)ret_var.inner;
25197         if (ret_var.is_owned) {
25198                 ret_ref |= 1;
25199         }
25200         return ret_ref;
25201 }
25202
25203 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) {
25204         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
25205         CHECK_ACCESS(fee_est_ptr);
25206         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
25207         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
25208                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25209                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
25210         }
25211         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
25212         CHECK_ACCESS(chain_monitor_ptr);
25213         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
25214         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
25215                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25216                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
25217         }
25218         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
25219         CHECK_ACCESS(tx_broadcaster_ptr);
25220         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
25221         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25222                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25223                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
25224         }
25225         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25226         CHECK_ACCESS(logger_ptr);
25227         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25228         if (logger_conv.free == LDKLogger_JCalls_free) {
25229                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25230                 LDKLogger_JCalls_cloned(&logger_conv);
25231         }
25232         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
25233         CHECK_ACCESS(keys_manager_ptr);
25234         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
25235         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25236                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25237                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
25238         }
25239         LDKUserConfig config_conv;
25240         config_conv.inner = (void*)(config & (~1));
25241         config_conv.is_owned = (config & 1) || (config == 0);
25242         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
25243         config_conv = UserConfig_clone(&config_conv);
25244         LDKChainParameters params_conv;
25245         params_conv.inner = (void*)(params & (~1));
25246         params_conv.is_owned = (params & 1) || (params == 0);
25247         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
25248         params_conv = ChainParameters_clone(&params_conv);
25249         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
25250         uint32_t ret_ref = 0;
25251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25254         ret_ref = (uintptr_t)ret_var.inner;
25255         if (ret_var.is_owned) {
25256                 ret_ref |= 1;
25257         }
25258         return ret_ref;
25259 }
25260
25261 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
25262         LDKChannelManager this_arg_conv;
25263         this_arg_conv.inner = (void*)(this_arg & (~1));
25264         this_arg_conv.is_owned = false;
25265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25266         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
25267         uint32_t ret_ref = 0;
25268         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25269         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25271         ret_ref = (uintptr_t)ret_var.inner;
25272         if (ret_var.is_owned) {
25273                 ret_ref |= 1;
25274         }
25275         return ret_ref;
25276 }
25277
25278 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) {
25279         LDKChannelManager this_arg_conv;
25280         this_arg_conv.inner = (void*)(this_arg & (~1));
25281         this_arg_conv.is_owned = false;
25282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25283         LDKPublicKey their_network_key_ref;
25284         CHECK(their_network_key->arr_len == 33);
25285         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
25286         LDKUserConfig override_config_conv;
25287         override_config_conv.inner = (void*)(override_config & (~1));
25288         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
25289         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
25290         override_config_conv = UserConfig_clone(&override_config_conv);
25291         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
25292         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
25293         return (uint32_t)ret_conv;
25294 }
25295
25296 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
25297         LDKChannelManager this_arg_conv;
25298         this_arg_conv.inner = (void*)(this_arg & (~1));
25299         this_arg_conv.is_owned = false;
25300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25301         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
25302         uint32_tArray ret_arr = NULL;
25303         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25304         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25305         for (size_t q = 0; q < ret_var.datalen; q++) {
25306                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25307                 uint32_t ret_conv_16_ref = 0;
25308                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25309                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25310                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25311                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25312                 if (ret_conv_16_var.is_owned) {
25313                         ret_conv_16_ref |= 1;
25314                 }
25315                 ret_arr_ptr[q] = ret_conv_16_ref;
25316         }
25317         
25318         FREE(ret_var.data);
25319         return ret_arr;
25320 }
25321
25322 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
25323         LDKChannelManager this_arg_conv;
25324         this_arg_conv.inner = (void*)(this_arg & (~1));
25325         this_arg_conv.is_owned = false;
25326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25327         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
25328         uint32_tArray ret_arr = NULL;
25329         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25330         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25331         for (size_t q = 0; q < ret_var.datalen; q++) {
25332                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25333                 uint32_t ret_conv_16_ref = 0;
25334                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25335                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25336                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25337                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25338                 if (ret_conv_16_var.is_owned) {
25339                         ret_conv_16_ref |= 1;
25340                 }
25341                 ret_arr_ptr[q] = ret_conv_16_ref;
25342         }
25343         
25344         FREE(ret_var.data);
25345         return ret_arr;
25346 }
25347
25348 uint32_t  __attribute__((export_name("TS_ChannelManager_close_channel"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
25349         LDKChannelManager this_arg_conv;
25350         this_arg_conv.inner = (void*)(this_arg & (~1));
25351         this_arg_conv.is_owned = false;
25352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25353         unsigned char channel_id_arr[32];
25354         CHECK(channel_id->arr_len == 32);
25355         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25356         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25357         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25358         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
25359         return (uint32_t)ret_conv;
25360 }
25361
25362 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) {
25363         LDKChannelManager this_arg_conv;
25364         this_arg_conv.inner = (void*)(this_arg & (~1));
25365         this_arg_conv.is_owned = false;
25366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25367         unsigned char channel_id_arr[32];
25368         CHECK(channel_id->arr_len == 32);
25369         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25370         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25371         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25372         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
25373         return (uint32_t)ret_conv;
25374 }
25375
25376 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_channel"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
25377         LDKChannelManager this_arg_conv;
25378         this_arg_conv.inner = (void*)(this_arg & (~1));
25379         this_arg_conv.is_owned = false;
25380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25381         unsigned char channel_id_arr[32];
25382         CHECK(channel_id->arr_len == 32);
25383         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25384         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25385         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25386         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
25387         return (uint32_t)ret_conv;
25388 }
25389
25390 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
25391         LDKChannelManager this_arg_conv;
25392         this_arg_conv.inner = (void*)(this_arg & (~1));
25393         this_arg_conv.is_owned = false;
25394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25395         ChannelManager_force_close_all_channels(&this_arg_conv);
25396 }
25397
25398 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) {
25399         LDKChannelManager this_arg_conv;
25400         this_arg_conv.inner = (void*)(this_arg & (~1));
25401         this_arg_conv.is_owned = false;
25402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25403         LDKRoute route_conv;
25404         route_conv.inner = (void*)(route & (~1));
25405         route_conv.is_owned = false;
25406         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25407         LDKThirtyTwoBytes payment_hash_ref;
25408         CHECK(payment_hash->arr_len == 32);
25409         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25410         LDKThirtyTwoBytes payment_secret_ref;
25411         CHECK(payment_secret->arr_len == 32);
25412         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
25413         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
25414         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
25415         return (uint32_t)ret_conv;
25416 }
25417
25418 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
25419         LDKChannelManager this_arg_conv;
25420         this_arg_conv.inner = (void*)(this_arg & (~1));
25421         this_arg_conv.is_owned = false;
25422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25423         LDKRoute route_conv;
25424         route_conv.inner = (void*)(route & (~1));
25425         route_conv.is_owned = false;
25426         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25427         LDKThirtyTwoBytes payment_id_ref;
25428         CHECK(payment_id->arr_len == 32);
25429         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25430         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
25431         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
25432         return (uint32_t)ret_conv;
25433 }
25434
25435 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
25436         LDKChannelManager this_arg_conv;
25437         this_arg_conv.inner = (void*)(this_arg & (~1));
25438         this_arg_conv.is_owned = false;
25439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25440         LDKThirtyTwoBytes payment_id_ref;
25441         CHECK(payment_id->arr_len == 32);
25442         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25443         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
25444 }
25445
25446 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) {
25447         LDKChannelManager this_arg_conv;
25448         this_arg_conv.inner = (void*)(this_arg & (~1));
25449         this_arg_conv.is_owned = false;
25450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25451         LDKRoute route_conv;
25452         route_conv.inner = (void*)(route & (~1));
25453         route_conv.is_owned = false;
25454         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25455         LDKThirtyTwoBytes payment_preimage_ref;
25456         CHECK(payment_preimage->arr_len == 32);
25457         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
25458         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
25459         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
25460         return (uint32_t)ret_conv;
25461 }
25462
25463 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) {
25464         LDKChannelManager this_arg_conv;
25465         this_arg_conv.inner = (void*)(this_arg & (~1));
25466         this_arg_conv.is_owned = false;
25467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25468         unsigned char temporary_channel_id_arr[32];
25469         CHECK(temporary_channel_id->arr_len == 32);
25470         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25471         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25472         LDKTransaction funding_transaction_ref;
25473         funding_transaction_ref.datalen = funding_transaction->arr_len;
25474         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
25475         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
25476         funding_transaction_ref.data_is_owned = true;
25477         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25478         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
25479         return (uint32_t)ret_conv;
25480 }
25481
25482 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) {
25483         LDKChannelManager this_arg_conv;
25484         this_arg_conv.inner = (void*)(this_arg & (~1));
25485         this_arg_conv.is_owned = false;
25486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25487         LDKThreeBytes rgb_ref;
25488         CHECK(rgb->arr_len == 3);
25489         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
25490         LDKThirtyTwoBytes alias_ref;
25491         CHECK(alias->arr_len == 32);
25492         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
25493         LDKCVec_NetAddressZ addresses_constr;
25494         addresses_constr.datalen = addresses->arr_len;
25495         if (addresses_constr.datalen > 0)
25496                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25497         else
25498                 addresses_constr.data = NULL;
25499         uint32_t* addresses_vals = addresses->elems /* XXX addresses leaks */;
25500         for (size_t m = 0; m < addresses_constr.datalen; m++) {
25501                 uint32_t addresses_conv_12 = addresses_vals[m];
25502                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
25503                 CHECK_ACCESS(addresses_conv_12_ptr);
25504                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
25505                 addresses_constr.data[m] = addresses_conv_12_conv;
25506         }
25507         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
25508 }
25509
25510 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
25511         LDKChannelManager this_arg_conv;
25512         this_arg_conv.inner = (void*)(this_arg & (~1));
25513         this_arg_conv.is_owned = false;
25514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25515         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
25516 }
25517
25518 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
25519         LDKChannelManager this_arg_conv;
25520         this_arg_conv.inner = (void*)(this_arg & (~1));
25521         this_arg_conv.is_owned = false;
25522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25523         ChannelManager_timer_tick_occurred(&this_arg_conv);
25524 }
25525
25526 jboolean  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
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 payment_hash_arr[32];
25532         CHECK(payment_hash->arr_len == 32);
25533         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
25534         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
25535         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
25536         return ret_val;
25537 }
25538
25539 jboolean  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
25540         LDKChannelManager this_arg_conv;
25541         this_arg_conv.inner = (void*)(this_arg & (~1));
25542         this_arg_conv.is_owned = false;
25543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25544         LDKThirtyTwoBytes payment_preimage_ref;
25545         CHECK(payment_preimage->arr_len == 32);
25546         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
25547         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
25548         return ret_val;
25549 }
25550
25551 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
25552         LDKChannelManager this_arg_conv;
25553         this_arg_conv.inner = (void*)(this_arg & (~1));
25554         this_arg_conv.is_owned = false;
25555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25556         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25557         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
25558         return ret_arr;
25559 }
25560
25561 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) {
25562         LDKChannelManager this_arg_conv;
25563         this_arg_conv.inner = (void*)(this_arg & (~1));
25564         this_arg_conv.is_owned = false;
25565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25566         unsigned char temporary_channel_id_arr[32];
25567         CHECK(temporary_channel_id->arr_len == 32);
25568         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25569         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25570         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25571         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, user_channel_id);
25572         return (uint32_t)ret_conv;
25573 }
25574
25575 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) {
25576         LDKChannelManager this_arg_conv;
25577         this_arg_conv.inner = (void*)(this_arg & (~1));
25578         this_arg_conv.is_owned = false;
25579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25580         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25581         CHECK_ACCESS(min_value_msat_ptr);
25582         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25583         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25584         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
25585         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25586         return (uint32_t)ret_conv;
25587 }
25588
25589 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) {
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         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25595         CHECK_ACCESS(min_value_msat_ptr);
25596         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25597         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25598         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
25599         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25600         return (uint32_t)ret_conv;
25601 }
25602
25603 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) {
25604         LDKChannelManager this_arg_conv;
25605         this_arg_conv.inner = (void*)(this_arg & (~1));
25606         this_arg_conv.is_owned = false;
25607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25608         LDKThirtyTwoBytes payment_hash_ref;
25609         CHECK(payment_hash->arr_len == 32);
25610         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25611         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25612         CHECK_ACCESS(min_value_msat_ptr);
25613         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25614         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25615         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
25616         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25617         return (uint32_t)ret_conv;
25618 }
25619
25620 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) {
25621         LDKChannelManager this_arg_conv;
25622         this_arg_conv.inner = (void*)(this_arg & (~1));
25623         this_arg_conv.is_owned = false;
25624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25625         LDKThirtyTwoBytes payment_hash_ref;
25626         CHECK(payment_hash->arr_len == 32);
25627         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25628         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25629         CHECK_ACCESS(min_value_msat_ptr);
25630         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25631         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25632         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
25633         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25634         return (uint32_t)ret_conv;
25635 }
25636
25637 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) {
25638         LDKChannelManager this_arg_conv;
25639         this_arg_conv.inner = (void*)(this_arg & (~1));
25640         this_arg_conv.is_owned = false;
25641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25642         LDKThirtyTwoBytes payment_hash_ref;
25643         CHECK(payment_hash->arr_len == 32);
25644         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25645         LDKThirtyTwoBytes payment_secret_ref;
25646         CHECK(payment_secret->arr_len == 32);
25647         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
25648         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
25649         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
25650         return (uint32_t)ret_conv;
25651 }
25652
25653 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint32_t this_arg) {
25654         LDKChannelManager this_arg_conv;
25655         this_arg_conv.inner = (void*)(this_arg & (~1));
25656         this_arg_conv.is_owned = false;
25657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25658         int64_t ret_val = ChannelManager_get_phantom_scid(&this_arg_conv);
25659         return ret_val;
25660 }
25661
25662 uint32_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint32_t this_arg) {
25663         LDKChannelManager this_arg_conv;
25664         this_arg_conv.inner = (void*)(this_arg & (~1));
25665         this_arg_conv.is_owned = false;
25666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25667         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
25668         uint32_t ret_ref = 0;
25669         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25670         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25672         ret_ref = (uintptr_t)ret_var.inner;
25673         if (ret_var.is_owned) {
25674                 ret_ref |= 1;
25675         }
25676         return ret_ref;
25677 }
25678
25679 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
25680         LDKChannelManager this_arg_conv;
25681         this_arg_conv.inner = (void*)(this_arg & (~1));
25682         this_arg_conv.is_owned = false;
25683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25684         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
25685         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
25686         return (uint32_t)ret_ret;
25687 }
25688
25689 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
25690         LDKChannelManager this_arg_conv;
25691         this_arg_conv.inner = (void*)(this_arg & (~1));
25692         this_arg_conv.is_owned = false;
25693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25694         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25695         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
25696         return (uint32_t)ret_ret;
25697 }
25698
25699 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
25700         LDKChannelManager this_arg_conv;
25701         this_arg_conv.inner = (void*)(this_arg & (~1));
25702         this_arg_conv.is_owned = false;
25703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25704         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25705         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
25706         return (uint32_t)ret_ret;
25707 }
25708
25709 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
25710         LDKChannelManager this_arg_conv;
25711         this_arg_conv.inner = (void*)(this_arg & (~1));
25712         this_arg_conv.is_owned = false;
25713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25714         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25715         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
25716         return (uint32_t)ret_ret;
25717 }
25718
25719 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
25720         LDKChannelManager this_arg_conv;
25721         this_arg_conv.inner = (void*)(this_arg & (~1));
25722         this_arg_conv.is_owned = false;
25723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25724         ChannelManager_await_persistable_update(&this_arg_conv);
25725 }
25726
25727 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
25728         LDKChannelManager this_arg_conv;
25729         this_arg_conv.inner = (void*)(this_arg & (~1));
25730         this_arg_conv.is_owned = false;
25731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25732         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
25733         uint32_t ret_ref = 0;
25734         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25735         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25737         ret_ref = (uintptr_t)ret_var.inner;
25738         if (ret_var.is_owned) {
25739                 ret_ref |= 1;
25740         }
25741         return ret_ref;
25742 }
25743
25744 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
25745         LDKChannelManager this_arg_conv;
25746         this_arg_conv.inner = (void*)(this_arg & (~1));
25747         this_arg_conv.is_owned = false;
25748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25749         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
25750         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
25751         return (uint32_t)ret_ret;
25752 }
25753
25754 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint32_t obj) {
25755         LDKCounterpartyForwardingInfo obj_conv;
25756         obj_conv.inner = (void*)(obj & (~1));
25757         obj_conv.is_owned = false;
25758         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25759         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
25760         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25761         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25762         CVec_u8Z_free(ret_var);
25763         return ret_arr;
25764 }
25765
25766 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
25767         LDKu8slice ser_ref;
25768         ser_ref.datalen = ser->arr_len;
25769         ser_ref.data = ser->elems /* XXX ser leaks */;
25770         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
25771         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
25772         return (uint32_t)ret_conv;
25773 }
25774
25775 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint32_t obj) {
25776         LDKChannelCounterparty obj_conv;
25777         obj_conv.inner = (void*)(obj & (~1));
25778         obj_conv.is_owned = false;
25779         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25780         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
25781         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25782         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25783         CVec_u8Z_free(ret_var);
25784         return ret_arr;
25785 }
25786
25787 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
25788         LDKu8slice ser_ref;
25789         ser_ref.datalen = ser->arr_len;
25790         ser_ref.data = ser->elems /* XXX ser leaks */;
25791         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
25792         *ret_conv = ChannelCounterparty_read(ser_ref);
25793         return (uint32_t)ret_conv;
25794 }
25795
25796 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint32_t obj) {
25797         LDKChannelDetails obj_conv;
25798         obj_conv.inner = (void*)(obj & (~1));
25799         obj_conv.is_owned = false;
25800         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25801         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
25802         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25803         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25804         CVec_u8Z_free(ret_var);
25805         return ret_arr;
25806 }
25807
25808 uint32_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
25809         LDKu8slice ser_ref;
25810         ser_ref.datalen = ser->arr_len;
25811         ser_ref.data = ser->elems /* XXX ser leaks */;
25812         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
25813         *ret_conv = ChannelDetails_read(ser_ref);
25814         return (uint32_t)ret_conv;
25815 }
25816
25817 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint32_t obj) {
25818         LDKPhantomRouteHints 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 = PhantomRouteHints_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_PhantomRouteHints_read"))) TS_PhantomRouteHints_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_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
25834         *ret_conv = PhantomRouteHints_read(ser_ref);
25835         return (uint32_t)ret_conv;
25836 }
25837
25838 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
25839         LDKChannelManager 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 = ChannelManager_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 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
25851         LDKChannelManagerReadArgs this_obj_conv;
25852         this_obj_conv.inner = (void*)(this_obj & (~1));
25853         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25855         ChannelManagerReadArgs_free(this_obj_conv);
25856 }
25857
25858 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
25859         LDKChannelManagerReadArgs this_ptr_conv;
25860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25861         this_ptr_conv.is_owned = false;
25862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25863         // WARNING: This object doesn't live past this scope, needs clone!
25864         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
25865         return ret_ret;
25866 }
25867
25868 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
25869         LDKChannelManagerReadArgs this_ptr_conv;
25870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25871         this_ptr_conv.is_owned = false;
25872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25873         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25874         CHECK_ACCESS(val_ptr);
25875         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
25876         if (val_conv.free == LDKKeysInterface_JCalls_free) {
25877                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25878                 LDKKeysInterface_JCalls_cloned(&val_conv);
25879         }
25880         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
25881 }
25882
25883 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
25884         LDKChannelManagerReadArgs this_ptr_conv;
25885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25886         this_ptr_conv.is_owned = false;
25887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25888         // WARNING: This object doesn't live past this scope, needs clone!
25889         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
25890         return ret_ret;
25891 }
25892
25893 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
25894         LDKChannelManagerReadArgs this_ptr_conv;
25895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25896         this_ptr_conv.is_owned = false;
25897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25898         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25899         CHECK_ACCESS(val_ptr);
25900         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
25901         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
25902                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25903                 LDKFeeEstimator_JCalls_cloned(&val_conv);
25904         }
25905         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
25906 }
25907
25908 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
25909         LDKChannelManagerReadArgs this_ptr_conv;
25910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25911         this_ptr_conv.is_owned = false;
25912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25913         // WARNING: This object doesn't live past this scope, needs clone!
25914         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
25915         return ret_ret;
25916 }
25917
25918 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
25919         LDKChannelManagerReadArgs this_ptr_conv;
25920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25921         this_ptr_conv.is_owned = false;
25922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25923         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25924         CHECK_ACCESS(val_ptr);
25925         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
25926         if (val_conv.free == LDKWatch_JCalls_free) {
25927                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25928                 LDKWatch_JCalls_cloned(&val_conv);
25929         }
25930         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
25931 }
25932
25933 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
25934         LDKChannelManagerReadArgs this_ptr_conv;
25935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25936         this_ptr_conv.is_owned = false;
25937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25938         // WARNING: This object doesn't live past this scope, needs clone!
25939         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
25940         return ret_ret;
25941 }
25942
25943 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
25944         LDKChannelManagerReadArgs this_ptr_conv;
25945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25946         this_ptr_conv.is_owned = false;
25947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25948         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25949         CHECK_ACCESS(val_ptr);
25950         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
25951         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
25952                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25953                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
25954         }
25955         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
25956 }
25957
25958 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
25959         LDKChannelManagerReadArgs this_ptr_conv;
25960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25961         this_ptr_conv.is_owned = false;
25962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25963         // WARNING: This object doesn't live past this scope, needs clone!
25964         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
25965         return ret_ret;
25966 }
25967
25968 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
25969         LDKChannelManagerReadArgs this_ptr_conv;
25970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25971         this_ptr_conv.is_owned = false;
25972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25973         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25974         CHECK_ACCESS(val_ptr);
25975         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
25976         if (val_conv.free == LDKLogger_JCalls_free) {
25977                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25978                 LDKLogger_JCalls_cloned(&val_conv);
25979         }
25980         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
25981 }
25982
25983 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
25984         LDKChannelManagerReadArgs this_ptr_conv;
25985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25986         this_ptr_conv.is_owned = false;
25987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25988         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
25989         uint32_t ret_ref = 0;
25990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25993         ret_ref = (uintptr_t)ret_var.inner;
25994         if (ret_var.is_owned) {
25995                 ret_ref |= 1;
25996         }
25997         return ret_ref;
25998 }
25999
26000 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
26001         LDKChannelManagerReadArgs this_ptr_conv;
26002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26003         this_ptr_conv.is_owned = false;
26004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26005         LDKUserConfig val_conv;
26006         val_conv.inner = (void*)(val & (~1));
26007         val_conv.is_owned = (val & 1) || (val == 0);
26008         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26009         val_conv = UserConfig_clone(&val_conv);
26010         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
26011 }
26012
26013 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) {
26014         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
26015         CHECK_ACCESS(keys_manager_ptr);
26016         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
26017         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26018                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26019                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26020         }
26021         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26022         CHECK_ACCESS(fee_estimator_ptr);
26023         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26024         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26025                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26026                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26027         }
26028         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
26029         CHECK_ACCESS(chain_monitor_ptr);
26030         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
26031         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
26032                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26033                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
26034         }
26035         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
26036         CHECK_ACCESS(tx_broadcaster_ptr);
26037         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
26038         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26039                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26040                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
26041         }
26042         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26043         CHECK_ACCESS(logger_ptr);
26044         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26045         if (logger_conv.free == LDKLogger_JCalls_free) {
26046                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26047                 LDKLogger_JCalls_cloned(&logger_conv);
26048         }
26049         LDKUserConfig default_config_conv;
26050         default_config_conv.inner = (void*)(default_config & (~1));
26051         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
26052         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
26053         default_config_conv = UserConfig_clone(&default_config_conv);
26054         LDKCVec_ChannelMonitorZ channel_monitors_constr;
26055         channel_monitors_constr.datalen = channel_monitors->arr_len;
26056         if (channel_monitors_constr.datalen > 0)
26057                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
26058         else
26059                 channel_monitors_constr.data = NULL;
26060         uint32_t* channel_monitors_vals = channel_monitors->elems /* XXX channel_monitors leaks */;
26061         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
26062                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
26063                 LDKChannelMonitor channel_monitors_conv_16_conv;
26064                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
26065                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
26066                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
26067                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
26068         }
26069         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);
26070         uint32_t ret_ref = 0;
26071         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26072         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26074         ret_ref = (uintptr_t)ret_var.inner;
26075         if (ret_var.is_owned) {
26076                 ret_ref |= 1;
26077         }
26078         return ret_ref;
26079 }
26080
26081 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
26082         LDKu8slice ser_ref;
26083         ser_ref.datalen = ser->arr_len;
26084         ser_ref.data = ser->elems /* XXX ser leaks */;
26085         LDKChannelManagerReadArgs arg_conv;
26086         arg_conv.inner = (void*)(arg & (~1));
26087         arg_conv.is_owned = (arg & 1) || (arg == 0);
26088         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26089         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
26090         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
26091         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
26092         return (uint32_t)ret_conv;
26093 }
26094
26095 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
26096         LDKDecodeError this_obj_conv;
26097         this_obj_conv.inner = (void*)(this_obj & (~1));
26098         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26100         DecodeError_free(this_obj_conv);
26101 }
26102
26103 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
26104         LDKDecodeError ret_var = DecodeError_clone(arg);
26105 uint32_t ret_ref = 0;
26106 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26107 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26108 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26109 ret_ref = (uintptr_t)ret_var.inner;
26110 if (ret_var.is_owned) {
26111         ret_ref |= 1;
26112 }
26113         return ret_ref;
26114 }
26115 uint32_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
26116         LDKDecodeError arg_conv;
26117         arg_conv.inner = (void*)(arg & (~1));
26118         arg_conv.is_owned = false;
26119         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26120         uint32_t ret_val = DecodeError_clone_ptr(&arg_conv);
26121         return ret_val;
26122 }
26123
26124 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
26125         LDKDecodeError orig_conv;
26126         orig_conv.inner = (void*)(orig & (~1));
26127         orig_conv.is_owned = false;
26128         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26129         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
26130         uint32_t ret_ref = 0;
26131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26134         ret_ref = (uintptr_t)ret_var.inner;
26135         if (ret_var.is_owned) {
26136                 ret_ref |= 1;
26137         }
26138         return ret_ref;
26139 }
26140
26141 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
26142         LDKInit this_obj_conv;
26143         this_obj_conv.inner = (void*)(this_obj & (~1));
26144         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26146         Init_free(this_obj_conv);
26147 }
26148
26149 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
26150         LDKInit this_ptr_conv;
26151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26152         this_ptr_conv.is_owned = false;
26153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26154         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
26155         uint32_t ret_ref = 0;
26156         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26157         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26159         ret_ref = (uintptr_t)ret_var.inner;
26160         if (ret_var.is_owned) {
26161                 ret_ref |= 1;
26162         }
26163         return ret_ref;
26164 }
26165
26166 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
26167         LDKInit this_ptr_conv;
26168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26169         this_ptr_conv.is_owned = false;
26170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26171         LDKInitFeatures val_conv;
26172         val_conv.inner = (void*)(val & (~1));
26173         val_conv.is_owned = (val & 1) || (val == 0);
26174         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26175         val_conv = InitFeatures_clone(&val_conv);
26176         Init_set_features(&this_ptr_conv, val_conv);
26177 }
26178
26179 uint32_t  __attribute__((export_name("TS_Init_get_remote_network_address"))) TS_Init_get_remote_network_address(uint32_t this_ptr) {
26180         LDKInit this_ptr_conv;
26181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26182         this_ptr_conv.is_owned = false;
26183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26184         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
26185         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
26186         uint32_t ret_ref = (uintptr_t)ret_copy;
26187         return ret_ref;
26188 }
26189
26190 void  __attribute__((export_name("TS_Init_set_remote_network_address"))) TS_Init_set_remote_network_address(uint32_t this_ptr, uint32_t val) {
26191         LDKInit this_ptr_conv;
26192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26193         this_ptr_conv.is_owned = false;
26194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26195         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26196         CHECK_ACCESS(val_ptr);
26197         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
26198         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
26199         Init_set_remote_network_address(&this_ptr_conv, val_conv);
26200 }
26201
26202 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg, uint32_t remote_network_address_arg) {
26203         LDKInitFeatures features_arg_conv;
26204         features_arg_conv.inner = (void*)(features_arg & (~1));
26205         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
26206         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
26207         features_arg_conv = InitFeatures_clone(&features_arg_conv);
26208         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
26209         CHECK_ACCESS(remote_network_address_arg_ptr);
26210         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
26211         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
26212         uint32_t ret_ref = 0;
26213         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26214         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26216         ret_ref = (uintptr_t)ret_var.inner;
26217         if (ret_var.is_owned) {
26218                 ret_ref |= 1;
26219         }
26220         return ret_ref;
26221 }
26222
26223 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
26224         LDKInit ret_var = Init_clone(arg);
26225 uint32_t ret_ref = 0;
26226 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26227 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26228 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26229 ret_ref = (uintptr_t)ret_var.inner;
26230 if (ret_var.is_owned) {
26231         ret_ref |= 1;
26232 }
26233         return ret_ref;
26234 }
26235 uint32_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
26236         LDKInit arg_conv;
26237         arg_conv.inner = (void*)(arg & (~1));
26238         arg_conv.is_owned = false;
26239         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26240         uint32_t ret_val = Init_clone_ptr(&arg_conv);
26241         return ret_val;
26242 }
26243
26244 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
26245         LDKInit orig_conv;
26246         orig_conv.inner = (void*)(orig & (~1));
26247         orig_conv.is_owned = false;
26248         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26249         LDKInit ret_var = Init_clone(&orig_conv);
26250         uint32_t ret_ref = 0;
26251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26254         ret_ref = (uintptr_t)ret_var.inner;
26255         if (ret_var.is_owned) {
26256                 ret_ref |= 1;
26257         }
26258         return ret_ref;
26259 }
26260
26261 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
26262         LDKErrorMessage this_obj_conv;
26263         this_obj_conv.inner = (void*)(this_obj & (~1));
26264         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26266         ErrorMessage_free(this_obj_conv);
26267 }
26268
26269 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
26270         LDKErrorMessage this_ptr_conv;
26271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26272         this_ptr_conv.is_owned = false;
26273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26274         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26275         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
26276         return ret_arr;
26277 }
26278
26279 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
26280         LDKErrorMessage this_ptr_conv;
26281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26282         this_ptr_conv.is_owned = false;
26283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26284         LDKThirtyTwoBytes val_ref;
26285         CHECK(val->arr_len == 32);
26286         memcpy(val_ref.data, val->elems, 32); FREE(val);
26287         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
26288 }
26289
26290 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
26291         LDKErrorMessage this_ptr_conv;
26292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26293         this_ptr_conv.is_owned = false;
26294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26295         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
26296         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26297         Str_free(ret_str);
26298         return ret_conv;
26299 }
26300
26301 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
26302         LDKErrorMessage this_ptr_conv;
26303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26304         this_ptr_conv.is_owned = false;
26305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26306         LDKStr val_conv = str_ref_to_owned_c(val);
26307         ErrorMessage_set_data(&this_ptr_conv, val_conv);
26308 }
26309
26310 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
26311         LDKThirtyTwoBytes channel_id_arg_ref;
26312         CHECK(channel_id_arg->arr_len == 32);
26313         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26314         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
26315         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
26316         uint32_t ret_ref = 0;
26317         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26318         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26320         ret_ref = (uintptr_t)ret_var.inner;
26321         if (ret_var.is_owned) {
26322                 ret_ref |= 1;
26323         }
26324         return ret_ref;
26325 }
26326
26327 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
26328         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
26329 uint32_t ret_ref = 0;
26330 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26331 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26332 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26333 ret_ref = (uintptr_t)ret_var.inner;
26334 if (ret_var.is_owned) {
26335         ret_ref |= 1;
26336 }
26337         return ret_ref;
26338 }
26339 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
26340         LDKErrorMessage arg_conv;
26341         arg_conv.inner = (void*)(arg & (~1));
26342         arg_conv.is_owned = false;
26343         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26344         uint32_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
26345         return ret_val;
26346 }
26347
26348 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
26349         LDKErrorMessage orig_conv;
26350         orig_conv.inner = (void*)(orig & (~1));
26351         orig_conv.is_owned = false;
26352         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26353         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
26354         uint32_t ret_ref = 0;
26355         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26356         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26358         ret_ref = (uintptr_t)ret_var.inner;
26359         if (ret_var.is_owned) {
26360                 ret_ref |= 1;
26361         }
26362         return ret_ref;
26363 }
26364
26365 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint32_t this_obj) {
26366         LDKWarningMessage this_obj_conv;
26367         this_obj_conv.inner = (void*)(this_obj & (~1));
26368         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26370         WarningMessage_free(this_obj_conv);
26371 }
26372
26373 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint32_t this_ptr) {
26374         LDKWarningMessage this_ptr_conv;
26375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26376         this_ptr_conv.is_owned = false;
26377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26378         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26379         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
26380         return ret_arr;
26381 }
26382
26383 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
26384         LDKWarningMessage this_ptr_conv;
26385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26386         this_ptr_conv.is_owned = false;
26387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26388         LDKThirtyTwoBytes val_ref;
26389         CHECK(val->arr_len == 32);
26390         memcpy(val_ref.data, val->elems, 32); FREE(val);
26391         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
26392 }
26393
26394 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint32_t this_ptr) {
26395         LDKWarningMessage this_ptr_conv;
26396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26397         this_ptr_conv.is_owned = false;
26398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26399         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
26400         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26401         Str_free(ret_str);
26402         return ret_conv;
26403 }
26404
26405 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint32_t this_ptr, jstring val) {
26406         LDKWarningMessage this_ptr_conv;
26407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26408         this_ptr_conv.is_owned = false;
26409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26410         LDKStr val_conv = str_ref_to_owned_c(val);
26411         WarningMessage_set_data(&this_ptr_conv, val_conv);
26412 }
26413
26414 uint32_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
26415         LDKThirtyTwoBytes channel_id_arg_ref;
26416         CHECK(channel_id_arg->arr_len == 32);
26417         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26418         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
26419         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
26420         uint32_t ret_ref = 0;
26421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26424         ret_ref = (uintptr_t)ret_var.inner;
26425         if (ret_var.is_owned) {
26426                 ret_ref |= 1;
26427         }
26428         return ret_ref;
26429 }
26430
26431 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
26432         LDKWarningMessage ret_var = WarningMessage_clone(arg);
26433 uint32_t ret_ref = 0;
26434 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26435 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26436 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26437 ret_ref = (uintptr_t)ret_var.inner;
26438 if (ret_var.is_owned) {
26439         ret_ref |= 1;
26440 }
26441         return ret_ref;
26442 }
26443 uint32_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint32_t arg) {
26444         LDKWarningMessage arg_conv;
26445         arg_conv.inner = (void*)(arg & (~1));
26446         arg_conv.is_owned = false;
26447         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26448         uint32_t ret_val = WarningMessage_clone_ptr(&arg_conv);
26449         return ret_val;
26450 }
26451
26452 uint32_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint32_t orig) {
26453         LDKWarningMessage orig_conv;
26454         orig_conv.inner = (void*)(orig & (~1));
26455         orig_conv.is_owned = false;
26456         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26457         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
26458         uint32_t ret_ref = 0;
26459         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26460         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26462         ret_ref = (uintptr_t)ret_var.inner;
26463         if (ret_var.is_owned) {
26464                 ret_ref |= 1;
26465         }
26466         return ret_ref;
26467 }
26468
26469 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
26470         LDKPing this_obj_conv;
26471         this_obj_conv.inner = (void*)(this_obj & (~1));
26472         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26474         Ping_free(this_obj_conv);
26475 }
26476
26477 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
26478         LDKPing this_ptr_conv;
26479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26480         this_ptr_conv.is_owned = false;
26481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26482         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
26483         return ret_val;
26484 }
26485
26486 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
26487         LDKPing this_ptr_conv;
26488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26489         this_ptr_conv.is_owned = false;
26490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26491         Ping_set_ponglen(&this_ptr_conv, val);
26492 }
26493
26494 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
26495         LDKPing this_ptr_conv;
26496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26497         this_ptr_conv.is_owned = false;
26498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26499         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
26500         return ret_val;
26501 }
26502
26503 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
26504         LDKPing this_ptr_conv;
26505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26506         this_ptr_conv.is_owned = false;
26507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26508         Ping_set_byteslen(&this_ptr_conv, val);
26509 }
26510
26511 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
26512         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
26513         uint32_t ret_ref = 0;
26514         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26515         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26517         ret_ref = (uintptr_t)ret_var.inner;
26518         if (ret_var.is_owned) {
26519                 ret_ref |= 1;
26520         }
26521         return ret_ref;
26522 }
26523
26524 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
26525         LDKPing ret_var = Ping_clone(arg);
26526 uint32_t ret_ref = 0;
26527 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26528 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26529 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26530 ret_ref = (uintptr_t)ret_var.inner;
26531 if (ret_var.is_owned) {
26532         ret_ref |= 1;
26533 }
26534         return ret_ref;
26535 }
26536 uint32_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
26537         LDKPing arg_conv;
26538         arg_conv.inner = (void*)(arg & (~1));
26539         arg_conv.is_owned = false;
26540         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26541         uint32_t ret_val = Ping_clone_ptr(&arg_conv);
26542         return ret_val;
26543 }
26544
26545 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
26546         LDKPing orig_conv;
26547         orig_conv.inner = (void*)(orig & (~1));
26548         orig_conv.is_owned = false;
26549         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26550         LDKPing ret_var = Ping_clone(&orig_conv);
26551         uint32_t ret_ref = 0;
26552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26555         ret_ref = (uintptr_t)ret_var.inner;
26556         if (ret_var.is_owned) {
26557                 ret_ref |= 1;
26558         }
26559         return ret_ref;
26560 }
26561
26562 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
26563         LDKPong this_obj_conv;
26564         this_obj_conv.inner = (void*)(this_obj & (~1));
26565         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26567         Pong_free(this_obj_conv);
26568 }
26569
26570 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
26571         LDKPong this_ptr_conv;
26572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26573         this_ptr_conv.is_owned = false;
26574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26575         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
26576         return ret_val;
26577 }
26578
26579 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
26580         LDKPong this_ptr_conv;
26581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26582         this_ptr_conv.is_owned = false;
26583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26584         Pong_set_byteslen(&this_ptr_conv, val);
26585 }
26586
26587 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
26588         LDKPong ret_var = Pong_new(byteslen_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
26600 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
26601         LDKPong ret_var = Pong_clone(arg);
26602 uint32_t ret_ref = 0;
26603 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26604 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26605 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26606 ret_ref = (uintptr_t)ret_var.inner;
26607 if (ret_var.is_owned) {
26608         ret_ref |= 1;
26609 }
26610         return ret_ref;
26611 }
26612 uint32_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
26613         LDKPong arg_conv;
26614         arg_conv.inner = (void*)(arg & (~1));
26615         arg_conv.is_owned = false;
26616         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26617         uint32_t ret_val = Pong_clone_ptr(&arg_conv);
26618         return ret_val;
26619 }
26620
26621 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
26622         LDKPong orig_conv;
26623         orig_conv.inner = (void*)(orig & (~1));
26624         orig_conv.is_owned = false;
26625         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26626         LDKPong ret_var = Pong_clone(&orig_conv);
26627         uint32_t ret_ref = 0;
26628         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26629         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26631         ret_ref = (uintptr_t)ret_var.inner;
26632         if (ret_var.is_owned) {
26633                 ret_ref |= 1;
26634         }
26635         return ret_ref;
26636 }
26637
26638 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
26639         LDKOpenChannel this_obj_conv;
26640         this_obj_conv.inner = (void*)(this_obj & (~1));
26641         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26643         OpenChannel_free(this_obj_conv);
26644 }
26645
26646 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
26647         LDKOpenChannel this_ptr_conv;
26648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26649         this_ptr_conv.is_owned = false;
26650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26651         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26652         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
26653         return ret_arr;
26654 }
26655
26656 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26657         LDKOpenChannel this_ptr_conv;
26658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26659         this_ptr_conv.is_owned = false;
26660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26661         LDKThirtyTwoBytes val_ref;
26662         CHECK(val->arr_len == 32);
26663         memcpy(val_ref.data, val->elems, 32); FREE(val);
26664         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
26665 }
26666
26667 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
26668         LDKOpenChannel this_ptr_conv;
26669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26670         this_ptr_conv.is_owned = false;
26671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26672         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26673         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
26674         return ret_arr;
26675 }
26676
26677 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
26678         LDKOpenChannel this_ptr_conv;
26679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26680         this_ptr_conv.is_owned = false;
26681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26682         LDKThirtyTwoBytes val_ref;
26683         CHECK(val->arr_len == 32);
26684         memcpy(val_ref.data, val->elems, 32); FREE(val);
26685         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26686 }
26687
26688 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
26689         LDKOpenChannel this_ptr_conv;
26690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26691         this_ptr_conv.is_owned = false;
26692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26693         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
26694         return ret_val;
26695 }
26696
26697 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
26698         LDKOpenChannel this_ptr_conv;
26699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26700         this_ptr_conv.is_owned = false;
26701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26702         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
26703 }
26704
26705 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
26706         LDKOpenChannel this_ptr_conv;
26707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26708         this_ptr_conv.is_owned = false;
26709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26710         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
26711         return ret_val;
26712 }
26713
26714 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
26715         LDKOpenChannel this_ptr_conv;
26716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26717         this_ptr_conv.is_owned = false;
26718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26719         OpenChannel_set_push_msat(&this_ptr_conv, val);
26720 }
26721
26722 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
26723         LDKOpenChannel this_ptr_conv;
26724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26725         this_ptr_conv.is_owned = false;
26726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26727         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
26728         return ret_val;
26729 }
26730
26731 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
26732         LDKOpenChannel this_ptr_conv;
26733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26734         this_ptr_conv.is_owned = false;
26735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26736         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26737 }
26738
26739 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) {
26740         LDKOpenChannel this_ptr_conv;
26741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26742         this_ptr_conv.is_owned = false;
26743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26744         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26745         return ret_val;
26746 }
26747
26748 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) {
26749         LDKOpenChannel this_ptr_conv;
26750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26751         this_ptr_conv.is_owned = false;
26752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26753         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26754 }
26755
26756 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
26757         LDKOpenChannel this_ptr_conv;
26758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26759         this_ptr_conv.is_owned = false;
26760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26761         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26762         return ret_val;
26763 }
26764
26765 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
26766         LDKOpenChannel this_ptr_conv;
26767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26768         this_ptr_conv.is_owned = false;
26769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26770         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26771 }
26772
26773 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
26774         LDKOpenChannel this_ptr_conv;
26775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26776         this_ptr_conv.is_owned = false;
26777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26778         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
26779         return ret_val;
26780 }
26781
26782 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26783         LDKOpenChannel this_ptr_conv;
26784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26785         this_ptr_conv.is_owned = false;
26786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26787         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
26788 }
26789
26790 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
26791         LDKOpenChannel this_ptr_conv;
26792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26793         this_ptr_conv.is_owned = false;
26794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26795         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
26796         return ret_val;
26797 }
26798
26799 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
26800         LDKOpenChannel this_ptr_conv;
26801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26802         this_ptr_conv.is_owned = false;
26803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26804         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
26805 }
26806
26807 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
26808         LDKOpenChannel this_ptr_conv;
26809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26810         this_ptr_conv.is_owned = false;
26811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26812         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
26813         return ret_val;
26814 }
26815
26816 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
26817         LDKOpenChannel this_ptr_conv;
26818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26819         this_ptr_conv.is_owned = false;
26820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26821         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
26822 }
26823
26824 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
26825         LDKOpenChannel this_ptr_conv;
26826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26827         this_ptr_conv.is_owned = false;
26828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26829         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
26830         return ret_val;
26831 }
26832
26833 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
26834         LDKOpenChannel this_ptr_conv;
26835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26836         this_ptr_conv.is_owned = false;
26837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26838         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
26839 }
26840
26841 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
26842         LDKOpenChannel this_ptr_conv;
26843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26844         this_ptr_conv.is_owned = false;
26845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26846         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26847         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
26848         return ret_arr;
26849 }
26850
26851 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
26852         LDKOpenChannel this_ptr_conv;
26853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26854         this_ptr_conv.is_owned = false;
26855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26856         LDKPublicKey val_ref;
26857         CHECK(val->arr_len == 33);
26858         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26859         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
26860 }
26861
26862 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
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         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26868         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
26869         return ret_arr;
26870 }
26871
26872 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
26873         LDKOpenChannel this_ptr_conv;
26874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26875         this_ptr_conv.is_owned = false;
26876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26877         LDKPublicKey val_ref;
26878         CHECK(val->arr_len == 33);
26879         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26880         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
26881 }
26882
26883 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
26884         LDKOpenChannel this_ptr_conv;
26885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26886         this_ptr_conv.is_owned = false;
26887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26888         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26889         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
26890         return ret_arr;
26891 }
26892
26893 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
26894         LDKOpenChannel this_ptr_conv;
26895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26896         this_ptr_conv.is_owned = false;
26897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26898         LDKPublicKey val_ref;
26899         CHECK(val->arr_len == 33);
26900         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26901         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
26902 }
26903
26904 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(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_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
26911         return ret_arr;
26912 }
26913
26914 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(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_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26923 }
26924
26925 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_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_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
26932         return ret_arr;
26933 }
26934
26935 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_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_htlc_basepoint(&this_ptr_conv, val_ref);
26944 }
26945
26946 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_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_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
26953         return ret_arr;
26954 }
26955
26956 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) {
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_first_per_commitment_point(&this_ptr_conv, val_ref);
26965 }
26966
26967 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(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_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
26973         return ret_val;
26974 }
26975
26976 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
26977         LDKOpenChannel this_ptr_conv;
26978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26979         this_ptr_conv.is_owned = false;
26980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26981         OpenChannel_set_channel_flags(&this_ptr_conv, val);
26982 }
26983
26984 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
26985         LDKOpenChannel this_ptr_conv;
26986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26987         this_ptr_conv.is_owned = false;
26988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26989         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
26990         uint32_t ret_ref = 0;
26991         if ((uintptr_t)ret_var.inner > 4096) {
26992                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26993                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26995                 ret_ref = (uintptr_t)ret_var.inner;
26996                 if (ret_var.is_owned) {
26997                         ret_ref |= 1;
26998                 }
26999         }
27000         return ret_ref;
27001 }
27002
27003 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
27004         LDKOpenChannel this_ptr_conv;
27005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27006         this_ptr_conv.is_owned = false;
27007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27008         LDKChannelTypeFeatures val_conv;
27009         val_conv.inner = (void*)(val & (~1));
27010         val_conv.is_owned = (val & 1) || (val == 0);
27011         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27012         val_conv = ChannelTypeFeatures_clone(&val_conv);
27013         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
27014 }
27015
27016 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
27017         LDKOpenChannel ret_var = OpenChannel_clone(arg);
27018 uint32_t ret_ref = 0;
27019 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27020 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27021 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27022 ret_ref = (uintptr_t)ret_var.inner;
27023 if (ret_var.is_owned) {
27024         ret_ref |= 1;
27025 }
27026         return ret_ref;
27027 }
27028 uint32_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
27029         LDKOpenChannel arg_conv;
27030         arg_conv.inner = (void*)(arg & (~1));
27031         arg_conv.is_owned = false;
27032         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27033         uint32_t ret_val = OpenChannel_clone_ptr(&arg_conv);
27034         return ret_val;
27035 }
27036
27037 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
27038         LDKOpenChannel orig_conv;
27039         orig_conv.inner = (void*)(orig & (~1));
27040         orig_conv.is_owned = false;
27041         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27042         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
27043         uint32_t ret_ref = 0;
27044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27047         ret_ref = (uintptr_t)ret_var.inner;
27048         if (ret_var.is_owned) {
27049                 ret_ref |= 1;
27050         }
27051         return ret_ref;
27052 }
27053
27054 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
27055         LDKAcceptChannel this_obj_conv;
27056         this_obj_conv.inner = (void*)(this_obj & (~1));
27057         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27059         AcceptChannel_free(this_obj_conv);
27060 }
27061
27062 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
27063         LDKAcceptChannel this_ptr_conv;
27064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27065         this_ptr_conv.is_owned = false;
27066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27067         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27068         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
27069         return ret_arr;
27070 }
27071
27072 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
27073         LDKAcceptChannel this_ptr_conv;
27074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27075         this_ptr_conv.is_owned = false;
27076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27077         LDKThirtyTwoBytes val_ref;
27078         CHECK(val->arr_len == 32);
27079         memcpy(val_ref.data, val->elems, 32); FREE(val);
27080         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
27081 }
27082
27083 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
27084         LDKAcceptChannel this_ptr_conv;
27085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27086         this_ptr_conv.is_owned = false;
27087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27088         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
27089         return ret_val;
27090 }
27091
27092 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
27093         LDKAcceptChannel this_ptr_conv;
27094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27095         this_ptr_conv.is_owned = false;
27096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27097         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
27098 }
27099
27100 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) {
27101         LDKAcceptChannel this_ptr_conv;
27102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27103         this_ptr_conv.is_owned = false;
27104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27105         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
27106         return ret_val;
27107 }
27108
27109 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) {
27110         LDKAcceptChannel this_ptr_conv;
27111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27112         this_ptr_conv.is_owned = false;
27113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27114         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
27115 }
27116
27117 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
27118         LDKAcceptChannel this_ptr_conv;
27119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27120         this_ptr_conv.is_owned = false;
27121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27122         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
27123         return ret_val;
27124 }
27125
27126 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
27127         LDKAcceptChannel this_ptr_conv;
27128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27129         this_ptr_conv.is_owned = false;
27130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27131         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
27132 }
27133
27134 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
27135         LDKAcceptChannel this_ptr_conv;
27136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27137         this_ptr_conv.is_owned = false;
27138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27139         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
27140         return ret_val;
27141 }
27142
27143 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
27144         LDKAcceptChannel this_ptr_conv;
27145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27146         this_ptr_conv.is_owned = false;
27147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27148         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
27149 }
27150
27151 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
27152         LDKAcceptChannel this_ptr_conv;
27153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27154         this_ptr_conv.is_owned = false;
27155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27156         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
27157         return ret_val;
27158 }
27159
27160 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
27161         LDKAcceptChannel this_ptr_conv;
27162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27163         this_ptr_conv.is_owned = false;
27164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27165         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
27166 }
27167
27168 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
27169         LDKAcceptChannel this_ptr_conv;
27170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27171         this_ptr_conv.is_owned = false;
27172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27173         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
27174         return ret_val;
27175 }
27176
27177 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
27178         LDKAcceptChannel this_ptr_conv;
27179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27180         this_ptr_conv.is_owned = false;
27181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27182         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
27183 }
27184
27185 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
27186         LDKAcceptChannel this_ptr_conv;
27187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27188         this_ptr_conv.is_owned = false;
27189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27190         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
27191         return ret_val;
27192 }
27193
27194 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
27195         LDKAcceptChannel this_ptr_conv;
27196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27197         this_ptr_conv.is_owned = false;
27198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27199         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
27200 }
27201
27202 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
27203         LDKAcceptChannel this_ptr_conv;
27204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27205         this_ptr_conv.is_owned = false;
27206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27207         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27208         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
27209         return ret_arr;
27210 }
27211
27212 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
27213         LDKAcceptChannel this_ptr_conv;
27214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27215         this_ptr_conv.is_owned = false;
27216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27217         LDKPublicKey val_ref;
27218         CHECK(val->arr_len == 33);
27219         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27220         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
27221 }
27222
27223 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
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         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27229         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
27230         return ret_arr;
27231 }
27232
27233 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
27234         LDKAcceptChannel this_ptr_conv;
27235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27236         this_ptr_conv.is_owned = false;
27237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27238         LDKPublicKey val_ref;
27239         CHECK(val->arr_len == 33);
27240         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27241         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
27242 }
27243
27244 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
27245         LDKAcceptChannel this_ptr_conv;
27246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27247         this_ptr_conv.is_owned = false;
27248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27249         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27250         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
27251         return ret_arr;
27252 }
27253
27254 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
27255         LDKAcceptChannel this_ptr_conv;
27256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27257         this_ptr_conv.is_owned = false;
27258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27259         LDKPublicKey val_ref;
27260         CHECK(val->arr_len == 33);
27261         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27262         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
27263 }
27264
27265 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(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_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
27272         return ret_arr;
27273 }
27274
27275 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(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_delayed_payment_basepoint(&this_ptr_conv, val_ref);
27284 }
27285
27286 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_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_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
27293         return ret_arr;
27294 }
27295
27296 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_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_htlc_basepoint(&this_ptr_conv, val_ref);
27305 }
27306
27307 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_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_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27314         return ret_arr;
27315 }
27316
27317 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) {
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_first_per_commitment_point(&this_ptr_conv, val_ref);
27326 }
27327
27328 uint32_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(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         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
27334         uint32_t ret_ref = 0;
27335         if ((uintptr_t)ret_var.inner > 4096) {
27336                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27337                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27339                 ret_ref = (uintptr_t)ret_var.inner;
27340                 if (ret_var.is_owned) {
27341                         ret_ref |= 1;
27342                 }
27343         }
27344         return ret_ref;
27345 }
27346
27347 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
27348         LDKAcceptChannel this_ptr_conv;
27349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27350         this_ptr_conv.is_owned = false;
27351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27352         LDKChannelTypeFeatures val_conv;
27353         val_conv.inner = (void*)(val & (~1));
27354         val_conv.is_owned = (val & 1) || (val == 0);
27355         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27356         val_conv = ChannelTypeFeatures_clone(&val_conv);
27357         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
27358 }
27359
27360 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
27361         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
27362 uint32_t ret_ref = 0;
27363 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27364 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27365 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27366 ret_ref = (uintptr_t)ret_var.inner;
27367 if (ret_var.is_owned) {
27368         ret_ref |= 1;
27369 }
27370         return ret_ref;
27371 }
27372 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
27373         LDKAcceptChannel arg_conv;
27374         arg_conv.inner = (void*)(arg & (~1));
27375         arg_conv.is_owned = false;
27376         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27377         uint32_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
27378         return ret_val;
27379 }
27380
27381 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
27382         LDKAcceptChannel orig_conv;
27383         orig_conv.inner = (void*)(orig & (~1));
27384         orig_conv.is_owned = false;
27385         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27386         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
27387         uint32_t ret_ref = 0;
27388         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27389         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27391         ret_ref = (uintptr_t)ret_var.inner;
27392         if (ret_var.is_owned) {
27393                 ret_ref |= 1;
27394         }
27395         return ret_ref;
27396 }
27397
27398 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
27399         LDKFundingCreated this_obj_conv;
27400         this_obj_conv.inner = (void*)(this_obj & (~1));
27401         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27403         FundingCreated_free(this_obj_conv);
27404 }
27405
27406 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
27407         LDKFundingCreated this_ptr_conv;
27408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27409         this_ptr_conv.is_owned = false;
27410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27411         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27412         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
27413         return ret_arr;
27414 }
27415
27416 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
27417         LDKFundingCreated this_ptr_conv;
27418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27419         this_ptr_conv.is_owned = false;
27420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27421         LDKThirtyTwoBytes val_ref;
27422         CHECK(val->arr_len == 32);
27423         memcpy(val_ref.data, val->elems, 32); FREE(val);
27424         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
27425 }
27426
27427 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
27428         LDKFundingCreated this_ptr_conv;
27429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27430         this_ptr_conv.is_owned = false;
27431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27432         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27433         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
27434         return ret_arr;
27435 }
27436
27437 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
27438         LDKFundingCreated this_ptr_conv;
27439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27440         this_ptr_conv.is_owned = false;
27441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27442         LDKThirtyTwoBytes val_ref;
27443         CHECK(val->arr_len == 32);
27444         memcpy(val_ref.data, val->elems, 32); FREE(val);
27445         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
27446 }
27447
27448 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
27449         LDKFundingCreated this_ptr_conv;
27450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27451         this_ptr_conv.is_owned = false;
27452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27453         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
27454         return ret_val;
27455 }
27456
27457 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
27458         LDKFundingCreated this_ptr_conv;
27459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27460         this_ptr_conv.is_owned = false;
27461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27462         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
27463 }
27464
27465 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
27466         LDKFundingCreated this_ptr_conv;
27467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27468         this_ptr_conv.is_owned = false;
27469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27470         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27471         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
27472         return ret_arr;
27473 }
27474
27475 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
27476         LDKFundingCreated this_ptr_conv;
27477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27478         this_ptr_conv.is_owned = false;
27479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27480         LDKSignature val_ref;
27481         CHECK(val->arr_len == 64);
27482         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27483         FundingCreated_set_signature(&this_ptr_conv, val_ref);
27484 }
27485
27486 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) {
27487         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
27488         CHECK(temporary_channel_id_arg->arr_len == 32);
27489         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
27490         LDKThirtyTwoBytes funding_txid_arg_ref;
27491         CHECK(funding_txid_arg->arr_len == 32);
27492         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
27493         LDKSignature signature_arg_ref;
27494         CHECK(signature_arg->arr_len == 64);
27495         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27496         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
27497         uint32_t ret_ref = 0;
27498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27501         ret_ref = (uintptr_t)ret_var.inner;
27502         if (ret_var.is_owned) {
27503                 ret_ref |= 1;
27504         }
27505         return ret_ref;
27506 }
27507
27508 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
27509         LDKFundingCreated ret_var = FundingCreated_clone(arg);
27510 uint32_t ret_ref = 0;
27511 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27512 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27513 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27514 ret_ref = (uintptr_t)ret_var.inner;
27515 if (ret_var.is_owned) {
27516         ret_ref |= 1;
27517 }
27518         return ret_ref;
27519 }
27520 uint32_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
27521         LDKFundingCreated arg_conv;
27522         arg_conv.inner = (void*)(arg & (~1));
27523         arg_conv.is_owned = false;
27524         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27525         uint32_t ret_val = FundingCreated_clone_ptr(&arg_conv);
27526         return ret_val;
27527 }
27528
27529 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
27530         LDKFundingCreated orig_conv;
27531         orig_conv.inner = (void*)(orig & (~1));
27532         orig_conv.is_owned = false;
27533         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27534         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
27535         uint32_t ret_ref = 0;
27536         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27537         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27539         ret_ref = (uintptr_t)ret_var.inner;
27540         if (ret_var.is_owned) {
27541                 ret_ref |= 1;
27542         }
27543         return ret_ref;
27544 }
27545
27546 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
27547         LDKFundingSigned this_obj_conv;
27548         this_obj_conv.inner = (void*)(this_obj & (~1));
27549         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27551         FundingSigned_free(this_obj_conv);
27552 }
27553
27554 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
27555         LDKFundingSigned this_ptr_conv;
27556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27557         this_ptr_conv.is_owned = false;
27558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27559         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27560         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
27561         return ret_arr;
27562 }
27563
27564 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27565         LDKFundingSigned this_ptr_conv;
27566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27567         this_ptr_conv.is_owned = false;
27568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27569         LDKThirtyTwoBytes val_ref;
27570         CHECK(val->arr_len == 32);
27571         memcpy(val_ref.data, val->elems, 32); FREE(val);
27572         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
27573 }
27574
27575 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
27576         LDKFundingSigned this_ptr_conv;
27577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27578         this_ptr_conv.is_owned = false;
27579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27580         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27581         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
27582         return ret_arr;
27583 }
27584
27585 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
27586         LDKFundingSigned this_ptr_conv;
27587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27588         this_ptr_conv.is_owned = false;
27589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27590         LDKSignature val_ref;
27591         CHECK(val->arr_len == 64);
27592         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27593         FundingSigned_set_signature(&this_ptr_conv, val_ref);
27594 }
27595
27596 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
27597         LDKThirtyTwoBytes channel_id_arg_ref;
27598         CHECK(channel_id_arg->arr_len == 32);
27599         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27600         LDKSignature signature_arg_ref;
27601         CHECK(signature_arg->arr_len == 64);
27602         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27603         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
27604         uint32_t ret_ref = 0;
27605         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27606         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27608         ret_ref = (uintptr_t)ret_var.inner;
27609         if (ret_var.is_owned) {
27610                 ret_ref |= 1;
27611         }
27612         return ret_ref;
27613 }
27614
27615 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
27616         LDKFundingSigned ret_var = FundingSigned_clone(arg);
27617 uint32_t ret_ref = 0;
27618 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27619 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27620 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27621 ret_ref = (uintptr_t)ret_var.inner;
27622 if (ret_var.is_owned) {
27623         ret_ref |= 1;
27624 }
27625         return ret_ref;
27626 }
27627 uint32_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
27628         LDKFundingSigned arg_conv;
27629         arg_conv.inner = (void*)(arg & (~1));
27630         arg_conv.is_owned = false;
27631         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27632         uint32_t ret_val = FundingSigned_clone_ptr(&arg_conv);
27633         return ret_val;
27634 }
27635
27636 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
27637         LDKFundingSigned orig_conv;
27638         orig_conv.inner = (void*)(orig & (~1));
27639         orig_conv.is_owned = false;
27640         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27641         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
27642         uint32_t ret_ref = 0;
27643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27646         ret_ref = (uintptr_t)ret_var.inner;
27647         if (ret_var.is_owned) {
27648                 ret_ref |= 1;
27649         }
27650         return ret_ref;
27651 }
27652
27653 void  __attribute__((export_name("TS_FundingLocked_free"))) TS_FundingLocked_free(uint32_t this_obj) {
27654         LDKFundingLocked this_obj_conv;
27655         this_obj_conv.inner = (void*)(this_obj & (~1));
27656         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27658         FundingLocked_free(this_obj_conv);
27659 }
27660
27661 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_channel_id"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
27662         LDKFundingLocked this_ptr_conv;
27663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27664         this_ptr_conv.is_owned = false;
27665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27666         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27667         memcpy(ret_arr->elems, *FundingLocked_get_channel_id(&this_ptr_conv), 32);
27668         return ret_arr;
27669 }
27670
27671 void  __attribute__((export_name("TS_FundingLocked_set_channel_id"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27672         LDKFundingLocked this_ptr_conv;
27673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27674         this_ptr_conv.is_owned = false;
27675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27676         LDKThirtyTwoBytes val_ref;
27677         CHECK(val->arr_len == 32);
27678         memcpy(val_ref.data, val->elems, 32); FREE(val);
27679         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
27680 }
27681
27682 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_next_per_commitment_point"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
27683         LDKFundingLocked this_ptr_conv;
27684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27685         this_ptr_conv.is_owned = false;
27686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27687         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27688         memcpy(ret_arr->elems, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27689         return ret_arr;
27690 }
27691
27692 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) {
27693         LDKFundingLocked this_ptr_conv;
27694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27695         this_ptr_conv.is_owned = false;
27696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27697         LDKPublicKey val_ref;
27698         CHECK(val->arr_len == 33);
27699         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27700         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
27701 }
27702
27703 uint32_t  __attribute__((export_name("TS_FundingLocked_get_short_channel_id_alias"))) TS_FundingLocked_get_short_channel_id_alias(uint32_t this_ptr) {
27704         LDKFundingLocked this_ptr_conv;
27705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27706         this_ptr_conv.is_owned = false;
27707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27708         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27709         *ret_copy = FundingLocked_get_short_channel_id_alias(&this_ptr_conv);
27710         uint32_t ret_ref = (uintptr_t)ret_copy;
27711         return ret_ref;
27712 }
27713
27714 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) {
27715         LDKFundingLocked this_ptr_conv;
27716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27717         this_ptr_conv.is_owned = false;
27718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27719         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27720         CHECK_ACCESS(val_ptr);
27721         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
27722         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
27723         FundingLocked_set_short_channel_id_alias(&this_ptr_conv, val_conv);
27724 }
27725
27726 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) {
27727         LDKThirtyTwoBytes channel_id_arg_ref;
27728         CHECK(channel_id_arg->arr_len == 32);
27729         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27730         LDKPublicKey next_per_commitment_point_arg_ref;
27731         CHECK(next_per_commitment_point_arg->arr_len == 33);
27732         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
27733         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
27734         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
27735         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
27736         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
27737         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
27738         uint32_t ret_ref = 0;
27739         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27740         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27742         ret_ref = (uintptr_t)ret_var.inner;
27743         if (ret_var.is_owned) {
27744                 ret_ref |= 1;
27745         }
27746         return ret_ref;
27747 }
27748
27749 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
27750         LDKFundingLocked ret_var = FundingLocked_clone(arg);
27751 uint32_t ret_ref = 0;
27752 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27753 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27754 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27755 ret_ref = (uintptr_t)ret_var.inner;
27756 if (ret_var.is_owned) {
27757         ret_ref |= 1;
27758 }
27759         return ret_ref;
27760 }
27761 uint32_t  __attribute__((export_name("TS_FundingLocked_clone_ptr"))) TS_FundingLocked_clone_ptr(uint32_t arg) {
27762         LDKFundingLocked arg_conv;
27763         arg_conv.inner = (void*)(arg & (~1));
27764         arg_conv.is_owned = false;
27765         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27766         uint32_t ret_val = FundingLocked_clone_ptr(&arg_conv);
27767         return ret_val;
27768 }
27769
27770 uint32_t  __attribute__((export_name("TS_FundingLocked_clone"))) TS_FundingLocked_clone(uint32_t orig) {
27771         LDKFundingLocked orig_conv;
27772         orig_conv.inner = (void*)(orig & (~1));
27773         orig_conv.is_owned = false;
27774         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27775         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
27776         uint32_t ret_ref = 0;
27777         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27778         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27780         ret_ref = (uintptr_t)ret_var.inner;
27781         if (ret_var.is_owned) {
27782                 ret_ref |= 1;
27783         }
27784         return ret_ref;
27785 }
27786
27787 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
27788         LDKShutdown this_obj_conv;
27789         this_obj_conv.inner = (void*)(this_obj & (~1));
27790         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27792         Shutdown_free(this_obj_conv);
27793 }
27794
27795 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
27796         LDKShutdown this_ptr_conv;
27797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27798         this_ptr_conv.is_owned = false;
27799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27800         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27801         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
27802         return ret_arr;
27803 }
27804
27805 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27806         LDKShutdown this_ptr_conv;
27807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27808         this_ptr_conv.is_owned = false;
27809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27810         LDKThirtyTwoBytes val_ref;
27811         CHECK(val->arr_len == 32);
27812         memcpy(val_ref.data, val->elems, 32); FREE(val);
27813         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
27814 }
27815
27816 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
27817         LDKShutdown this_ptr_conv;
27818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27819         this_ptr_conv.is_owned = false;
27820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27821         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
27822         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27823         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27824         return ret_arr;
27825 }
27826
27827 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
27828         LDKShutdown this_ptr_conv;
27829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27830         this_ptr_conv.is_owned = false;
27831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27832         LDKCVec_u8Z val_ref;
27833         val_ref.datalen = val->arr_len;
27834         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
27835         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
27836         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
27837 }
27838
27839 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
27840         LDKThirtyTwoBytes channel_id_arg_ref;
27841         CHECK(channel_id_arg->arr_len == 32);
27842         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27843         LDKCVec_u8Z scriptpubkey_arg_ref;
27844         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
27845         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
27846         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
27847         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
27848         uint32_t ret_ref = 0;
27849         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27850         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27852         ret_ref = (uintptr_t)ret_var.inner;
27853         if (ret_var.is_owned) {
27854                 ret_ref |= 1;
27855         }
27856         return ret_ref;
27857 }
27858
27859 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
27860         LDKShutdown ret_var = Shutdown_clone(arg);
27861 uint32_t ret_ref = 0;
27862 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27863 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27864 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27865 ret_ref = (uintptr_t)ret_var.inner;
27866 if (ret_var.is_owned) {
27867         ret_ref |= 1;
27868 }
27869         return ret_ref;
27870 }
27871 uint32_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
27872         LDKShutdown arg_conv;
27873         arg_conv.inner = (void*)(arg & (~1));
27874         arg_conv.is_owned = false;
27875         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27876         uint32_t ret_val = Shutdown_clone_ptr(&arg_conv);
27877         return ret_val;
27878 }
27879
27880 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
27881         LDKShutdown orig_conv;
27882         orig_conv.inner = (void*)(orig & (~1));
27883         orig_conv.is_owned = false;
27884         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27885         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
27886         uint32_t ret_ref = 0;
27887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27890         ret_ref = (uintptr_t)ret_var.inner;
27891         if (ret_var.is_owned) {
27892                 ret_ref |= 1;
27893         }
27894         return ret_ref;
27895 }
27896
27897 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
27898         LDKClosingSignedFeeRange this_obj_conv;
27899         this_obj_conv.inner = (void*)(this_obj & (~1));
27900         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27902         ClosingSignedFeeRange_free(this_obj_conv);
27903 }
27904
27905 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
27906         LDKClosingSignedFeeRange this_ptr_conv;
27907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27908         this_ptr_conv.is_owned = false;
27909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27910         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
27911         return ret_val;
27912 }
27913
27914 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
27915         LDKClosingSignedFeeRange this_ptr_conv;
27916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27917         this_ptr_conv.is_owned = false;
27918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27919         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
27920 }
27921
27922 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
27923         LDKClosingSignedFeeRange this_ptr_conv;
27924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27925         this_ptr_conv.is_owned = false;
27926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27927         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
27928         return ret_val;
27929 }
27930
27931 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
27932         LDKClosingSignedFeeRange this_ptr_conv;
27933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27934         this_ptr_conv.is_owned = false;
27935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27936         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
27937 }
27938
27939 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
27940         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
27941         uint32_t ret_ref = 0;
27942         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27943         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27945         ret_ref = (uintptr_t)ret_var.inner;
27946         if (ret_var.is_owned) {
27947                 ret_ref |= 1;
27948         }
27949         return ret_ref;
27950 }
27951
27952 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
27953         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
27954 uint32_t ret_ref = 0;
27955 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27956 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27957 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27958 ret_ref = (uintptr_t)ret_var.inner;
27959 if (ret_var.is_owned) {
27960         ret_ref |= 1;
27961 }
27962         return ret_ref;
27963 }
27964 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
27965         LDKClosingSignedFeeRange arg_conv;
27966         arg_conv.inner = (void*)(arg & (~1));
27967         arg_conv.is_owned = false;
27968         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27969         uint32_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
27970         return ret_val;
27971 }
27972
27973 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
27974         LDKClosingSignedFeeRange orig_conv;
27975         orig_conv.inner = (void*)(orig & (~1));
27976         orig_conv.is_owned = false;
27977         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27978         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
27979         uint32_t ret_ref = 0;
27980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27983         ret_ref = (uintptr_t)ret_var.inner;
27984         if (ret_var.is_owned) {
27985                 ret_ref |= 1;
27986         }
27987         return ret_ref;
27988 }
27989
27990 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
27991         LDKClosingSigned this_obj_conv;
27992         this_obj_conv.inner = (void*)(this_obj & (~1));
27993         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27995         ClosingSigned_free(this_obj_conv);
27996 }
27997
27998 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
27999         LDKClosingSigned this_ptr_conv;
28000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28001         this_ptr_conv.is_owned = false;
28002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28003         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28004         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
28005         return ret_arr;
28006 }
28007
28008 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28009         LDKClosingSigned this_ptr_conv;
28010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28011         this_ptr_conv.is_owned = false;
28012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28013         LDKThirtyTwoBytes val_ref;
28014         CHECK(val->arr_len == 32);
28015         memcpy(val_ref.data, val->elems, 32); FREE(val);
28016         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
28017 }
28018
28019 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
28020         LDKClosingSigned this_ptr_conv;
28021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28022         this_ptr_conv.is_owned = false;
28023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28024         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
28025         return ret_val;
28026 }
28027
28028 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
28029         LDKClosingSigned this_ptr_conv;
28030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28031         this_ptr_conv.is_owned = false;
28032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28033         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
28034 }
28035
28036 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
28037         LDKClosingSigned this_ptr_conv;
28038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28039         this_ptr_conv.is_owned = false;
28040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28041         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28042         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
28043         return ret_arr;
28044 }
28045
28046 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28047         LDKClosingSigned this_ptr_conv;
28048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28049         this_ptr_conv.is_owned = false;
28050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28051         LDKSignature val_ref;
28052         CHECK(val->arr_len == 64);
28053         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28054         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
28055 }
28056
28057 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
28058         LDKClosingSigned this_ptr_conv;
28059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28060         this_ptr_conv.is_owned = false;
28061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28062         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
28063         uint32_t ret_ref = 0;
28064         if ((uintptr_t)ret_var.inner > 4096) {
28065                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28066                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28068                 ret_ref = (uintptr_t)ret_var.inner;
28069                 if (ret_var.is_owned) {
28070                         ret_ref |= 1;
28071                 }
28072         }
28073         return ret_ref;
28074 }
28075
28076 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
28077         LDKClosingSigned this_ptr_conv;
28078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28079         this_ptr_conv.is_owned = false;
28080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28081         LDKClosingSignedFeeRange val_conv;
28082         val_conv.inner = (void*)(val & (~1));
28083         val_conv.is_owned = (val & 1) || (val == 0);
28084         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28085         val_conv = ClosingSignedFeeRange_clone(&val_conv);
28086         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
28087 }
28088
28089 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) {
28090         LDKThirtyTwoBytes channel_id_arg_ref;
28091         CHECK(channel_id_arg->arr_len == 32);
28092         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28093         LDKSignature signature_arg_ref;
28094         CHECK(signature_arg->arr_len == 64);
28095         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28096         LDKClosingSignedFeeRange fee_range_arg_conv;
28097         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
28098         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
28099         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
28100         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
28101         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
28102         uint32_t ret_ref = 0;
28103         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28104         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28106         ret_ref = (uintptr_t)ret_var.inner;
28107         if (ret_var.is_owned) {
28108                 ret_ref |= 1;
28109         }
28110         return ret_ref;
28111 }
28112
28113 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
28114         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
28115 uint32_t ret_ref = 0;
28116 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28117 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28118 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28119 ret_ref = (uintptr_t)ret_var.inner;
28120 if (ret_var.is_owned) {
28121         ret_ref |= 1;
28122 }
28123         return ret_ref;
28124 }
28125 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
28126         LDKClosingSigned arg_conv;
28127         arg_conv.inner = (void*)(arg & (~1));
28128         arg_conv.is_owned = false;
28129         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28130         uint32_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
28131         return ret_val;
28132 }
28133
28134 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
28135         LDKClosingSigned orig_conv;
28136         orig_conv.inner = (void*)(orig & (~1));
28137         orig_conv.is_owned = false;
28138         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28139         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
28140         uint32_t ret_ref = 0;
28141         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28142         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28144         ret_ref = (uintptr_t)ret_var.inner;
28145         if (ret_var.is_owned) {
28146                 ret_ref |= 1;
28147         }
28148         return ret_ref;
28149 }
28150
28151 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
28152         LDKUpdateAddHTLC this_obj_conv;
28153         this_obj_conv.inner = (void*)(this_obj & (~1));
28154         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28156         UpdateAddHTLC_free(this_obj_conv);
28157 }
28158
28159 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
28160         LDKUpdateAddHTLC this_ptr_conv;
28161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28162         this_ptr_conv.is_owned = false;
28163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28164         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28165         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
28166         return ret_arr;
28167 }
28168
28169 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28170         LDKUpdateAddHTLC this_ptr_conv;
28171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28172         this_ptr_conv.is_owned = false;
28173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28174         LDKThirtyTwoBytes val_ref;
28175         CHECK(val->arr_len == 32);
28176         memcpy(val_ref.data, val->elems, 32); FREE(val);
28177         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
28178 }
28179
28180 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
28181         LDKUpdateAddHTLC this_ptr_conv;
28182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28183         this_ptr_conv.is_owned = false;
28184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28185         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
28186         return ret_val;
28187 }
28188
28189 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28190         LDKUpdateAddHTLC this_ptr_conv;
28191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28192         this_ptr_conv.is_owned = false;
28193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28194         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
28195 }
28196
28197 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
28198         LDKUpdateAddHTLC this_ptr_conv;
28199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28200         this_ptr_conv.is_owned = false;
28201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28202         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
28203         return ret_val;
28204 }
28205
28206 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
28207         LDKUpdateAddHTLC this_ptr_conv;
28208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28209         this_ptr_conv.is_owned = false;
28210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28211         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
28212 }
28213
28214 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
28215         LDKUpdateAddHTLC this_ptr_conv;
28216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28217         this_ptr_conv.is_owned = false;
28218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28219         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28220         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
28221         return ret_arr;
28222 }
28223
28224 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
28225         LDKUpdateAddHTLC this_ptr_conv;
28226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28227         this_ptr_conv.is_owned = false;
28228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28229         LDKThirtyTwoBytes val_ref;
28230         CHECK(val->arr_len == 32);
28231         memcpy(val_ref.data, val->elems, 32); FREE(val);
28232         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
28233 }
28234
28235 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
28236         LDKUpdateAddHTLC this_ptr_conv;
28237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28238         this_ptr_conv.is_owned = false;
28239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28240         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
28241         return ret_val;
28242 }
28243
28244 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
28245         LDKUpdateAddHTLC this_ptr_conv;
28246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28247         this_ptr_conv.is_owned = false;
28248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28249         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
28250 }
28251
28252 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
28253         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
28254 uint32_t ret_ref = 0;
28255 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28256 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28257 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28258 ret_ref = (uintptr_t)ret_var.inner;
28259 if (ret_var.is_owned) {
28260         ret_ref |= 1;
28261 }
28262         return ret_ref;
28263 }
28264 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
28265         LDKUpdateAddHTLC arg_conv;
28266         arg_conv.inner = (void*)(arg & (~1));
28267         arg_conv.is_owned = false;
28268         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28269         uint32_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
28270         return ret_val;
28271 }
28272
28273 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
28274         LDKUpdateAddHTLC orig_conv;
28275         orig_conv.inner = (void*)(orig & (~1));
28276         orig_conv.is_owned = false;
28277         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28278         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
28279         uint32_t ret_ref = 0;
28280         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28281         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28283         ret_ref = (uintptr_t)ret_var.inner;
28284         if (ret_var.is_owned) {
28285                 ret_ref |= 1;
28286         }
28287         return ret_ref;
28288 }
28289
28290 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
28291         LDKUpdateFulfillHTLC this_obj_conv;
28292         this_obj_conv.inner = (void*)(this_obj & (~1));
28293         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28295         UpdateFulfillHTLC_free(this_obj_conv);
28296 }
28297
28298 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
28299         LDKUpdateFulfillHTLC 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         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28304         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
28305         return ret_arr;
28306 }
28307
28308 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28309         LDKUpdateFulfillHTLC this_ptr_conv;
28310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28311         this_ptr_conv.is_owned = false;
28312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28313         LDKThirtyTwoBytes val_ref;
28314         CHECK(val->arr_len == 32);
28315         memcpy(val_ref.data, val->elems, 32); FREE(val);
28316         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
28317 }
28318
28319 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
28320         LDKUpdateFulfillHTLC this_ptr_conv;
28321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28322         this_ptr_conv.is_owned = false;
28323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28324         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
28325         return ret_val;
28326 }
28327
28328 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28329         LDKUpdateFulfillHTLC this_ptr_conv;
28330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28331         this_ptr_conv.is_owned = false;
28332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28333         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
28334 }
28335
28336 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
28337         LDKUpdateFulfillHTLC this_ptr_conv;
28338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28339         this_ptr_conv.is_owned = false;
28340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28341         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28342         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
28343         return ret_arr;
28344 }
28345
28346 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
28347         LDKUpdateFulfillHTLC this_ptr_conv;
28348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28349         this_ptr_conv.is_owned = false;
28350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28351         LDKThirtyTwoBytes val_ref;
28352         CHECK(val->arr_len == 32);
28353         memcpy(val_ref.data, val->elems, 32); FREE(val);
28354         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
28355 }
28356
28357 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) {
28358         LDKThirtyTwoBytes channel_id_arg_ref;
28359         CHECK(channel_id_arg->arr_len == 32);
28360         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28361         LDKThirtyTwoBytes payment_preimage_arg_ref;
28362         CHECK(payment_preimage_arg->arr_len == 32);
28363         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
28364         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
28365         uint32_t ret_ref = 0;
28366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28369         ret_ref = (uintptr_t)ret_var.inner;
28370         if (ret_var.is_owned) {
28371                 ret_ref |= 1;
28372         }
28373         return ret_ref;
28374 }
28375
28376 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
28377         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
28378 uint32_t ret_ref = 0;
28379 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28380 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28381 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28382 ret_ref = (uintptr_t)ret_var.inner;
28383 if (ret_var.is_owned) {
28384         ret_ref |= 1;
28385 }
28386         return ret_ref;
28387 }
28388 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
28389         LDKUpdateFulfillHTLC arg_conv;
28390         arg_conv.inner = (void*)(arg & (~1));
28391         arg_conv.is_owned = false;
28392         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28393         uint32_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
28394         return ret_val;
28395 }
28396
28397 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
28398         LDKUpdateFulfillHTLC orig_conv;
28399         orig_conv.inner = (void*)(orig & (~1));
28400         orig_conv.is_owned = false;
28401         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28402         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
28403         uint32_t ret_ref = 0;
28404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28407         ret_ref = (uintptr_t)ret_var.inner;
28408         if (ret_var.is_owned) {
28409                 ret_ref |= 1;
28410         }
28411         return ret_ref;
28412 }
28413
28414 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
28415         LDKUpdateFailHTLC this_obj_conv;
28416         this_obj_conv.inner = (void*)(this_obj & (~1));
28417         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28419         UpdateFailHTLC_free(this_obj_conv);
28420 }
28421
28422 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
28423         LDKUpdateFailHTLC this_ptr_conv;
28424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28425         this_ptr_conv.is_owned = false;
28426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28427         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28428         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
28429         return ret_arr;
28430 }
28431
28432 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28433         LDKUpdateFailHTLC this_ptr_conv;
28434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28435         this_ptr_conv.is_owned = false;
28436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28437         LDKThirtyTwoBytes val_ref;
28438         CHECK(val->arr_len == 32);
28439         memcpy(val_ref.data, val->elems, 32); FREE(val);
28440         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
28441 }
28442
28443 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
28444         LDKUpdateFailHTLC this_ptr_conv;
28445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28446         this_ptr_conv.is_owned = false;
28447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28448         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
28449         return ret_val;
28450 }
28451
28452 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28453         LDKUpdateFailHTLC this_ptr_conv;
28454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28455         this_ptr_conv.is_owned = false;
28456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28457         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
28458 }
28459
28460 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
28461         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
28462 uint32_t ret_ref = 0;
28463 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28464 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28465 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28466 ret_ref = (uintptr_t)ret_var.inner;
28467 if (ret_var.is_owned) {
28468         ret_ref |= 1;
28469 }
28470         return ret_ref;
28471 }
28472 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
28473         LDKUpdateFailHTLC arg_conv;
28474         arg_conv.inner = (void*)(arg & (~1));
28475         arg_conv.is_owned = false;
28476         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28477         uint32_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
28478         return ret_val;
28479 }
28480
28481 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
28482         LDKUpdateFailHTLC orig_conv;
28483         orig_conv.inner = (void*)(orig & (~1));
28484         orig_conv.is_owned = false;
28485         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28486         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
28487         uint32_t ret_ref = 0;
28488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28491         ret_ref = (uintptr_t)ret_var.inner;
28492         if (ret_var.is_owned) {
28493                 ret_ref |= 1;
28494         }
28495         return ret_ref;
28496 }
28497
28498 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
28499         LDKUpdateFailMalformedHTLC this_obj_conv;
28500         this_obj_conv.inner = (void*)(this_obj & (~1));
28501         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28503         UpdateFailMalformedHTLC_free(this_obj_conv);
28504 }
28505
28506 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
28507         LDKUpdateFailMalformedHTLC 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         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28512         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
28513         return ret_arr;
28514 }
28515
28516 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28517         LDKUpdateFailMalformedHTLC this_ptr_conv;
28518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28519         this_ptr_conv.is_owned = false;
28520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28521         LDKThirtyTwoBytes val_ref;
28522         CHECK(val->arr_len == 32);
28523         memcpy(val_ref.data, val->elems, 32); FREE(val);
28524         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
28525 }
28526
28527 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
28528         LDKUpdateFailMalformedHTLC this_ptr_conv;
28529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28530         this_ptr_conv.is_owned = false;
28531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28532         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
28533         return ret_val;
28534 }
28535
28536 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28537         LDKUpdateFailMalformedHTLC this_ptr_conv;
28538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28539         this_ptr_conv.is_owned = false;
28540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28541         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
28542 }
28543
28544 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
28545         LDKUpdateFailMalformedHTLC this_ptr_conv;
28546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28547         this_ptr_conv.is_owned = false;
28548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28549         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
28550         return ret_val;
28551 }
28552
28553 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
28554         LDKUpdateFailMalformedHTLC this_ptr_conv;
28555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28556         this_ptr_conv.is_owned = false;
28557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28558         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
28559 }
28560
28561 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
28562         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
28563 uint32_t ret_ref = 0;
28564 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28565 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28566 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28567 ret_ref = (uintptr_t)ret_var.inner;
28568 if (ret_var.is_owned) {
28569         ret_ref |= 1;
28570 }
28571         return ret_ref;
28572 }
28573 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
28574         LDKUpdateFailMalformedHTLC arg_conv;
28575         arg_conv.inner = (void*)(arg & (~1));
28576         arg_conv.is_owned = false;
28577         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28578         uint32_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
28579         return ret_val;
28580 }
28581
28582 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
28583         LDKUpdateFailMalformedHTLC orig_conv;
28584         orig_conv.inner = (void*)(orig & (~1));
28585         orig_conv.is_owned = false;
28586         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28587         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
28588         uint32_t ret_ref = 0;
28589         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28590         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28592         ret_ref = (uintptr_t)ret_var.inner;
28593         if (ret_var.is_owned) {
28594                 ret_ref |= 1;
28595         }
28596         return ret_ref;
28597 }
28598
28599 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
28600         LDKCommitmentSigned this_obj_conv;
28601         this_obj_conv.inner = (void*)(this_obj & (~1));
28602         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28604         CommitmentSigned_free(this_obj_conv);
28605 }
28606
28607 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
28608         LDKCommitmentSigned 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         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28613         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
28614         return ret_arr;
28615 }
28616
28617 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28618         LDKCommitmentSigned this_ptr_conv;
28619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28620         this_ptr_conv.is_owned = false;
28621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28622         LDKThirtyTwoBytes val_ref;
28623         CHECK(val->arr_len == 32);
28624         memcpy(val_ref.data, val->elems, 32); FREE(val);
28625         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
28626 }
28627
28628 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
28629         LDKCommitmentSigned this_ptr_conv;
28630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28631         this_ptr_conv.is_owned = false;
28632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28633         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28634         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
28635         return ret_arr;
28636 }
28637
28638 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28639         LDKCommitmentSigned this_ptr_conv;
28640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28641         this_ptr_conv.is_owned = false;
28642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28643         LDKSignature val_ref;
28644         CHECK(val->arr_len == 64);
28645         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28646         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
28647 }
28648
28649 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
28650         LDKCommitmentSigned this_ptr_conv;
28651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28652         this_ptr_conv.is_owned = false;
28653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28654         LDKCVec_SignatureZ val_constr;
28655         val_constr.datalen = val->arr_len;
28656         if (val_constr.datalen > 0)
28657                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28658         else
28659                 val_constr.data = NULL;
28660         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
28661         for (size_t m = 0; m < val_constr.datalen; m++) {
28662                 int8_tArray val_conv_12 = val_vals[m];
28663                 LDKSignature val_conv_12_ref;
28664                 CHECK(val_conv_12->arr_len == 64);
28665                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
28666                 val_constr.data[m] = val_conv_12_ref;
28667         }
28668         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
28669 }
28670
28671 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
28672         LDKThirtyTwoBytes channel_id_arg_ref;
28673         CHECK(channel_id_arg->arr_len == 32);
28674         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28675         LDKSignature signature_arg_ref;
28676         CHECK(signature_arg->arr_len == 64);
28677         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28678         LDKCVec_SignatureZ htlc_signatures_arg_constr;
28679         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
28680         if (htlc_signatures_arg_constr.datalen > 0)
28681                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28682         else
28683                 htlc_signatures_arg_constr.data = NULL;
28684         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems /* XXX htlc_signatures_arg leaks */;
28685         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
28686                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
28687                 LDKSignature htlc_signatures_arg_conv_12_ref;
28688                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
28689                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
28690                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
28691         }
28692         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
28693         uint32_t ret_ref = 0;
28694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28697         ret_ref = (uintptr_t)ret_var.inner;
28698         if (ret_var.is_owned) {
28699                 ret_ref |= 1;
28700         }
28701         return ret_ref;
28702 }
28703
28704 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
28705         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
28706 uint32_t ret_ref = 0;
28707 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28708 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28709 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28710 ret_ref = (uintptr_t)ret_var.inner;
28711 if (ret_var.is_owned) {
28712         ret_ref |= 1;
28713 }
28714         return ret_ref;
28715 }
28716 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
28717         LDKCommitmentSigned arg_conv;
28718         arg_conv.inner = (void*)(arg & (~1));
28719         arg_conv.is_owned = false;
28720         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28721         uint32_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
28722         return ret_val;
28723 }
28724
28725 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
28726         LDKCommitmentSigned orig_conv;
28727         orig_conv.inner = (void*)(orig & (~1));
28728         orig_conv.is_owned = false;
28729         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28730         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
28731         uint32_t ret_ref = 0;
28732         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28733         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28735         ret_ref = (uintptr_t)ret_var.inner;
28736         if (ret_var.is_owned) {
28737                 ret_ref |= 1;
28738         }
28739         return ret_ref;
28740 }
28741
28742 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
28743         LDKRevokeAndACK this_obj_conv;
28744         this_obj_conv.inner = (void*)(this_obj & (~1));
28745         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28747         RevokeAndACK_free(this_obj_conv);
28748 }
28749
28750 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
28751         LDKRevokeAndACK this_ptr_conv;
28752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28753         this_ptr_conv.is_owned = false;
28754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28755         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28756         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
28757         return ret_arr;
28758 }
28759
28760 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28761         LDKRevokeAndACK this_ptr_conv;
28762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28763         this_ptr_conv.is_owned = false;
28764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28765         LDKThirtyTwoBytes val_ref;
28766         CHECK(val->arr_len == 32);
28767         memcpy(val_ref.data, val->elems, 32); FREE(val);
28768         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
28769 }
28770
28771 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
28772         LDKRevokeAndACK this_ptr_conv;
28773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28774         this_ptr_conv.is_owned = false;
28775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28776         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28777         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
28778         return ret_arr;
28779 }
28780
28781 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
28782         LDKRevokeAndACK this_ptr_conv;
28783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28784         this_ptr_conv.is_owned = false;
28785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28786         LDKThirtyTwoBytes val_ref;
28787         CHECK(val->arr_len == 32);
28788         memcpy(val_ref.data, val->elems, 32); FREE(val);
28789         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
28790 }
28791
28792 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
28793         LDKRevokeAndACK this_ptr_conv;
28794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28795         this_ptr_conv.is_owned = false;
28796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28797         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28798         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28799         return ret_arr;
28800 }
28801
28802 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) {
28803         LDKRevokeAndACK this_ptr_conv;
28804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28805         this_ptr_conv.is_owned = false;
28806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28807         LDKPublicKey val_ref;
28808         CHECK(val->arr_len == 33);
28809         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28810         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
28811 }
28812
28813 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) {
28814         LDKThirtyTwoBytes channel_id_arg_ref;
28815         CHECK(channel_id_arg->arr_len == 32);
28816         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28817         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
28818         CHECK(per_commitment_secret_arg->arr_len == 32);
28819         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
28820         LDKPublicKey next_per_commitment_point_arg_ref;
28821         CHECK(next_per_commitment_point_arg->arr_len == 33);
28822         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
28823         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
28824         uint32_t ret_ref = 0;
28825         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28826         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28828         ret_ref = (uintptr_t)ret_var.inner;
28829         if (ret_var.is_owned) {
28830                 ret_ref |= 1;
28831         }
28832         return ret_ref;
28833 }
28834
28835 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
28836         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
28837 uint32_t ret_ref = 0;
28838 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28839 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28840 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28841 ret_ref = (uintptr_t)ret_var.inner;
28842 if (ret_var.is_owned) {
28843         ret_ref |= 1;
28844 }
28845         return ret_ref;
28846 }
28847 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
28848         LDKRevokeAndACK arg_conv;
28849         arg_conv.inner = (void*)(arg & (~1));
28850         arg_conv.is_owned = false;
28851         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28852         uint32_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
28853         return ret_val;
28854 }
28855
28856 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
28857         LDKRevokeAndACK orig_conv;
28858         orig_conv.inner = (void*)(orig & (~1));
28859         orig_conv.is_owned = false;
28860         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28861         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
28862         uint32_t ret_ref = 0;
28863         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28864         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28866         ret_ref = (uintptr_t)ret_var.inner;
28867         if (ret_var.is_owned) {
28868                 ret_ref |= 1;
28869         }
28870         return ret_ref;
28871 }
28872
28873 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
28874         LDKUpdateFee this_obj_conv;
28875         this_obj_conv.inner = (void*)(this_obj & (~1));
28876         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28878         UpdateFee_free(this_obj_conv);
28879 }
28880
28881 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
28882         LDKUpdateFee this_ptr_conv;
28883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28884         this_ptr_conv.is_owned = false;
28885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28886         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28887         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
28888         return ret_arr;
28889 }
28890
28891 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28892         LDKUpdateFee this_ptr_conv;
28893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28894         this_ptr_conv.is_owned = false;
28895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28896         LDKThirtyTwoBytes val_ref;
28897         CHECK(val->arr_len == 32);
28898         memcpy(val_ref.data, val->elems, 32); FREE(val);
28899         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
28900 }
28901
28902 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
28903         LDKUpdateFee this_ptr_conv;
28904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28905         this_ptr_conv.is_owned = false;
28906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28907         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
28908         return ret_val;
28909 }
28910
28911 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
28912         LDKUpdateFee this_ptr_conv;
28913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28914         this_ptr_conv.is_owned = false;
28915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28916         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
28917 }
28918
28919 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
28920         LDKThirtyTwoBytes channel_id_arg_ref;
28921         CHECK(channel_id_arg->arr_len == 32);
28922         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28923         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
28924         uint32_t ret_ref = 0;
28925         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28926         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28928         ret_ref = (uintptr_t)ret_var.inner;
28929         if (ret_var.is_owned) {
28930                 ret_ref |= 1;
28931         }
28932         return ret_ref;
28933 }
28934
28935 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
28936         LDKUpdateFee ret_var = UpdateFee_clone(arg);
28937 uint32_t ret_ref = 0;
28938 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28939 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28940 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28941 ret_ref = (uintptr_t)ret_var.inner;
28942 if (ret_var.is_owned) {
28943         ret_ref |= 1;
28944 }
28945         return ret_ref;
28946 }
28947 uint32_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
28948         LDKUpdateFee arg_conv;
28949         arg_conv.inner = (void*)(arg & (~1));
28950         arg_conv.is_owned = false;
28951         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28952         uint32_t ret_val = UpdateFee_clone_ptr(&arg_conv);
28953         return ret_val;
28954 }
28955
28956 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
28957         LDKUpdateFee orig_conv;
28958         orig_conv.inner = (void*)(orig & (~1));
28959         orig_conv.is_owned = false;
28960         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28961         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
28962         uint32_t ret_ref = 0;
28963         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28964         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28966         ret_ref = (uintptr_t)ret_var.inner;
28967         if (ret_var.is_owned) {
28968                 ret_ref |= 1;
28969         }
28970         return ret_ref;
28971 }
28972
28973 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
28974         LDKDataLossProtect this_obj_conv;
28975         this_obj_conv.inner = (void*)(this_obj & (~1));
28976         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28978         DataLossProtect_free(this_obj_conv);
28979 }
28980
28981 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) {
28982         LDKDataLossProtect this_ptr_conv;
28983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28984         this_ptr_conv.is_owned = false;
28985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28986         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28987         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
28988         return ret_arr;
28989 }
28990
28991 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) {
28992         LDKDataLossProtect this_ptr_conv;
28993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28994         this_ptr_conv.is_owned = false;
28995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28996         LDKThirtyTwoBytes val_ref;
28997         CHECK(val->arr_len == 32);
28998         memcpy(val_ref.data, val->elems, 32); FREE(val);
28999         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
29000 }
29001
29002 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) {
29003         LDKDataLossProtect this_ptr_conv;
29004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29005         this_ptr_conv.is_owned = false;
29006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29007         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29008         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29009         return ret_arr;
29010 }
29011
29012 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) {
29013         LDKDataLossProtect this_ptr_conv;
29014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29015         this_ptr_conv.is_owned = false;
29016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29017         LDKPublicKey val_ref;
29018         CHECK(val->arr_len == 33);
29019         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29020         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
29021 }
29022
29023 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) {
29024         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
29025         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
29026         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
29027         LDKPublicKey my_current_per_commitment_point_arg_ref;
29028         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
29029         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);
29030         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
29031         uint32_t ret_ref = 0;
29032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29035         ret_ref = (uintptr_t)ret_var.inner;
29036         if (ret_var.is_owned) {
29037                 ret_ref |= 1;
29038         }
29039         return ret_ref;
29040 }
29041
29042 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
29043         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
29044 uint32_t ret_ref = 0;
29045 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29046 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29047 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29048 ret_ref = (uintptr_t)ret_var.inner;
29049 if (ret_var.is_owned) {
29050         ret_ref |= 1;
29051 }
29052         return ret_ref;
29053 }
29054 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
29055         LDKDataLossProtect arg_conv;
29056         arg_conv.inner = (void*)(arg & (~1));
29057         arg_conv.is_owned = false;
29058         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29059         uint32_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
29060         return ret_val;
29061 }
29062
29063 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
29064         LDKDataLossProtect orig_conv;
29065         orig_conv.inner = (void*)(orig & (~1));
29066         orig_conv.is_owned = false;
29067         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29068         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
29069         uint32_t ret_ref = 0;
29070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29073         ret_ref = (uintptr_t)ret_var.inner;
29074         if (ret_var.is_owned) {
29075                 ret_ref |= 1;
29076         }
29077         return ret_ref;
29078 }
29079
29080 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
29081         LDKChannelReestablish this_obj_conv;
29082         this_obj_conv.inner = (void*)(this_obj & (~1));
29083         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29085         ChannelReestablish_free(this_obj_conv);
29086 }
29087
29088 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
29089         LDKChannelReestablish this_ptr_conv;
29090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29091         this_ptr_conv.is_owned = false;
29092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29093         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29094         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
29095         return ret_arr;
29096 }
29097
29098 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29099         LDKChannelReestablish this_ptr_conv;
29100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29101         this_ptr_conv.is_owned = false;
29102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29103         LDKThirtyTwoBytes val_ref;
29104         CHECK(val->arr_len == 32);
29105         memcpy(val_ref.data, val->elems, 32); FREE(val);
29106         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
29107 }
29108
29109 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
29110         LDKChannelReestablish this_ptr_conv;
29111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29112         this_ptr_conv.is_owned = false;
29113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29114         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
29115         return ret_val;
29116 }
29117
29118 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) {
29119         LDKChannelReestablish this_ptr_conv;
29120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29121         this_ptr_conv.is_owned = false;
29122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29123         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
29124 }
29125
29126 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
29127         LDKChannelReestablish this_ptr_conv;
29128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29129         this_ptr_conv.is_owned = false;
29130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29131         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
29132         return ret_val;
29133 }
29134
29135 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) {
29136         LDKChannelReestablish this_ptr_conv;
29137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29138         this_ptr_conv.is_owned = false;
29139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29140         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
29141 }
29142
29143 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
29144         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
29145 uint32_t ret_ref = 0;
29146 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29147 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29148 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29149 ret_ref = (uintptr_t)ret_var.inner;
29150 if (ret_var.is_owned) {
29151         ret_ref |= 1;
29152 }
29153         return ret_ref;
29154 }
29155 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
29156         LDKChannelReestablish arg_conv;
29157         arg_conv.inner = (void*)(arg & (~1));
29158         arg_conv.is_owned = false;
29159         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29160         uint32_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
29161         return ret_val;
29162 }
29163
29164 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
29165         LDKChannelReestablish orig_conv;
29166         orig_conv.inner = (void*)(orig & (~1));
29167         orig_conv.is_owned = false;
29168         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29169         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
29170         uint32_t ret_ref = 0;
29171         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29172         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29174         ret_ref = (uintptr_t)ret_var.inner;
29175         if (ret_var.is_owned) {
29176                 ret_ref |= 1;
29177         }
29178         return ret_ref;
29179 }
29180
29181 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
29182         LDKAnnouncementSignatures this_obj_conv;
29183         this_obj_conv.inner = (void*)(this_obj & (~1));
29184         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29186         AnnouncementSignatures_free(this_obj_conv);
29187 }
29188
29189 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
29190         LDKAnnouncementSignatures 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         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29195         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
29196         return ret_arr;
29197 }
29198
29199 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29200         LDKAnnouncementSignatures this_ptr_conv;
29201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29202         this_ptr_conv.is_owned = false;
29203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29204         LDKThirtyTwoBytes val_ref;
29205         CHECK(val->arr_len == 32);
29206         memcpy(val_ref.data, val->elems, 32); FREE(val);
29207         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
29208 }
29209
29210 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
29211         LDKAnnouncementSignatures this_ptr_conv;
29212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29213         this_ptr_conv.is_owned = false;
29214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29215         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
29216         return ret_val;
29217 }
29218
29219 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29220         LDKAnnouncementSignatures this_ptr_conv;
29221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29222         this_ptr_conv.is_owned = false;
29223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29224         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
29225 }
29226
29227 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
29228         LDKAnnouncementSignatures this_ptr_conv;
29229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29230         this_ptr_conv.is_owned = false;
29231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29232         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29233         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
29234         return ret_arr;
29235 }
29236
29237 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
29238         LDKAnnouncementSignatures this_ptr_conv;
29239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29240         this_ptr_conv.is_owned = false;
29241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29242         LDKSignature val_ref;
29243         CHECK(val->arr_len == 64);
29244         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29245         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
29246 }
29247
29248 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
29249         LDKAnnouncementSignatures this_ptr_conv;
29250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29251         this_ptr_conv.is_owned = false;
29252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29253         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29254         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
29255         return ret_arr;
29256 }
29257
29258 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
29259         LDKAnnouncementSignatures this_ptr_conv;
29260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29261         this_ptr_conv.is_owned = false;
29262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29263         LDKSignature val_ref;
29264         CHECK(val->arr_len == 64);
29265         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29266         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
29267 }
29268
29269 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) {
29270         LDKThirtyTwoBytes channel_id_arg_ref;
29271         CHECK(channel_id_arg->arr_len == 32);
29272         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29273         LDKSignature node_signature_arg_ref;
29274         CHECK(node_signature_arg->arr_len == 64);
29275         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
29276         LDKSignature bitcoin_signature_arg_ref;
29277         CHECK(bitcoin_signature_arg->arr_len == 64);
29278         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
29279         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
29280         uint32_t ret_ref = 0;
29281         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29282         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29284         ret_ref = (uintptr_t)ret_var.inner;
29285         if (ret_var.is_owned) {
29286                 ret_ref |= 1;
29287         }
29288         return ret_ref;
29289 }
29290
29291 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
29292         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
29293 uint32_t ret_ref = 0;
29294 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29295 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29296 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29297 ret_ref = (uintptr_t)ret_var.inner;
29298 if (ret_var.is_owned) {
29299         ret_ref |= 1;
29300 }
29301         return ret_ref;
29302 }
29303 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
29304         LDKAnnouncementSignatures arg_conv;
29305         arg_conv.inner = (void*)(arg & (~1));
29306         arg_conv.is_owned = false;
29307         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29308         uint32_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
29309         return ret_val;
29310 }
29311
29312 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
29313         LDKAnnouncementSignatures orig_conv;
29314         orig_conv.inner = (void*)(orig & (~1));
29315         orig_conv.is_owned = false;
29316         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29317         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
29318         uint32_t ret_ref = 0;
29319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29322         ret_ref = (uintptr_t)ret_var.inner;
29323         if (ret_var.is_owned) {
29324                 ret_ref |= 1;
29325         }
29326         return ret_ref;
29327 }
29328
29329 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
29330         if ((this_ptr & 1) != 0) return;
29331         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
29332         CHECK_ACCESS(this_ptr_ptr);
29333         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
29334         FREE((void*)this_ptr);
29335         NetAddress_free(this_ptr_conv);
29336 }
29337
29338 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
29339         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29340         *ret_copy = NetAddress_clone(arg);
29341 uint32_t ret_ref = (uintptr_t)ret_copy;
29342         return ret_ref;
29343 }
29344 uint32_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
29345         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
29346         uint32_t ret_val = NetAddress_clone_ptr(arg_conv);
29347         return ret_val;
29348 }
29349
29350 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
29351         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
29352         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29353         *ret_copy = NetAddress_clone(orig_conv);
29354         uint32_t ret_ref = (uintptr_t)ret_copy;
29355         return ret_ref;
29356 }
29357
29358 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
29359         LDKFourBytes addr_ref;
29360         CHECK(addr->arr_len == 4);
29361         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
29362         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29363         *ret_copy = NetAddress_ipv4(addr_ref, port);
29364         uint32_t ret_ref = (uintptr_t)ret_copy;
29365         return ret_ref;
29366 }
29367
29368 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
29369         LDKSixteenBytes addr_ref;
29370         CHECK(addr->arr_len == 16);
29371         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
29372         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29373         *ret_copy = NetAddress_ipv6(addr_ref, port);
29374         uint32_t ret_ref = (uintptr_t)ret_copy;
29375         return ret_ref;
29376 }
29377
29378 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
29379         LDKTwelveBytes a_ref;
29380         CHECK(a->arr_len == 12);
29381         memcpy(a_ref.data, a->elems, 12); FREE(a);
29382         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29383         *ret_copy = NetAddress_onion_v2(a_ref);
29384         uint32_t ret_ref = (uintptr_t)ret_copy;
29385         return ret_ref;
29386 }
29387
29388 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) {
29389         LDKThirtyTwoBytes ed25519_pubkey_ref;
29390         CHECK(ed25519_pubkey->arr_len == 32);
29391         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
29392         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29393         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
29394         uint32_t ret_ref = (uintptr_t)ret_copy;
29395         return ret_ref;
29396 }
29397
29398 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
29399         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
29400         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
29401         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29402         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29403         CVec_u8Z_free(ret_var);
29404         return ret_arr;
29405 }
29406
29407 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
29408         LDKu8slice ser_ref;
29409         ser_ref.datalen = ser->arr_len;
29410         ser_ref.data = ser->elems /* XXX ser leaks */;
29411         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
29412         *ret_conv = NetAddress_read(ser_ref);
29413         return (uint32_t)ret_conv;
29414 }
29415
29416 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
29417         LDKUnsignedNodeAnnouncement this_obj_conv;
29418         this_obj_conv.inner = (void*)(this_obj & (~1));
29419         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29421         UnsignedNodeAnnouncement_free(this_obj_conv);
29422 }
29423
29424 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
29425         LDKUnsignedNodeAnnouncement this_ptr_conv;
29426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29427         this_ptr_conv.is_owned = false;
29428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29429         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
29430         uint32_t ret_ref = 0;
29431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29434         ret_ref = (uintptr_t)ret_var.inner;
29435         if (ret_var.is_owned) {
29436                 ret_ref |= 1;
29437         }
29438         return ret_ref;
29439 }
29440
29441 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
29442         LDKUnsignedNodeAnnouncement this_ptr_conv;
29443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29444         this_ptr_conv.is_owned = false;
29445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29446         LDKNodeFeatures val_conv;
29447         val_conv.inner = (void*)(val & (~1));
29448         val_conv.is_owned = (val & 1) || (val == 0);
29449         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29450         val_conv = NodeFeatures_clone(&val_conv);
29451         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
29452 }
29453
29454 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
29455         LDKUnsignedNodeAnnouncement this_ptr_conv;
29456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29457         this_ptr_conv.is_owned = false;
29458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29459         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
29460         return ret_val;
29461 }
29462
29463 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
29464         LDKUnsignedNodeAnnouncement this_ptr_conv;
29465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29466         this_ptr_conv.is_owned = false;
29467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29468         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
29469 }
29470
29471 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
29472         LDKUnsignedNodeAnnouncement this_ptr_conv;
29473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29474         this_ptr_conv.is_owned = false;
29475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29476         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29477         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
29478         return ret_arr;
29479 }
29480
29481 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
29482         LDKUnsignedNodeAnnouncement this_ptr_conv;
29483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29484         this_ptr_conv.is_owned = false;
29485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29486         LDKPublicKey val_ref;
29487         CHECK(val->arr_len == 33);
29488         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29489         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
29490 }
29491
29492 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
29493         LDKUnsignedNodeAnnouncement this_ptr_conv;
29494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29495         this_ptr_conv.is_owned = false;
29496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29497         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
29498         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
29499         return ret_arr;
29500 }
29501
29502 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
29503         LDKUnsignedNodeAnnouncement this_ptr_conv;
29504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29505         this_ptr_conv.is_owned = false;
29506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29507         LDKThreeBytes val_ref;
29508         CHECK(val->arr_len == 3);
29509         memcpy(val_ref.data, val->elems, 3); FREE(val);
29510         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
29511 }
29512
29513 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
29514         LDKUnsignedNodeAnnouncement this_ptr_conv;
29515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29516         this_ptr_conv.is_owned = false;
29517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29518         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29519         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
29520         return ret_arr;
29521 }
29522
29523 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
29524         LDKUnsignedNodeAnnouncement this_ptr_conv;
29525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29526         this_ptr_conv.is_owned = false;
29527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29528         LDKThirtyTwoBytes val_ref;
29529         CHECK(val->arr_len == 32);
29530         memcpy(val_ref.data, val->elems, 32); FREE(val);
29531         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
29532 }
29533
29534 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
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         LDKCVec_NetAddressZ val_constr;
29540         val_constr.datalen = val->arr_len;
29541         if (val_constr.datalen > 0)
29542                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
29543         else
29544                 val_constr.data = NULL;
29545         uint32_t* val_vals = val->elems /* XXX val leaks */;
29546         for (size_t m = 0; m < val_constr.datalen; m++) {
29547                 uint32_t val_conv_12 = val_vals[m];
29548                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
29549                 CHECK_ACCESS(val_conv_12_ptr);
29550                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
29551                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
29552                 val_constr.data[m] = val_conv_12_conv;
29553         }
29554         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
29555 }
29556
29557 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
29558         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
29559 uint32_t ret_ref = 0;
29560 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29561 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29562 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29563 ret_ref = (uintptr_t)ret_var.inner;
29564 if (ret_var.is_owned) {
29565         ret_ref |= 1;
29566 }
29567         return ret_ref;
29568 }
29569 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
29570         LDKUnsignedNodeAnnouncement arg_conv;
29571         arg_conv.inner = (void*)(arg & (~1));
29572         arg_conv.is_owned = false;
29573         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29574         uint32_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
29575         return ret_val;
29576 }
29577
29578 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
29579         LDKUnsignedNodeAnnouncement orig_conv;
29580         orig_conv.inner = (void*)(orig & (~1));
29581         orig_conv.is_owned = false;
29582         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29583         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
29584         uint32_t ret_ref = 0;
29585         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29586         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29588         ret_ref = (uintptr_t)ret_var.inner;
29589         if (ret_var.is_owned) {
29590                 ret_ref |= 1;
29591         }
29592         return ret_ref;
29593 }
29594
29595 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
29596         LDKNodeAnnouncement this_obj_conv;
29597         this_obj_conv.inner = (void*)(this_obj & (~1));
29598         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29600         NodeAnnouncement_free(this_obj_conv);
29601 }
29602
29603 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
29604         LDKNodeAnnouncement this_ptr_conv;
29605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29606         this_ptr_conv.is_owned = false;
29607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29608         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29609         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
29610         return ret_arr;
29611 }
29612
29613 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
29614         LDKNodeAnnouncement this_ptr_conv;
29615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29616         this_ptr_conv.is_owned = false;
29617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29618         LDKSignature val_ref;
29619         CHECK(val->arr_len == 64);
29620         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29621         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
29622 }
29623
29624 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
29625         LDKNodeAnnouncement this_ptr_conv;
29626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29627         this_ptr_conv.is_owned = false;
29628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29629         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
29630         uint32_t ret_ref = 0;
29631         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29632         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29634         ret_ref = (uintptr_t)ret_var.inner;
29635         if (ret_var.is_owned) {
29636                 ret_ref |= 1;
29637         }
29638         return ret_ref;
29639 }
29640
29641 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
29642         LDKNodeAnnouncement this_ptr_conv;
29643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29644         this_ptr_conv.is_owned = false;
29645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29646         LDKUnsignedNodeAnnouncement val_conv;
29647         val_conv.inner = (void*)(val & (~1));
29648         val_conv.is_owned = (val & 1) || (val == 0);
29649         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29650         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
29651         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
29652 }
29653
29654 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
29655         LDKSignature signature_arg_ref;
29656         CHECK(signature_arg->arr_len == 64);
29657         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29658         LDKUnsignedNodeAnnouncement contents_arg_conv;
29659         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29660         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29661         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29662         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
29663         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
29664         uint32_t ret_ref = 0;
29665         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29666         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29668         ret_ref = (uintptr_t)ret_var.inner;
29669         if (ret_var.is_owned) {
29670                 ret_ref |= 1;
29671         }
29672         return ret_ref;
29673 }
29674
29675 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
29676         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
29677 uint32_t ret_ref = 0;
29678 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29679 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29680 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29681 ret_ref = (uintptr_t)ret_var.inner;
29682 if (ret_var.is_owned) {
29683         ret_ref |= 1;
29684 }
29685         return ret_ref;
29686 }
29687 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
29688         LDKNodeAnnouncement arg_conv;
29689         arg_conv.inner = (void*)(arg & (~1));
29690         arg_conv.is_owned = false;
29691         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29692         uint32_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
29693         return ret_val;
29694 }
29695
29696 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
29697         LDKNodeAnnouncement orig_conv;
29698         orig_conv.inner = (void*)(orig & (~1));
29699         orig_conv.is_owned = false;
29700         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29701         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
29702         uint32_t ret_ref = 0;
29703         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29704         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29706         ret_ref = (uintptr_t)ret_var.inner;
29707         if (ret_var.is_owned) {
29708                 ret_ref |= 1;
29709         }
29710         return ret_ref;
29711 }
29712
29713 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
29714         LDKUnsignedChannelAnnouncement this_obj_conv;
29715         this_obj_conv.inner = (void*)(this_obj & (~1));
29716         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29718         UnsignedChannelAnnouncement_free(this_obj_conv);
29719 }
29720
29721 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
29722         LDKUnsignedChannelAnnouncement this_ptr_conv;
29723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29724         this_ptr_conv.is_owned = false;
29725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29726         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_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 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
29739         LDKUnsignedChannelAnnouncement this_ptr_conv;
29740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29741         this_ptr_conv.is_owned = false;
29742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29743         LDKChannelFeatures val_conv;
29744         val_conv.inner = (void*)(val & (~1));
29745         val_conv.is_owned = (val & 1) || (val == 0);
29746         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29747         val_conv = ChannelFeatures_clone(&val_conv);
29748         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
29749 }
29750
29751 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
29752         LDKUnsignedChannelAnnouncement this_ptr_conv;
29753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29754         this_ptr_conv.is_owned = false;
29755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29756         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29757         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
29758         return ret_arr;
29759 }
29760
29761 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29762         LDKUnsignedChannelAnnouncement this_ptr_conv;
29763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29764         this_ptr_conv.is_owned = false;
29765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29766         LDKThirtyTwoBytes val_ref;
29767         CHECK(val->arr_len == 32);
29768         memcpy(val_ref.data, val->elems, 32); FREE(val);
29769         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
29770 }
29771
29772 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
29773         LDKUnsignedChannelAnnouncement this_ptr_conv;
29774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29775         this_ptr_conv.is_owned = false;
29776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29777         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
29778         return ret_val;
29779 }
29780
29781 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29782         LDKUnsignedChannelAnnouncement this_ptr_conv;
29783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29784         this_ptr_conv.is_owned = false;
29785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29786         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
29787 }
29788
29789 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
29790         LDKUnsignedChannelAnnouncement this_ptr_conv;
29791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29792         this_ptr_conv.is_owned = false;
29793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29794         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29795         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
29796         return ret_arr;
29797 }
29798
29799 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
29800         LDKUnsignedChannelAnnouncement this_ptr_conv;
29801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29802         this_ptr_conv.is_owned = false;
29803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29804         LDKPublicKey val_ref;
29805         CHECK(val->arr_len == 33);
29806         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29807         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
29808 }
29809
29810 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
29811         LDKUnsignedChannelAnnouncement this_ptr_conv;
29812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29813         this_ptr_conv.is_owned = false;
29814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29815         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29816         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
29817         return ret_arr;
29818 }
29819
29820 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
29821         LDKUnsignedChannelAnnouncement this_ptr_conv;
29822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29823         this_ptr_conv.is_owned = false;
29824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29825         LDKPublicKey val_ref;
29826         CHECK(val->arr_len == 33);
29827         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29828         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
29829 }
29830
29831 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
29832         LDKUnsignedChannelAnnouncement this_ptr_conv;
29833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29834         this_ptr_conv.is_owned = false;
29835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29836         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29837         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
29838         return ret_arr;
29839 }
29840
29841 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
29842         LDKUnsignedChannelAnnouncement this_ptr_conv;
29843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29844         this_ptr_conv.is_owned = false;
29845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29846         LDKPublicKey val_ref;
29847         CHECK(val->arr_len == 33);
29848         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29849         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
29850 }
29851
29852 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(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_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
29859         return ret_arr;
29860 }
29861
29862 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(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_bitcoin_key_2(&this_ptr_conv, val_ref);
29871 }
29872
29873 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
29874         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
29875 uint32_t ret_ref = 0;
29876 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29877 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29878 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29879 ret_ref = (uintptr_t)ret_var.inner;
29880 if (ret_var.is_owned) {
29881         ret_ref |= 1;
29882 }
29883         return ret_ref;
29884 }
29885 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
29886         LDKUnsignedChannelAnnouncement arg_conv;
29887         arg_conv.inner = (void*)(arg & (~1));
29888         arg_conv.is_owned = false;
29889         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29890         uint32_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
29891         return ret_val;
29892 }
29893
29894 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
29895         LDKUnsignedChannelAnnouncement orig_conv;
29896         orig_conv.inner = (void*)(orig & (~1));
29897         orig_conv.is_owned = false;
29898         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29899         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
29900         uint32_t ret_ref = 0;
29901         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29902         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29904         ret_ref = (uintptr_t)ret_var.inner;
29905         if (ret_var.is_owned) {
29906                 ret_ref |= 1;
29907         }
29908         return ret_ref;
29909 }
29910
29911 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
29912         LDKChannelAnnouncement this_obj_conv;
29913         this_obj_conv.inner = (void*)(this_obj & (~1));
29914         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29916         ChannelAnnouncement_free(this_obj_conv);
29917 }
29918
29919 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
29920         LDKChannelAnnouncement this_ptr_conv;
29921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29922         this_ptr_conv.is_owned = false;
29923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29924         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29925         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
29926         return ret_arr;
29927 }
29928
29929 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
29930         LDKChannelAnnouncement this_ptr_conv;
29931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29932         this_ptr_conv.is_owned = false;
29933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29934         LDKSignature val_ref;
29935         CHECK(val->arr_len == 64);
29936         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29937         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
29938 }
29939
29940 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
29941         LDKChannelAnnouncement this_ptr_conv;
29942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29943         this_ptr_conv.is_owned = false;
29944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29945         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29946         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
29947         return ret_arr;
29948 }
29949
29950 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
29951         LDKChannelAnnouncement this_ptr_conv;
29952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29953         this_ptr_conv.is_owned = false;
29954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29955         LDKSignature val_ref;
29956         CHECK(val->arr_len == 64);
29957         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29958         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
29959 }
29960
29961 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
29962         LDKChannelAnnouncement this_ptr_conv;
29963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29964         this_ptr_conv.is_owned = false;
29965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29966         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29967         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
29968         return ret_arr;
29969 }
29970
29971 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
29972         LDKChannelAnnouncement this_ptr_conv;
29973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29974         this_ptr_conv.is_owned = false;
29975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29976         LDKSignature val_ref;
29977         CHECK(val->arr_len == 64);
29978         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29979         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
29980 }
29981
29982 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(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_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
29989         return ret_arr;
29990 }
29991
29992 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(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_bitcoin_signature_2(&this_ptr_conv, val_ref);
30001 }
30002
30003 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(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         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
30009         uint32_t ret_ref = 0;
30010         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30011         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30013         ret_ref = (uintptr_t)ret_var.inner;
30014         if (ret_var.is_owned) {
30015                 ret_ref |= 1;
30016         }
30017         return ret_ref;
30018 }
30019
30020 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
30021         LDKChannelAnnouncement this_ptr_conv;
30022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30023         this_ptr_conv.is_owned = false;
30024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30025         LDKUnsignedChannelAnnouncement val_conv;
30026         val_conv.inner = (void*)(val & (~1));
30027         val_conv.is_owned = (val & 1) || (val == 0);
30028         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30029         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
30030         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
30031 }
30032
30033 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) {
30034         LDKSignature node_signature_1_arg_ref;
30035         CHECK(node_signature_1_arg->arr_len == 64);
30036         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
30037         LDKSignature node_signature_2_arg_ref;
30038         CHECK(node_signature_2_arg->arr_len == 64);
30039         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
30040         LDKSignature bitcoin_signature_1_arg_ref;
30041         CHECK(bitcoin_signature_1_arg->arr_len == 64);
30042         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
30043         LDKSignature bitcoin_signature_2_arg_ref;
30044         CHECK(bitcoin_signature_2_arg->arr_len == 64);
30045         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
30046         LDKUnsignedChannelAnnouncement contents_arg_conv;
30047         contents_arg_conv.inner = (void*)(contents_arg & (~1));
30048         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
30049         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
30050         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
30051         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);
30052         uint32_t ret_ref = 0;
30053         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30054         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30056         ret_ref = (uintptr_t)ret_var.inner;
30057         if (ret_var.is_owned) {
30058                 ret_ref |= 1;
30059         }
30060         return ret_ref;
30061 }
30062
30063 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
30064         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
30065 uint32_t ret_ref = 0;
30066 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30067 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30068 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30069 ret_ref = (uintptr_t)ret_var.inner;
30070 if (ret_var.is_owned) {
30071         ret_ref |= 1;
30072 }
30073         return ret_ref;
30074 }
30075 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
30076         LDKChannelAnnouncement arg_conv;
30077         arg_conv.inner = (void*)(arg & (~1));
30078         arg_conv.is_owned = false;
30079         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30080         uint32_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
30081         return ret_val;
30082 }
30083
30084 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
30085         LDKChannelAnnouncement orig_conv;
30086         orig_conv.inner = (void*)(orig & (~1));
30087         orig_conv.is_owned = false;
30088         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30089         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
30090         uint32_t ret_ref = 0;
30091         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30092         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30094         ret_ref = (uintptr_t)ret_var.inner;
30095         if (ret_var.is_owned) {
30096                 ret_ref |= 1;
30097         }
30098         return ret_ref;
30099 }
30100
30101 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
30102         LDKUnsignedChannelUpdate this_obj_conv;
30103         this_obj_conv.inner = (void*)(this_obj & (~1));
30104         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30106         UnsignedChannelUpdate_free(this_obj_conv);
30107 }
30108
30109 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
30110         LDKUnsignedChannelUpdate this_ptr_conv;
30111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30112         this_ptr_conv.is_owned = false;
30113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30114         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30115         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
30116         return ret_arr;
30117 }
30118
30119 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30120         LDKUnsignedChannelUpdate this_ptr_conv;
30121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30122         this_ptr_conv.is_owned = false;
30123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30124         LDKThirtyTwoBytes val_ref;
30125         CHECK(val->arr_len == 32);
30126         memcpy(val_ref.data, val->elems, 32); FREE(val);
30127         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
30128 }
30129
30130 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
30131         LDKUnsignedChannelUpdate this_ptr_conv;
30132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30133         this_ptr_conv.is_owned = false;
30134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30135         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
30136         return ret_val;
30137 }
30138
30139 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
30140         LDKUnsignedChannelUpdate this_ptr_conv;
30141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30142         this_ptr_conv.is_owned = false;
30143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30144         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
30145 }
30146
30147 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
30148         LDKUnsignedChannelUpdate this_ptr_conv;
30149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30150         this_ptr_conv.is_owned = false;
30151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30152         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
30153         return ret_val;
30154 }
30155
30156 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
30157         LDKUnsignedChannelUpdate this_ptr_conv;
30158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30159         this_ptr_conv.is_owned = false;
30160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30161         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
30162 }
30163
30164 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
30165         LDKUnsignedChannelUpdate this_ptr_conv;
30166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30167         this_ptr_conv.is_owned = false;
30168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30169         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
30170         return ret_val;
30171 }
30172
30173 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
30174         LDKUnsignedChannelUpdate this_ptr_conv;
30175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30176         this_ptr_conv.is_owned = false;
30177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30178         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
30179 }
30180
30181 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
30182         LDKUnsignedChannelUpdate this_ptr_conv;
30183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30184         this_ptr_conv.is_owned = false;
30185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30186         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
30187         return ret_val;
30188 }
30189
30190 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
30191         LDKUnsignedChannelUpdate this_ptr_conv;
30192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30193         this_ptr_conv.is_owned = false;
30194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30195         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
30196 }
30197
30198 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
30199         LDKUnsignedChannelUpdate this_ptr_conv;
30200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30201         this_ptr_conv.is_owned = false;
30202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30203         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
30204         return ret_val;
30205 }
30206
30207 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
30208         LDKUnsignedChannelUpdate this_ptr_conv;
30209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30210         this_ptr_conv.is_owned = false;
30211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30212         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
30213 }
30214
30215 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
30216         LDKUnsignedChannelUpdate this_ptr_conv;
30217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30218         this_ptr_conv.is_owned = false;
30219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30220         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
30221         return ret_val;
30222 }
30223
30224 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
30225         LDKUnsignedChannelUpdate this_ptr_conv;
30226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30227         this_ptr_conv.is_owned = false;
30228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30229         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
30230 }
30231
30232 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
30233         LDKUnsignedChannelUpdate this_ptr_conv;
30234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30235         this_ptr_conv.is_owned = false;
30236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30237         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
30238         return ret_val;
30239 }
30240
30241 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
30242         LDKUnsignedChannelUpdate this_ptr_conv;
30243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30244         this_ptr_conv.is_owned = false;
30245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30246         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
30247 }
30248
30249 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
30250         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
30251 uint32_t ret_ref = 0;
30252 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30253 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30254 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30255 ret_ref = (uintptr_t)ret_var.inner;
30256 if (ret_var.is_owned) {
30257         ret_ref |= 1;
30258 }
30259         return ret_ref;
30260 }
30261 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
30262         LDKUnsignedChannelUpdate arg_conv;
30263         arg_conv.inner = (void*)(arg & (~1));
30264         arg_conv.is_owned = false;
30265         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30266         uint32_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
30267         return ret_val;
30268 }
30269
30270 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
30271         LDKUnsignedChannelUpdate orig_conv;
30272         orig_conv.inner = (void*)(orig & (~1));
30273         orig_conv.is_owned = false;
30274         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30275         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
30276         uint32_t ret_ref = 0;
30277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30280         ret_ref = (uintptr_t)ret_var.inner;
30281         if (ret_var.is_owned) {
30282                 ret_ref |= 1;
30283         }
30284         return ret_ref;
30285 }
30286
30287 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
30288         LDKChannelUpdate this_obj_conv;
30289         this_obj_conv.inner = (void*)(this_obj & (~1));
30290         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30292         ChannelUpdate_free(this_obj_conv);
30293 }
30294
30295 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
30296         LDKChannelUpdate 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         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30301         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
30302         return ret_arr;
30303 }
30304
30305 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
30306         LDKChannelUpdate this_ptr_conv;
30307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30308         this_ptr_conv.is_owned = false;
30309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30310         LDKSignature val_ref;
30311         CHECK(val->arr_len == 64);
30312         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30313         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
30314 }
30315
30316 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
30317         LDKChannelUpdate this_ptr_conv;
30318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30319         this_ptr_conv.is_owned = false;
30320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30321         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
30322         uint32_t ret_ref = 0;
30323         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30324         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30326         ret_ref = (uintptr_t)ret_var.inner;
30327         if (ret_var.is_owned) {
30328                 ret_ref |= 1;
30329         }
30330         return ret_ref;
30331 }
30332
30333 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
30334         LDKChannelUpdate this_ptr_conv;
30335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30336         this_ptr_conv.is_owned = false;
30337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30338         LDKUnsignedChannelUpdate val_conv;
30339         val_conv.inner = (void*)(val & (~1));
30340         val_conv.is_owned = (val & 1) || (val == 0);
30341         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30342         val_conv = UnsignedChannelUpdate_clone(&val_conv);
30343         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
30344 }
30345
30346 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
30347         LDKSignature signature_arg_ref;
30348         CHECK(signature_arg->arr_len == 64);
30349         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30350         LDKUnsignedChannelUpdate contents_arg_conv;
30351         contents_arg_conv.inner = (void*)(contents_arg & (~1));
30352         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
30353         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
30354         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
30355         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
30356         uint32_t ret_ref = 0;
30357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30360         ret_ref = (uintptr_t)ret_var.inner;
30361         if (ret_var.is_owned) {
30362                 ret_ref |= 1;
30363         }
30364         return ret_ref;
30365 }
30366
30367 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
30368         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
30369 uint32_t ret_ref = 0;
30370 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30371 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30372 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30373 ret_ref = (uintptr_t)ret_var.inner;
30374 if (ret_var.is_owned) {
30375         ret_ref |= 1;
30376 }
30377         return ret_ref;
30378 }
30379 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
30380         LDKChannelUpdate arg_conv;
30381         arg_conv.inner = (void*)(arg & (~1));
30382         arg_conv.is_owned = false;
30383         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30384         uint32_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
30385         return ret_val;
30386 }
30387
30388 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
30389         LDKChannelUpdate orig_conv;
30390         orig_conv.inner = (void*)(orig & (~1));
30391         orig_conv.is_owned = false;
30392         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30393         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
30394         uint32_t ret_ref = 0;
30395         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30396         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30398         ret_ref = (uintptr_t)ret_var.inner;
30399         if (ret_var.is_owned) {
30400                 ret_ref |= 1;
30401         }
30402         return ret_ref;
30403 }
30404
30405 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
30406         LDKQueryChannelRange this_obj_conv;
30407         this_obj_conv.inner = (void*)(this_obj & (~1));
30408         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30410         QueryChannelRange_free(this_obj_conv);
30411 }
30412
30413 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
30414         LDKQueryChannelRange this_ptr_conv;
30415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30416         this_ptr_conv.is_owned = false;
30417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30418         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30419         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
30420         return ret_arr;
30421 }
30422
30423 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30424         LDKQueryChannelRange this_ptr_conv;
30425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30426         this_ptr_conv.is_owned = false;
30427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30428         LDKThirtyTwoBytes val_ref;
30429         CHECK(val->arr_len == 32);
30430         memcpy(val_ref.data, val->elems, 32); FREE(val);
30431         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
30432 }
30433
30434 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
30435         LDKQueryChannelRange this_ptr_conv;
30436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30437         this_ptr_conv.is_owned = false;
30438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30439         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
30440         return ret_val;
30441 }
30442
30443 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
30444         LDKQueryChannelRange this_ptr_conv;
30445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30446         this_ptr_conv.is_owned = false;
30447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30448         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
30449 }
30450
30451 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
30452         LDKQueryChannelRange this_ptr_conv;
30453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30454         this_ptr_conv.is_owned = false;
30455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30456         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
30457         return ret_val;
30458 }
30459
30460 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
30461         LDKQueryChannelRange this_ptr_conv;
30462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30463         this_ptr_conv.is_owned = false;
30464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30465         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30466 }
30467
30468 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) {
30469         LDKThirtyTwoBytes chain_hash_arg_ref;
30470         CHECK(chain_hash_arg->arr_len == 32);
30471         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30472         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
30473         uint32_t ret_ref = 0;
30474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30477         ret_ref = (uintptr_t)ret_var.inner;
30478         if (ret_var.is_owned) {
30479                 ret_ref |= 1;
30480         }
30481         return ret_ref;
30482 }
30483
30484 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
30485         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
30486 uint32_t ret_ref = 0;
30487 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30488 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30489 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30490 ret_ref = (uintptr_t)ret_var.inner;
30491 if (ret_var.is_owned) {
30492         ret_ref |= 1;
30493 }
30494         return ret_ref;
30495 }
30496 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
30497         LDKQueryChannelRange arg_conv;
30498         arg_conv.inner = (void*)(arg & (~1));
30499         arg_conv.is_owned = false;
30500         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30501         uint32_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
30502         return ret_val;
30503 }
30504
30505 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
30506         LDKQueryChannelRange orig_conv;
30507         orig_conv.inner = (void*)(orig & (~1));
30508         orig_conv.is_owned = false;
30509         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30510         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
30511         uint32_t ret_ref = 0;
30512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30515         ret_ref = (uintptr_t)ret_var.inner;
30516         if (ret_var.is_owned) {
30517                 ret_ref |= 1;
30518         }
30519         return ret_ref;
30520 }
30521
30522 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
30523         LDKReplyChannelRange this_obj_conv;
30524         this_obj_conv.inner = (void*)(this_obj & (~1));
30525         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30527         ReplyChannelRange_free(this_obj_conv);
30528 }
30529
30530 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
30531         LDKReplyChannelRange this_ptr_conv;
30532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30533         this_ptr_conv.is_owned = false;
30534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30535         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30536         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
30537         return ret_arr;
30538 }
30539
30540 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30541         LDKReplyChannelRange this_ptr_conv;
30542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30543         this_ptr_conv.is_owned = false;
30544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30545         LDKThirtyTwoBytes val_ref;
30546         CHECK(val->arr_len == 32);
30547         memcpy(val_ref.data, val->elems, 32); FREE(val);
30548         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
30549 }
30550
30551 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
30552         LDKReplyChannelRange this_ptr_conv;
30553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30554         this_ptr_conv.is_owned = false;
30555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30556         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
30557         return ret_val;
30558 }
30559
30560 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
30561         LDKReplyChannelRange this_ptr_conv;
30562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30563         this_ptr_conv.is_owned = false;
30564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30565         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
30566 }
30567
30568 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
30569         LDKReplyChannelRange this_ptr_conv;
30570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30571         this_ptr_conv.is_owned = false;
30572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30573         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
30574         return ret_val;
30575 }
30576
30577 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
30578         LDKReplyChannelRange this_ptr_conv;
30579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30580         this_ptr_conv.is_owned = false;
30581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30582         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30583 }
30584
30585 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
30586         LDKReplyChannelRange this_ptr_conv;
30587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30588         this_ptr_conv.is_owned = false;
30589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30590         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
30591         return ret_val;
30592 }
30593
30594 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
30595         LDKReplyChannelRange this_ptr_conv;
30596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30597         this_ptr_conv.is_owned = false;
30598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30599         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
30600 }
30601
30602 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30603         LDKReplyChannelRange this_ptr_conv;
30604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30605         this_ptr_conv.is_owned = false;
30606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30607         LDKCVec_u64Z val_constr;
30608         val_constr.datalen = val->arr_len;
30609         if (val_constr.datalen > 0)
30610                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30611         else
30612                 val_constr.data = NULL;
30613         int64_t* val_vals = val->elems /* XXX val leaks */;
30614         for (size_t i = 0; i < val_constr.datalen; i++) {
30615                 int64_t val_conv_8 = val_vals[i];
30616                 val_constr.data[i] = val_conv_8;
30617         }
30618         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
30619 }
30620
30621 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) {
30622         LDKThirtyTwoBytes chain_hash_arg_ref;
30623         CHECK(chain_hash_arg->arr_len == 32);
30624         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30625         LDKCVec_u64Z short_channel_ids_arg_constr;
30626         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30627         if (short_channel_ids_arg_constr.datalen > 0)
30628                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30629         else
30630                 short_channel_ids_arg_constr.data = NULL;
30631         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30632         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30633                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30634                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30635         }
30636         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
30637         uint32_t ret_ref = 0;
30638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30641         ret_ref = (uintptr_t)ret_var.inner;
30642         if (ret_var.is_owned) {
30643                 ret_ref |= 1;
30644         }
30645         return ret_ref;
30646 }
30647
30648 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
30649         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
30650 uint32_t ret_ref = 0;
30651 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30652 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30653 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30654 ret_ref = (uintptr_t)ret_var.inner;
30655 if (ret_var.is_owned) {
30656         ret_ref |= 1;
30657 }
30658         return ret_ref;
30659 }
30660 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
30661         LDKReplyChannelRange arg_conv;
30662         arg_conv.inner = (void*)(arg & (~1));
30663         arg_conv.is_owned = false;
30664         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30665         uint32_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
30666         return ret_val;
30667 }
30668
30669 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
30670         LDKReplyChannelRange orig_conv;
30671         orig_conv.inner = (void*)(orig & (~1));
30672         orig_conv.is_owned = false;
30673         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30674         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
30675         uint32_t ret_ref = 0;
30676         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30677         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30679         ret_ref = (uintptr_t)ret_var.inner;
30680         if (ret_var.is_owned) {
30681                 ret_ref |= 1;
30682         }
30683         return ret_ref;
30684 }
30685
30686 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
30687         LDKQueryShortChannelIds this_obj_conv;
30688         this_obj_conv.inner = (void*)(this_obj & (~1));
30689         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30691         QueryShortChannelIds_free(this_obj_conv);
30692 }
30693
30694 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
30695         LDKQueryShortChannelIds this_ptr_conv;
30696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30697         this_ptr_conv.is_owned = false;
30698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30699         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30700         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
30701         return ret_arr;
30702 }
30703
30704 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30705         LDKQueryShortChannelIds this_ptr_conv;
30706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30707         this_ptr_conv.is_owned = false;
30708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30709         LDKThirtyTwoBytes val_ref;
30710         CHECK(val->arr_len == 32);
30711         memcpy(val_ref.data, val->elems, 32); FREE(val);
30712         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
30713 }
30714
30715 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30716         LDKQueryShortChannelIds this_ptr_conv;
30717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30718         this_ptr_conv.is_owned = false;
30719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30720         LDKCVec_u64Z val_constr;
30721         val_constr.datalen = val->arr_len;
30722         if (val_constr.datalen > 0)
30723                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30724         else
30725                 val_constr.data = NULL;
30726         int64_t* val_vals = val->elems /* XXX val leaks */;
30727         for (size_t i = 0; i < val_constr.datalen; i++) {
30728                 int64_t val_conv_8 = val_vals[i];
30729                 val_constr.data[i] = val_conv_8;
30730         }
30731         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
30732 }
30733
30734 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
30735         LDKThirtyTwoBytes chain_hash_arg_ref;
30736         CHECK(chain_hash_arg->arr_len == 32);
30737         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30738         LDKCVec_u64Z short_channel_ids_arg_constr;
30739         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30740         if (short_channel_ids_arg_constr.datalen > 0)
30741                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30742         else
30743                 short_channel_ids_arg_constr.data = NULL;
30744         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30745         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30746                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30747                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30748         }
30749         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
30750         uint32_t ret_ref = 0;
30751         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30752         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30754         ret_ref = (uintptr_t)ret_var.inner;
30755         if (ret_var.is_owned) {
30756                 ret_ref |= 1;
30757         }
30758         return ret_ref;
30759 }
30760
30761 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
30762         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
30763 uint32_t ret_ref = 0;
30764 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30765 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30766 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30767 ret_ref = (uintptr_t)ret_var.inner;
30768 if (ret_var.is_owned) {
30769         ret_ref |= 1;
30770 }
30771         return ret_ref;
30772 }
30773 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
30774         LDKQueryShortChannelIds arg_conv;
30775         arg_conv.inner = (void*)(arg & (~1));
30776         arg_conv.is_owned = false;
30777         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30778         uint32_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
30779         return ret_val;
30780 }
30781
30782 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
30783         LDKQueryShortChannelIds orig_conv;
30784         orig_conv.inner = (void*)(orig & (~1));
30785         orig_conv.is_owned = false;
30786         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30787         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
30788         uint32_t ret_ref = 0;
30789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30792         ret_ref = (uintptr_t)ret_var.inner;
30793         if (ret_var.is_owned) {
30794                 ret_ref |= 1;
30795         }
30796         return ret_ref;
30797 }
30798
30799 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
30800         LDKReplyShortChannelIdsEnd this_obj_conv;
30801         this_obj_conv.inner = (void*)(this_obj & (~1));
30802         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30804         ReplyShortChannelIdsEnd_free(this_obj_conv);
30805 }
30806
30807 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
30808         LDKReplyShortChannelIdsEnd this_ptr_conv;
30809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30810         this_ptr_conv.is_owned = false;
30811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30812         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30813         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
30814         return ret_arr;
30815 }
30816
30817 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30818         LDKReplyShortChannelIdsEnd this_ptr_conv;
30819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30820         this_ptr_conv.is_owned = false;
30821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30822         LDKThirtyTwoBytes val_ref;
30823         CHECK(val->arr_len == 32);
30824         memcpy(val_ref.data, val->elems, 32); FREE(val);
30825         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
30826 }
30827
30828 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
30829         LDKReplyShortChannelIdsEnd this_ptr_conv;
30830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30831         this_ptr_conv.is_owned = false;
30832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30833         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
30834         return ret_val;
30835 }
30836
30837 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
30838         LDKReplyShortChannelIdsEnd this_ptr_conv;
30839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30840         this_ptr_conv.is_owned = false;
30841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30842         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
30843 }
30844
30845 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
30846         LDKThirtyTwoBytes chain_hash_arg_ref;
30847         CHECK(chain_hash_arg->arr_len == 32);
30848         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30849         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
30850         uint32_t ret_ref = 0;
30851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30854         ret_ref = (uintptr_t)ret_var.inner;
30855         if (ret_var.is_owned) {
30856                 ret_ref |= 1;
30857         }
30858         return ret_ref;
30859 }
30860
30861 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
30862         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
30863 uint32_t ret_ref = 0;
30864 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30865 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30866 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30867 ret_ref = (uintptr_t)ret_var.inner;
30868 if (ret_var.is_owned) {
30869         ret_ref |= 1;
30870 }
30871         return ret_ref;
30872 }
30873 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
30874         LDKReplyShortChannelIdsEnd arg_conv;
30875         arg_conv.inner = (void*)(arg & (~1));
30876         arg_conv.is_owned = false;
30877         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30878         uint32_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
30879         return ret_val;
30880 }
30881
30882 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
30883         LDKReplyShortChannelIdsEnd orig_conv;
30884         orig_conv.inner = (void*)(orig & (~1));
30885         orig_conv.is_owned = false;
30886         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30887         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
30888         uint32_t ret_ref = 0;
30889         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30890         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30892         ret_ref = (uintptr_t)ret_var.inner;
30893         if (ret_var.is_owned) {
30894                 ret_ref |= 1;
30895         }
30896         return ret_ref;
30897 }
30898
30899 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
30900         LDKGossipTimestampFilter this_obj_conv;
30901         this_obj_conv.inner = (void*)(this_obj & (~1));
30902         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30904         GossipTimestampFilter_free(this_obj_conv);
30905 }
30906
30907 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
30908         LDKGossipTimestampFilter this_ptr_conv;
30909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30910         this_ptr_conv.is_owned = false;
30911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30912         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30913         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
30914         return ret_arr;
30915 }
30916
30917 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30918         LDKGossipTimestampFilter this_ptr_conv;
30919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30920         this_ptr_conv.is_owned = false;
30921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30922         LDKThirtyTwoBytes val_ref;
30923         CHECK(val->arr_len == 32);
30924         memcpy(val_ref.data, val->elems, 32); FREE(val);
30925         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
30926 }
30927
30928 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
30929         LDKGossipTimestampFilter this_ptr_conv;
30930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30931         this_ptr_conv.is_owned = false;
30932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30933         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
30934         return ret_val;
30935 }
30936
30937 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
30938         LDKGossipTimestampFilter this_ptr_conv;
30939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30940         this_ptr_conv.is_owned = false;
30941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30942         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
30943 }
30944
30945 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
30946         LDKGossipTimestampFilter this_ptr_conv;
30947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30948         this_ptr_conv.is_owned = false;
30949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30950         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
30951         return ret_val;
30952 }
30953
30954 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
30955         LDKGossipTimestampFilter this_ptr_conv;
30956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30957         this_ptr_conv.is_owned = false;
30958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30959         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
30960 }
30961
30962 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) {
30963         LDKThirtyTwoBytes chain_hash_arg_ref;
30964         CHECK(chain_hash_arg->arr_len == 32);
30965         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30966         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
30967         uint32_t ret_ref = 0;
30968         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30969         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30970         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30971         ret_ref = (uintptr_t)ret_var.inner;
30972         if (ret_var.is_owned) {
30973                 ret_ref |= 1;
30974         }
30975         return ret_ref;
30976 }
30977
30978 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
30979         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
30980 uint32_t ret_ref = 0;
30981 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30982 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30983 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30984 ret_ref = (uintptr_t)ret_var.inner;
30985 if (ret_var.is_owned) {
30986         ret_ref |= 1;
30987 }
30988         return ret_ref;
30989 }
30990 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
30991         LDKGossipTimestampFilter arg_conv;
30992         arg_conv.inner = (void*)(arg & (~1));
30993         arg_conv.is_owned = false;
30994         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30995         uint32_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
30996         return ret_val;
30997 }
30998
30999 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
31000         LDKGossipTimestampFilter orig_conv;
31001         orig_conv.inner = (void*)(orig & (~1));
31002         orig_conv.is_owned = false;
31003         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31004         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
31005         uint32_t ret_ref = 0;
31006         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31007         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31009         ret_ref = (uintptr_t)ret_var.inner;
31010         if (ret_var.is_owned) {
31011                 ret_ref |= 1;
31012         }
31013         return ret_ref;
31014 }
31015
31016 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
31017         if ((this_ptr & 1) != 0) return;
31018         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31019         CHECK_ACCESS(this_ptr_ptr);
31020         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
31021         FREE((void*)this_ptr);
31022         ErrorAction_free(this_ptr_conv);
31023 }
31024
31025 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
31026         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31027         *ret_copy = ErrorAction_clone(arg);
31028 uint32_t ret_ref = (uintptr_t)ret_copy;
31029         return ret_ref;
31030 }
31031 uint32_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
31032         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
31033         uint32_t ret_val = ErrorAction_clone_ptr(arg_conv);
31034         return ret_val;
31035 }
31036
31037 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
31038         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
31039         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31040         *ret_copy = ErrorAction_clone(orig_conv);
31041         uint32_t ret_ref = (uintptr_t)ret_copy;
31042         return ret_ref;
31043 }
31044
31045 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
31046         LDKErrorMessage msg_conv;
31047         msg_conv.inner = (void*)(msg & (~1));
31048         msg_conv.is_owned = (msg & 1) || (msg == 0);
31049         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31050         msg_conv = ErrorMessage_clone(&msg_conv);
31051         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31052         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
31053         uint32_t ret_ref = (uintptr_t)ret_copy;
31054         return ret_ref;
31055 }
31056
31057 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
31058         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31059         *ret_copy = ErrorAction_ignore_error();
31060         uint32_t ret_ref = (uintptr_t)ret_copy;
31061         return ret_ref;
31062 }
31063
31064 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
31065         LDKLevel a_conv = LDKLevel_from_js(a);
31066         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31067         *ret_copy = ErrorAction_ignore_and_log(a_conv);
31068         uint32_t ret_ref = (uintptr_t)ret_copy;
31069         return ret_ref;
31070 }
31071
31072 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
31073         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31074         *ret_copy = ErrorAction_ignore_duplicate_gossip();
31075         uint32_t ret_ref = (uintptr_t)ret_copy;
31076         return ret_ref;
31077 }
31078
31079 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
31080         LDKErrorMessage msg_conv;
31081         msg_conv.inner = (void*)(msg & (~1));
31082         msg_conv.is_owned = (msg & 1) || (msg == 0);
31083         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31084         msg_conv = ErrorMessage_clone(&msg_conv);
31085         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31086         *ret_copy = ErrorAction_send_error_message(msg_conv);
31087         uint32_t ret_ref = (uintptr_t)ret_copy;
31088         return ret_ref;
31089 }
31090
31091 uint32_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint32_t msg, uint32_t log_level) {
31092         LDKWarningMessage msg_conv;
31093         msg_conv.inner = (void*)(msg & (~1));
31094         msg_conv.is_owned = (msg & 1) || (msg == 0);
31095         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31096         msg_conv = WarningMessage_clone(&msg_conv);
31097         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
31098         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31099         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
31100         uint32_t ret_ref = (uintptr_t)ret_copy;
31101         return ret_ref;
31102 }
31103
31104 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
31105         LDKLightningError this_obj_conv;
31106         this_obj_conv.inner = (void*)(this_obj & (~1));
31107         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31109         LightningError_free(this_obj_conv);
31110 }
31111
31112 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
31113         LDKLightningError this_ptr_conv;
31114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31115         this_ptr_conv.is_owned = false;
31116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31117         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
31118         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
31119         Str_free(ret_str);
31120         return ret_conv;
31121 }
31122
31123 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
31124         LDKLightningError this_ptr_conv;
31125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31126         this_ptr_conv.is_owned = false;
31127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31128         LDKStr val_conv = str_ref_to_owned_c(val);
31129         LightningError_set_err(&this_ptr_conv, val_conv);
31130 }
31131
31132 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
31133         LDKLightningError this_ptr_conv;
31134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31135         this_ptr_conv.is_owned = false;
31136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31137         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31138         *ret_copy = LightningError_get_action(&this_ptr_conv);
31139         uint32_t ret_ref = (uintptr_t)ret_copy;
31140         return ret_ref;
31141 }
31142
31143 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
31144         LDKLightningError this_ptr_conv;
31145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31146         this_ptr_conv.is_owned = false;
31147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31148         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31149         CHECK_ACCESS(val_ptr);
31150         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
31151         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
31152         LightningError_set_action(&this_ptr_conv, val_conv);
31153 }
31154
31155 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
31156         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
31157         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
31158         CHECK_ACCESS(action_arg_ptr);
31159         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
31160         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
31161         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
31162         uint32_t ret_ref = 0;
31163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31166         ret_ref = (uintptr_t)ret_var.inner;
31167         if (ret_var.is_owned) {
31168                 ret_ref |= 1;
31169         }
31170         return ret_ref;
31171 }
31172
31173 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
31174         LDKLightningError ret_var = LightningError_clone(arg);
31175 uint32_t ret_ref = 0;
31176 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31177 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31178 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31179 ret_ref = (uintptr_t)ret_var.inner;
31180 if (ret_var.is_owned) {
31181         ret_ref |= 1;
31182 }
31183         return ret_ref;
31184 }
31185 uint32_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
31186         LDKLightningError arg_conv;
31187         arg_conv.inner = (void*)(arg & (~1));
31188         arg_conv.is_owned = false;
31189         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31190         uint32_t ret_val = LightningError_clone_ptr(&arg_conv);
31191         return ret_val;
31192 }
31193
31194 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
31195         LDKLightningError orig_conv;
31196         orig_conv.inner = (void*)(orig & (~1));
31197         orig_conv.is_owned = false;
31198         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31199         LDKLightningError ret_var = LightningError_clone(&orig_conv);
31200         uint32_t ret_ref = 0;
31201         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31202         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31204         ret_ref = (uintptr_t)ret_var.inner;
31205         if (ret_var.is_owned) {
31206                 ret_ref |= 1;
31207         }
31208         return ret_ref;
31209 }
31210
31211 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
31212         LDKCommitmentUpdate this_obj_conv;
31213         this_obj_conv.inner = (void*)(this_obj & (~1));
31214         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31216         CommitmentUpdate_free(this_obj_conv);
31217 }
31218
31219 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
31220         LDKCommitmentUpdate this_ptr_conv;
31221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31222         this_ptr_conv.is_owned = false;
31223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31224         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
31225         uint32_tArray ret_arr = NULL;
31226         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31227         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31228         for (size_t p = 0; p < ret_var.datalen; p++) {
31229                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
31230                 uint32_t ret_conv_15_ref = 0;
31231                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31232                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31233                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
31234                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
31235                 if (ret_conv_15_var.is_owned) {
31236                         ret_conv_15_ref |= 1;
31237                 }
31238                 ret_arr_ptr[p] = ret_conv_15_ref;
31239         }
31240         
31241         FREE(ret_var.data);
31242         return ret_arr;
31243 }
31244
31245 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
31246         LDKCommitmentUpdate this_ptr_conv;
31247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31248         this_ptr_conv.is_owned = false;
31249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31250         LDKCVec_UpdateAddHTLCZ val_constr;
31251         val_constr.datalen = val->arr_len;
31252         if (val_constr.datalen > 0)
31253                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
31254         else
31255                 val_constr.data = NULL;
31256         uint32_t* val_vals = val->elems /* XXX val leaks */;
31257         for (size_t p = 0; p < val_constr.datalen; p++) {
31258                 uint32_t val_conv_15 = val_vals[p];
31259                 LDKUpdateAddHTLC val_conv_15_conv;
31260                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
31261                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
31262                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
31263                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
31264                 val_constr.data[p] = val_conv_15_conv;
31265         }
31266         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
31267 }
31268
31269 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
31270         LDKCommitmentUpdate this_ptr_conv;
31271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31272         this_ptr_conv.is_owned = false;
31273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31274         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
31275         uint32_tArray ret_arr = NULL;
31276         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31277         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31278         for (size_t t = 0; t < ret_var.datalen; t++) {
31279                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
31280                 uint32_t ret_conv_19_ref = 0;
31281                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31282                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31283                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
31284                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
31285                 if (ret_conv_19_var.is_owned) {
31286                         ret_conv_19_ref |= 1;
31287                 }
31288                 ret_arr_ptr[t] = ret_conv_19_ref;
31289         }
31290         
31291         FREE(ret_var.data);
31292         return ret_arr;
31293 }
31294
31295 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
31296         LDKCommitmentUpdate this_ptr_conv;
31297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31298         this_ptr_conv.is_owned = false;
31299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31300         LDKCVec_UpdateFulfillHTLCZ val_constr;
31301         val_constr.datalen = val->arr_len;
31302         if (val_constr.datalen > 0)
31303                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
31304         else
31305                 val_constr.data = NULL;
31306         uint32_t* val_vals = val->elems /* XXX val leaks */;
31307         for (size_t t = 0; t < val_constr.datalen; t++) {
31308                 uint32_t val_conv_19 = val_vals[t];
31309                 LDKUpdateFulfillHTLC val_conv_19_conv;
31310                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
31311                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
31312                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
31313                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
31314                 val_constr.data[t] = val_conv_19_conv;
31315         }
31316         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
31317 }
31318
31319 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
31320         LDKCommitmentUpdate this_ptr_conv;
31321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31322         this_ptr_conv.is_owned = false;
31323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31324         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
31325         uint32_tArray ret_arr = NULL;
31326         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31327         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31328         for (size_t q = 0; q < ret_var.datalen; q++) {
31329                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
31330                 uint32_t ret_conv_16_ref = 0;
31331                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31332                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31333                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31334                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
31335                 if (ret_conv_16_var.is_owned) {
31336                         ret_conv_16_ref |= 1;
31337                 }
31338                 ret_arr_ptr[q] = ret_conv_16_ref;
31339         }
31340         
31341         FREE(ret_var.data);
31342         return ret_arr;
31343 }
31344
31345 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
31346         LDKCommitmentUpdate this_ptr_conv;
31347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31348         this_ptr_conv.is_owned = false;
31349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31350         LDKCVec_UpdateFailHTLCZ val_constr;
31351         val_constr.datalen = val->arr_len;
31352         if (val_constr.datalen > 0)
31353                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
31354         else
31355                 val_constr.data = NULL;
31356         uint32_t* val_vals = val->elems /* XXX val leaks */;
31357         for (size_t q = 0; q < val_constr.datalen; q++) {
31358                 uint32_t val_conv_16 = val_vals[q];
31359                 LDKUpdateFailHTLC val_conv_16_conv;
31360                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
31361                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
31362                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
31363                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
31364                 val_constr.data[q] = val_conv_16_conv;
31365         }
31366         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
31367 }
31368
31369 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
31370         LDKCommitmentUpdate this_ptr_conv;
31371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31372         this_ptr_conv.is_owned = false;
31373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31374         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
31375         uint32_tArray ret_arr = NULL;
31376         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31377         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31378         for (size_t z = 0; z < ret_var.datalen; z++) {
31379                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
31380                 uint32_t ret_conv_25_ref = 0;
31381                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31382                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31383                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
31384                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
31385                 if (ret_conv_25_var.is_owned) {
31386                         ret_conv_25_ref |= 1;
31387                 }
31388                 ret_arr_ptr[z] = ret_conv_25_ref;
31389         }
31390         
31391         FREE(ret_var.data);
31392         return ret_arr;
31393 }
31394
31395 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) {
31396         LDKCommitmentUpdate this_ptr_conv;
31397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31398         this_ptr_conv.is_owned = false;
31399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31400         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
31401         val_constr.datalen = val->arr_len;
31402         if (val_constr.datalen > 0)
31403                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
31404         else
31405                 val_constr.data = NULL;
31406         uint32_t* val_vals = val->elems /* XXX val leaks */;
31407         for (size_t z = 0; z < val_constr.datalen; z++) {
31408                 uint32_t val_conv_25 = val_vals[z];
31409                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
31410                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
31411                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
31412                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
31413                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
31414                 val_constr.data[z] = val_conv_25_conv;
31415         }
31416         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
31417 }
31418
31419 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
31420         LDKCommitmentUpdate this_ptr_conv;
31421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31422         this_ptr_conv.is_owned = false;
31423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31424         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
31425         uint32_t ret_ref = 0;
31426         if ((uintptr_t)ret_var.inner > 4096) {
31427                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31428                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31430                 ret_ref = (uintptr_t)ret_var.inner;
31431                 if (ret_var.is_owned) {
31432                         ret_ref |= 1;
31433                 }
31434         }
31435         return ret_ref;
31436 }
31437
31438 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
31439         LDKCommitmentUpdate this_ptr_conv;
31440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31441         this_ptr_conv.is_owned = false;
31442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31443         LDKUpdateFee val_conv;
31444         val_conv.inner = (void*)(val & (~1));
31445         val_conv.is_owned = (val & 1) || (val == 0);
31446         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31447         val_conv = UpdateFee_clone(&val_conv);
31448         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
31449 }
31450
31451 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
31452         LDKCommitmentUpdate this_ptr_conv;
31453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31454         this_ptr_conv.is_owned = false;
31455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31456         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
31457         uint32_t ret_ref = 0;
31458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31461         ret_ref = (uintptr_t)ret_var.inner;
31462         if (ret_var.is_owned) {
31463                 ret_ref |= 1;
31464         }
31465         return ret_ref;
31466 }
31467
31468 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
31469         LDKCommitmentUpdate this_ptr_conv;
31470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31471         this_ptr_conv.is_owned = false;
31472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31473         LDKCommitmentSigned val_conv;
31474         val_conv.inner = (void*)(val & (~1));
31475         val_conv.is_owned = (val & 1) || (val == 0);
31476         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31477         val_conv = CommitmentSigned_clone(&val_conv);
31478         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
31479 }
31480
31481 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) {
31482         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
31483         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
31484         if (update_add_htlcs_arg_constr.datalen > 0)
31485                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
31486         else
31487                 update_add_htlcs_arg_constr.data = NULL;
31488         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems /* XXX update_add_htlcs_arg leaks */;
31489         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
31490                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
31491                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
31492                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
31493                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
31494                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
31495                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
31496                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
31497         }
31498         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
31499         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
31500         if (update_fulfill_htlcs_arg_constr.datalen > 0)
31501                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
31502         else
31503                 update_fulfill_htlcs_arg_constr.data = NULL;
31504         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems /* XXX update_fulfill_htlcs_arg leaks */;
31505         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
31506                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
31507                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
31508                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
31509                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
31510                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
31511                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
31512                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
31513         }
31514         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
31515         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
31516         if (update_fail_htlcs_arg_constr.datalen > 0)
31517                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
31518         else
31519                 update_fail_htlcs_arg_constr.data = NULL;
31520         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems /* XXX update_fail_htlcs_arg leaks */;
31521         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
31522                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
31523                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
31524                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
31525                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
31526                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
31527                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
31528                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
31529         }
31530         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
31531         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
31532         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
31533                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
31534         else
31535                 update_fail_malformed_htlcs_arg_constr.data = NULL;
31536         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems /* XXX update_fail_malformed_htlcs_arg leaks */;
31537         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
31538                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
31539                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
31540                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
31541                 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);
31542                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
31543                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
31544                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
31545         }
31546         LDKUpdateFee update_fee_arg_conv;
31547         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
31548         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
31549         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
31550         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
31551         LDKCommitmentSigned commitment_signed_arg_conv;
31552         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
31553         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
31554         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
31555         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
31556         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);
31557         uint32_t ret_ref = 0;
31558         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31559         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31561         ret_ref = (uintptr_t)ret_var.inner;
31562         if (ret_var.is_owned) {
31563                 ret_ref |= 1;
31564         }
31565         return ret_ref;
31566 }
31567
31568 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
31569         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
31570 uint32_t ret_ref = 0;
31571 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31572 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31573 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31574 ret_ref = (uintptr_t)ret_var.inner;
31575 if (ret_var.is_owned) {
31576         ret_ref |= 1;
31577 }
31578         return ret_ref;
31579 }
31580 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
31581         LDKCommitmentUpdate arg_conv;
31582         arg_conv.inner = (void*)(arg & (~1));
31583         arg_conv.is_owned = false;
31584         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31585         uint32_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
31586         return ret_val;
31587 }
31588
31589 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
31590         LDKCommitmentUpdate orig_conv;
31591         orig_conv.inner = (void*)(orig & (~1));
31592         orig_conv.is_owned = false;
31593         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31594         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
31595         uint32_t ret_ref = 0;
31596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31599         ret_ref = (uintptr_t)ret_var.inner;
31600         if (ret_var.is_owned) {
31601                 ret_ref |= 1;
31602         }
31603         return ret_ref;
31604 }
31605
31606 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
31607         if ((this_ptr & 1) != 0) return;
31608         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31609         CHECK_ACCESS(this_ptr_ptr);
31610         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
31611         FREE((void*)this_ptr);
31612         ChannelMessageHandler_free(this_ptr_conv);
31613 }
31614
31615 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
31616         if ((this_ptr & 1) != 0) return;
31617         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31618         CHECK_ACCESS(this_ptr_ptr);
31619         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
31620         FREE((void*)this_ptr);
31621         RoutingMessageHandler_free(this_ptr_conv);
31622 }
31623
31624 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
31625         LDKAcceptChannel obj_conv;
31626         obj_conv.inner = (void*)(obj & (~1));
31627         obj_conv.is_owned = false;
31628         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31629         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
31630         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31631         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31632         CVec_u8Z_free(ret_var);
31633         return ret_arr;
31634 }
31635
31636 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
31637         LDKu8slice ser_ref;
31638         ser_ref.datalen = ser->arr_len;
31639         ser_ref.data = ser->elems /* XXX ser leaks */;
31640         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
31641         *ret_conv = AcceptChannel_read(ser_ref);
31642         return (uint32_t)ret_conv;
31643 }
31644
31645 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
31646         LDKAnnouncementSignatures obj_conv;
31647         obj_conv.inner = (void*)(obj & (~1));
31648         obj_conv.is_owned = false;
31649         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31650         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
31651         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31652         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31653         CVec_u8Z_free(ret_var);
31654         return ret_arr;
31655 }
31656
31657 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
31658         LDKu8slice ser_ref;
31659         ser_ref.datalen = ser->arr_len;
31660         ser_ref.data = ser->elems /* XXX ser leaks */;
31661         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
31662         *ret_conv = AnnouncementSignatures_read(ser_ref);
31663         return (uint32_t)ret_conv;
31664 }
31665
31666 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
31667         LDKChannelReestablish obj_conv;
31668         obj_conv.inner = (void*)(obj & (~1));
31669         obj_conv.is_owned = false;
31670         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31671         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
31672         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31673         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31674         CVec_u8Z_free(ret_var);
31675         return ret_arr;
31676 }
31677
31678 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
31679         LDKu8slice ser_ref;
31680         ser_ref.datalen = ser->arr_len;
31681         ser_ref.data = ser->elems /* XXX ser leaks */;
31682         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
31683         *ret_conv = ChannelReestablish_read(ser_ref);
31684         return (uint32_t)ret_conv;
31685 }
31686
31687 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
31688         LDKClosingSigned 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 = ClosingSigned_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_ClosingSigned_read"))) TS_ClosingSigned_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_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
31704         *ret_conv = ClosingSigned_read(ser_ref);
31705         return (uint32_t)ret_conv;
31706 }
31707
31708 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
31709         LDKClosingSignedFeeRange 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 = ClosingSignedFeeRange_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_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_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_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
31725         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
31726         return (uint32_t)ret_conv;
31727 }
31728
31729 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
31730         LDKCommitmentSigned 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 = CommitmentSigned_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_CommitmentSigned_read"))) TS_CommitmentSigned_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_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
31746         *ret_conv = CommitmentSigned_read(ser_ref);
31747         return (uint32_t)ret_conv;
31748 }
31749
31750 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
31751         LDKFundingCreated 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 = FundingCreated_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_FundingCreated_read"))) TS_FundingCreated_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_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
31767         *ret_conv = FundingCreated_read(ser_ref);
31768         return (uint32_t)ret_conv;
31769 }
31770
31771 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
31772         LDKFundingSigned 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 = FundingSigned_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_FundingSigned_read"))) TS_FundingSigned_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_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
31788         *ret_conv = FundingSigned_read(ser_ref);
31789         return (uint32_t)ret_conv;
31790 }
31791
31792 int8_tArray  __attribute__((export_name("TS_FundingLocked_write"))) TS_FundingLocked_write(uint32_t obj) {
31793         LDKFundingLocked 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 = FundingLocked_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_FundingLocked_read"))) TS_FundingLocked_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_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
31809         *ret_conv = FundingLocked_read(ser_ref);
31810         return (uint32_t)ret_conv;
31811 }
31812
31813 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
31814         LDKInit 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 = Init_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_Init_read"))) TS_Init_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_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
31830         *ret_conv = Init_read(ser_ref);
31831         return (uint32_t)ret_conv;
31832 }
31833
31834 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
31835         LDKOpenChannel 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 = OpenChannel_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_OpenChannel_read"))) TS_OpenChannel_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_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
31851         *ret_conv = OpenChannel_read(ser_ref);
31852         return (uint32_t)ret_conv;
31853 }
31854
31855 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
31856         LDKRevokeAndACK 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 = RevokeAndACK_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_RevokeAndACK_read"))) TS_RevokeAndACK_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_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
31872         *ret_conv = RevokeAndACK_read(ser_ref);
31873         return (uint32_t)ret_conv;
31874 }
31875
31876 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
31877         LDKShutdown 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 = Shutdown_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_Shutdown_read"))) TS_Shutdown_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_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
31893         *ret_conv = Shutdown_read(ser_ref);
31894         return (uint32_t)ret_conv;
31895 }
31896
31897 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
31898         LDKUpdateFailHTLC 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 = UpdateFailHTLC_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_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_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_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
31914         *ret_conv = UpdateFailHTLC_read(ser_ref);
31915         return (uint32_t)ret_conv;
31916 }
31917
31918 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
31919         LDKUpdateFailMalformedHTLC 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 = UpdateFailMalformedHTLC_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_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_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_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
31935         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
31936         return (uint32_t)ret_conv;
31937 }
31938
31939 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
31940         LDKUpdateFee 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 = UpdateFee_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_UpdateFee_read"))) TS_UpdateFee_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_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
31956         *ret_conv = UpdateFee_read(ser_ref);
31957         return (uint32_t)ret_conv;
31958 }
31959
31960 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
31961         LDKUpdateFulfillHTLC 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 = UpdateFulfillHTLC_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_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_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_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
31977         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
31978         return (uint32_t)ret_conv;
31979 }
31980
31981 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
31982         LDKUpdateAddHTLC 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 = UpdateAddHTLC_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_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_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_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
31998         *ret_conv = UpdateAddHTLC_read(ser_ref);
31999         return (uint32_t)ret_conv;
32000 }
32001
32002 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
32003         LDKPing 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 = Ping_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_Ping_read"))) TS_Ping_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_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
32019         *ret_conv = Ping_read(ser_ref);
32020         return (uint32_t)ret_conv;
32021 }
32022
32023 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
32024         LDKPong 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 = Pong_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_Pong_read"))) TS_Pong_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_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
32040         *ret_conv = Pong_read(ser_ref);
32041         return (uint32_t)ret_conv;
32042 }
32043
32044 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
32045         LDKUnsignedChannelAnnouncement 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 = UnsignedChannelAnnouncement_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_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_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_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
32061         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
32062         return (uint32_t)ret_conv;
32063 }
32064
32065 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
32066         LDKChannelAnnouncement 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 = ChannelAnnouncement_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_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_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_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
32082         *ret_conv = ChannelAnnouncement_read(ser_ref);
32083         return (uint32_t)ret_conv;
32084 }
32085
32086 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
32087         LDKUnsignedChannelUpdate 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 = UnsignedChannelUpdate_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_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_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_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
32103         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
32104         return (uint32_t)ret_conv;
32105 }
32106
32107 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
32108         LDKChannelUpdate 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 = ChannelUpdate_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_ChannelUpdate_read"))) TS_ChannelUpdate_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_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
32124         *ret_conv = ChannelUpdate_read(ser_ref);
32125         return (uint32_t)ret_conv;
32126 }
32127
32128 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
32129         LDKErrorMessage 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 = ErrorMessage_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_ErrorMessage_read"))) TS_ErrorMessage_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_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
32145         *ret_conv = ErrorMessage_read(ser_ref);
32146         return (uint32_t)ret_conv;
32147 }
32148
32149 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint32_t obj) {
32150         LDKWarningMessage 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 = WarningMessage_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_WarningMessage_read"))) TS_WarningMessage_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_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
32166         *ret_conv = WarningMessage_read(ser_ref);
32167         return (uint32_t)ret_conv;
32168 }
32169
32170 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
32171         LDKUnsignedNodeAnnouncement 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 = UnsignedNodeAnnouncement_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_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_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_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
32187         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
32188         return (uint32_t)ret_conv;
32189 }
32190
32191 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
32192         LDKNodeAnnouncement 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 = NodeAnnouncement_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_NodeAnnouncement_read"))) TS_NodeAnnouncement_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_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
32208         *ret_conv = NodeAnnouncement_read(ser_ref);
32209         return (uint32_t)ret_conv;
32210 }
32211
32212 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
32213         LDKu8slice ser_ref;
32214         ser_ref.datalen = ser->arr_len;
32215         ser_ref.data = ser->elems /* XXX ser leaks */;
32216         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
32217         *ret_conv = QueryShortChannelIds_read(ser_ref);
32218         return (uint32_t)ret_conv;
32219 }
32220
32221 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
32222         LDKQueryShortChannelIds obj_conv;
32223         obj_conv.inner = (void*)(obj & (~1));
32224         obj_conv.is_owned = false;
32225         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32226         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
32227         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32228         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32229         CVec_u8Z_free(ret_var);
32230         return ret_arr;
32231 }
32232
32233 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
32234         LDKReplyShortChannelIdsEnd 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 = ReplyShortChannelIdsEnd_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_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_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_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
32250         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
32251         return (uint32_t)ret_conv;
32252 }
32253
32254 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
32255         LDKQueryChannelRange this_arg_conv;
32256         this_arg_conv.inner = (void*)(this_arg & (~1));
32257         this_arg_conv.is_owned = false;
32258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32259         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
32260         return ret_val;
32261 }
32262
32263 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
32264         LDKQueryChannelRange obj_conv;
32265         obj_conv.inner = (void*)(obj & (~1));
32266         obj_conv.is_owned = false;
32267         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32268         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
32269         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32270         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32271         CVec_u8Z_free(ret_var);
32272         return ret_arr;
32273 }
32274
32275 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_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_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
32280         *ret_conv = QueryChannelRange_read(ser_ref);
32281         return (uint32_t)ret_conv;
32282 }
32283
32284 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
32285         LDKu8slice ser_ref;
32286         ser_ref.datalen = ser->arr_len;
32287         ser_ref.data = ser->elems /* XXX ser leaks */;
32288         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
32289         *ret_conv = ReplyChannelRange_read(ser_ref);
32290         return (uint32_t)ret_conv;
32291 }
32292
32293 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
32294         LDKReplyChannelRange obj_conv;
32295         obj_conv.inner = (void*)(obj & (~1));
32296         obj_conv.is_owned = false;
32297         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32298         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
32299         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32300         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32301         CVec_u8Z_free(ret_var);
32302         return ret_arr;
32303 }
32304
32305 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
32306         LDKGossipTimestampFilter obj_conv;
32307         obj_conv.inner = (void*)(obj & (~1));
32308         obj_conv.is_owned = false;
32309         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32310         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
32311         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32312         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32313         CVec_u8Z_free(ret_var);
32314         return ret_arr;
32315 }
32316
32317 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
32318         LDKu8slice ser_ref;
32319         ser_ref.datalen = ser->arr_len;
32320         ser_ref.data = ser->elems /* XXX ser leaks */;
32321         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
32322         *ret_conv = GossipTimestampFilter_read(ser_ref);
32323         return (uint32_t)ret_conv;
32324 }
32325
32326 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
32327         if ((this_ptr & 1) != 0) return;
32328         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32329         CHECK_ACCESS(this_ptr_ptr);
32330         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
32331         FREE((void*)this_ptr);
32332         CustomMessageHandler_free(this_ptr_conv);
32333 }
32334
32335 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
32336         LDKIgnoringMessageHandler this_obj_conv;
32337         this_obj_conv.inner = (void*)(this_obj & (~1));
32338         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32340         IgnoringMessageHandler_free(this_obj_conv);
32341 }
32342
32343 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
32344         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
32345         uint32_t ret_ref = 0;
32346         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32347         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32349         ret_ref = (uintptr_t)ret_var.inner;
32350         if (ret_var.is_owned) {
32351                 ret_ref |= 1;
32352         }
32353         return ret_ref;
32354 }
32355
32356 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
32357         LDKIgnoringMessageHandler this_arg_conv;
32358         this_arg_conv.inner = (void*)(this_arg & (~1));
32359         this_arg_conv.is_owned = false;
32360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32361         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32362         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
32363         return (uint32_t)ret_ret;
32364 }
32365
32366 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
32367         LDKIgnoringMessageHandler this_arg_conv;
32368         this_arg_conv.inner = (void*)(this_arg & (~1));
32369         this_arg_conv.is_owned = false;
32370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32371         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
32372         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
32373         return (uint32_t)ret_ret;
32374 }
32375
32376 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
32377         LDKIgnoringMessageHandler this_arg_conv;
32378         this_arg_conv.inner = (void*)(this_arg & (~1));
32379         this_arg_conv.is_owned = false;
32380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32381         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
32382         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
32383         return (uint32_t)ret_ret;
32384 }
32385
32386 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
32387         LDKIgnoringMessageHandler this_arg_conv;
32388         this_arg_conv.inner = (void*)(this_arg & (~1));
32389         this_arg_conv.is_owned = false;
32390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32391         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
32392         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
32393         return (uint32_t)ret_ret;
32394 }
32395
32396 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
32397         LDKErroringMessageHandler this_obj_conv;
32398         this_obj_conv.inner = (void*)(this_obj & (~1));
32399         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32401         ErroringMessageHandler_free(this_obj_conv);
32402 }
32403
32404 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
32405         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
32406         uint32_t ret_ref = 0;
32407         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32408         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32410         ret_ref = (uintptr_t)ret_var.inner;
32411         if (ret_var.is_owned) {
32412                 ret_ref |= 1;
32413         }
32414         return ret_ref;
32415 }
32416
32417 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
32418         LDKErroringMessageHandler this_arg_conv;
32419         this_arg_conv.inner = (void*)(this_arg & (~1));
32420         this_arg_conv.is_owned = false;
32421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32422         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32423         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
32424         return (uint32_t)ret_ret;
32425 }
32426
32427 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
32428         LDKErroringMessageHandler this_arg_conv;
32429         this_arg_conv.inner = (void*)(this_arg & (~1));
32430         this_arg_conv.is_owned = false;
32431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32432         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
32433         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
32434         return (uint32_t)ret_ret;
32435 }
32436
32437 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
32438         LDKMessageHandler this_obj_conv;
32439         this_obj_conv.inner = (void*)(this_obj & (~1));
32440         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32442         MessageHandler_free(this_obj_conv);
32443 }
32444
32445 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
32446         LDKMessageHandler this_ptr_conv;
32447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32448         this_ptr_conv.is_owned = false;
32449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32450         // WARNING: This object doesn't live past this scope, needs clone!
32451         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
32452         return ret_ret;
32453 }
32454
32455 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
32456         LDKMessageHandler this_ptr_conv;
32457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32458         this_ptr_conv.is_owned = false;
32459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32460         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32461         CHECK_ACCESS(val_ptr);
32462         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
32463         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
32464                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32465                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
32466         }
32467         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
32468 }
32469
32470 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
32471         LDKMessageHandler this_ptr_conv;
32472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32473         this_ptr_conv.is_owned = false;
32474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32475         // WARNING: This object doesn't live past this scope, needs clone!
32476         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
32477         return ret_ret;
32478 }
32479
32480 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
32481         LDKMessageHandler this_ptr_conv;
32482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32483         this_ptr_conv.is_owned = false;
32484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32485         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32486         CHECK_ACCESS(val_ptr);
32487         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
32488         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
32489                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32490                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
32491         }
32492         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
32493 }
32494
32495 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
32496         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
32497         CHECK_ACCESS(chan_handler_arg_ptr);
32498         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
32499         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
32500                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32501                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
32502         }
32503         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
32504         CHECK_ACCESS(route_handler_arg_ptr);
32505         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
32506         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
32507                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32508                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
32509         }
32510         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
32511         uint32_t ret_ref = 0;
32512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32515         ret_ref = (uintptr_t)ret_var.inner;
32516         if (ret_var.is_owned) {
32517                 ret_ref |= 1;
32518         }
32519         return ret_ref;
32520 }
32521
32522 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
32523         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
32524         *ret_ret = SocketDescriptor_clone(arg);
32525         return (uint32_t)ret_ret;
32526 }
32527 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
32528         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
32529         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
32530         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
32531         uint32_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
32532         return ret_val;
32533 }
32534
32535 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
32536         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
32537         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
32538         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
32539         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
32540         *ret_ret = SocketDescriptor_clone(orig_conv);
32541         return (uint32_t)ret_ret;
32542 }
32543
32544 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
32545         if ((this_ptr & 1) != 0) return;
32546         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32547         CHECK_ACCESS(this_ptr_ptr);
32548         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
32549         FREE((void*)this_ptr);
32550         SocketDescriptor_free(this_ptr_conv);
32551 }
32552
32553 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
32554         LDKPeerHandleError this_obj_conv;
32555         this_obj_conv.inner = (void*)(this_obj & (~1));
32556         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32558         PeerHandleError_free(this_obj_conv);
32559 }
32560
32561 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
32562         LDKPeerHandleError this_ptr_conv;
32563         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32564         this_ptr_conv.is_owned = false;
32565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32566         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
32567         return ret_val;
32568 }
32569
32570 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
32571         LDKPeerHandleError this_ptr_conv;
32572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32573         this_ptr_conv.is_owned = false;
32574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32575         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
32576 }
32577
32578 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
32579         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
32580         uint32_t ret_ref = 0;
32581         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32582         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32584         ret_ref = (uintptr_t)ret_var.inner;
32585         if (ret_var.is_owned) {
32586                 ret_ref |= 1;
32587         }
32588         return ret_ref;
32589 }
32590
32591 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
32592         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
32593 uint32_t ret_ref = 0;
32594 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32595 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32596 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32597 ret_ref = (uintptr_t)ret_var.inner;
32598 if (ret_var.is_owned) {
32599         ret_ref |= 1;
32600 }
32601         return ret_ref;
32602 }
32603 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
32604         LDKPeerHandleError arg_conv;
32605         arg_conv.inner = (void*)(arg & (~1));
32606         arg_conv.is_owned = false;
32607         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32608         uint32_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
32609         return ret_val;
32610 }
32611
32612 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
32613         LDKPeerHandleError orig_conv;
32614         orig_conv.inner = (void*)(orig & (~1));
32615         orig_conv.is_owned = false;
32616         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32617         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
32618         uint32_t ret_ref = 0;
32619         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32620         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32622         ret_ref = (uintptr_t)ret_var.inner;
32623         if (ret_var.is_owned) {
32624                 ret_ref |= 1;
32625         }
32626         return ret_ref;
32627 }
32628
32629 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
32630         LDKPeerManager this_obj_conv;
32631         this_obj_conv.inner = (void*)(this_obj & (~1));
32632         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32634         PeerManager_free(this_obj_conv);
32635 }
32636
32637 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) {
32638         LDKMessageHandler message_handler_conv;
32639         message_handler_conv.inner = (void*)(message_handler & (~1));
32640         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
32641         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
32642         // WARNING: we need a move here but no clone is available for LDKMessageHandler
32643         LDKSecretKey our_node_secret_ref;
32644         CHECK(our_node_secret->arr_len == 32);
32645         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
32646         unsigned char ephemeral_random_data_arr[32];
32647         CHECK(ephemeral_random_data->arr_len == 32);
32648         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
32649         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
32650         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
32651         CHECK_ACCESS(logger_ptr);
32652         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32653         if (logger_conv.free == LDKLogger_JCalls_free) {
32654                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32655                 LDKLogger_JCalls_cloned(&logger_conv);
32656         }
32657         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
32658         CHECK_ACCESS(custom_message_handler_ptr);
32659         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
32660         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
32661                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32662                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
32663         }
32664         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
32665         uint32_t ret_ref = 0;
32666         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32667         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32669         ret_ref = (uintptr_t)ret_var.inner;
32670         if (ret_var.is_owned) {
32671                 ret_ref |= 1;
32672         }
32673         return ret_ref;
32674 }
32675
32676 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
32677         LDKPeerManager this_arg_conv;
32678         this_arg_conv.inner = (void*)(this_arg & (~1));
32679         this_arg_conv.is_owned = false;
32680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32681         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
32682         ptrArray ret_arr = NULL;
32683         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
32684         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
32685         for (size_t m = 0; m < ret_var.datalen; m++) {
32686                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
32687                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
32688                 ret_arr_ptr[m] = ret_conv_12_arr;
32689         }
32690         
32691         FREE(ret_var.data);
32692         return ret_arr;
32693 }
32694
32695 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) {
32696         LDKPeerManager this_arg_conv;
32697         this_arg_conv.inner = (void*)(this_arg & (~1));
32698         this_arg_conv.is_owned = false;
32699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32700         LDKPublicKey their_node_id_ref;
32701         CHECK(their_node_id->arr_len == 33);
32702         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
32703         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32704         CHECK_ACCESS(descriptor_ptr);
32705         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32706         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
32707                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32708                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
32709         }
32710         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
32711         CHECK_ACCESS(remote_network_address_ptr);
32712         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
32713         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
32714         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
32715         return (uint32_t)ret_conv;
32716 }
32717
32718 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) {
32719         LDKPeerManager this_arg_conv;
32720         this_arg_conv.inner = (void*)(this_arg & (~1));
32721         this_arg_conv.is_owned = false;
32722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32723         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32724         CHECK_ACCESS(descriptor_ptr);
32725         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32726         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
32727                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32728                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
32729         }
32730         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
32731         CHECK_ACCESS(remote_network_address_ptr);
32732         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
32733         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32734         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
32735         return (uint32_t)ret_conv;
32736 }
32737
32738 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
32739         LDKPeerManager this_arg_conv;
32740         this_arg_conv.inner = (void*)(this_arg & (~1));
32741         this_arg_conv.is_owned = false;
32742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32743         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32744         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32745         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32746         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32747         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
32748         return (uint32_t)ret_conv;
32749 }
32750
32751 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
32752         LDKPeerManager this_arg_conv;
32753         this_arg_conv.inner = (void*)(this_arg & (~1));
32754         this_arg_conv.is_owned = false;
32755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32756         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
32757         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
32758         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
32759         LDKu8slice data_ref;
32760         data_ref.datalen = data->arr_len;
32761         data_ref.data = data->elems /* XXX data leaks */;
32762         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
32763         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
32764         return (uint32_t)ret_conv;
32765 }
32766
32767 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
32768         LDKPeerManager this_arg_conv;
32769         this_arg_conv.inner = (void*)(this_arg & (~1));
32770         this_arg_conv.is_owned = false;
32771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32772         PeerManager_process_events(&this_arg_conv);
32773 }
32774
32775 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
32776         LDKPeerManager this_arg_conv;
32777         this_arg_conv.inner = (void*)(this_arg & (~1));
32778         this_arg_conv.is_owned = false;
32779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32780         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32781         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32782         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32783         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
32784 }
32785
32786 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) {
32787         LDKPeerManager this_arg_conv;
32788         this_arg_conv.inner = (void*)(this_arg & (~1));
32789         this_arg_conv.is_owned = false;
32790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32791         LDKPublicKey node_id_ref;
32792         CHECK(node_id->arr_len == 33);
32793         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
32794         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
32795 }
32796
32797 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
32798         LDKPeerManager this_arg_conv;
32799         this_arg_conv.inner = (void*)(this_arg & (~1));
32800         this_arg_conv.is_owned = false;
32801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32802         PeerManager_disconnect_all_peers(&this_arg_conv);
32803 }
32804
32805 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
32806         LDKPeerManager this_arg_conv;
32807         this_arg_conv.inner = (void*)(this_arg & (~1));
32808         this_arg_conv.is_owned = false;
32809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32810         PeerManager_timer_tick_occurred(&this_arg_conv);
32811 }
32812
32813 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
32814         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
32815         return ret_val;
32816 }
32817
32818 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
32819         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
32820         return ret_val;
32821 }
32822
32823 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
32824         unsigned char commitment_seed_arr[32];
32825         CHECK(commitment_seed->arr_len == 32);
32826         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
32827         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
32828         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32829         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
32830         return ret_arr;
32831 }
32832
32833 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) {
32834         LDKCVec_u8Z to_holder_script_ref;
32835         to_holder_script_ref.datalen = to_holder_script->arr_len;
32836         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
32837         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
32838         LDKCVec_u8Z to_counterparty_script_ref;
32839         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
32840         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
32841         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
32842         LDKOutPoint funding_outpoint_conv;
32843         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
32844         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
32845         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
32846         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
32847         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);
32848         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32849         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32850         Transaction_free(ret_var);
32851         return ret_arr;
32852 }
32853
32854 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint32_t this_obj) {
32855         LDKCounterpartyCommitmentSecrets this_obj_conv;
32856         this_obj_conv.inner = (void*)(this_obj & (~1));
32857         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32859         CounterpartyCommitmentSecrets_free(this_obj_conv);
32860 }
32861
32862 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
32863         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
32864 uint32_t ret_ref = 0;
32865 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32866 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32867 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32868 ret_ref = (uintptr_t)ret_var.inner;
32869 if (ret_var.is_owned) {
32870         ret_ref |= 1;
32871 }
32872         return ret_ref;
32873 }
32874 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint32_t arg) {
32875         LDKCounterpartyCommitmentSecrets arg_conv;
32876         arg_conv.inner = (void*)(arg & (~1));
32877         arg_conv.is_owned = false;
32878         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32879         uint32_t ret_val = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
32880         return ret_val;
32881 }
32882
32883 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint32_t orig) {
32884         LDKCounterpartyCommitmentSecrets orig_conv;
32885         orig_conv.inner = (void*)(orig & (~1));
32886         orig_conv.is_owned = false;
32887         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32888         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
32889         uint32_t ret_ref = 0;
32890         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32891         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32893         ret_ref = (uintptr_t)ret_var.inner;
32894         if (ret_var.is_owned) {
32895                 ret_ref |= 1;
32896         }
32897         return ret_ref;
32898 }
32899
32900 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
32901         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
32902         uint32_t ret_ref = 0;
32903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32906         ret_ref = (uintptr_t)ret_var.inner;
32907         if (ret_var.is_owned) {
32908                 ret_ref |= 1;
32909         }
32910         return ret_ref;
32911 }
32912
32913 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint32_t this_arg) {
32914         LDKCounterpartyCommitmentSecrets this_arg_conv;
32915         this_arg_conv.inner = (void*)(this_arg & (~1));
32916         this_arg_conv.is_owned = false;
32917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32918         int64_t ret_val = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
32919         return ret_val;
32920 }
32921
32922 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint32_t this_arg, int64_t idx, int8_tArray secret) {
32923         LDKCounterpartyCommitmentSecrets this_arg_conv;
32924         this_arg_conv.inner = (void*)(this_arg & (~1));
32925         this_arg_conv.is_owned = false;
32926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32927         LDKThirtyTwoBytes secret_ref;
32928         CHECK(secret->arr_len == 32);
32929         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
32930         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
32931         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
32932         return (uint32_t)ret_conv;
32933 }
32934
32935 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint32_t this_arg, int64_t idx) {
32936         LDKCounterpartyCommitmentSecrets this_arg_conv;
32937         this_arg_conv.inner = (void*)(this_arg & (~1));
32938         this_arg_conv.is_owned = false;
32939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32940         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32941         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
32942         return ret_arr;
32943 }
32944
32945 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint32_t obj) {
32946         LDKCounterpartyCommitmentSecrets obj_conv;
32947         obj_conv.inner = (void*)(obj & (~1));
32948         obj_conv.is_owned = false;
32949         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32950         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
32951         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32952         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32953         CVec_u8Z_free(ret_var);
32954         return ret_arr;
32955 }
32956
32957 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
32958         LDKu8slice ser_ref;
32959         ser_ref.datalen = ser->arr_len;
32960         ser_ref.data = ser->elems /* XXX ser leaks */;
32961         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
32962         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
32963         return (uint32_t)ret_conv;
32964 }
32965
32966 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
32967         LDKPublicKey per_commitment_point_ref;
32968         CHECK(per_commitment_point->arr_len == 33);
32969         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32970         unsigned char base_secret_arr[32];
32971         CHECK(base_secret->arr_len == 32);
32972         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
32973         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
32974         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
32975         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
32976         return (uint32_t)ret_conv;
32977 }
32978
32979 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
32980         LDKPublicKey per_commitment_point_ref;
32981         CHECK(per_commitment_point->arr_len == 33);
32982         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
32983         LDKPublicKey base_point_ref;
32984         CHECK(base_point->arr_len == 33);
32985         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
32986         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
32987         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
32988         return (uint32_t)ret_conv;
32989 }
32990
32991 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) {
32992         unsigned char per_commitment_secret_arr[32];
32993         CHECK(per_commitment_secret->arr_len == 32);
32994         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
32995         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
32996         unsigned char countersignatory_revocation_base_secret_arr[32];
32997         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
32998         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
32999         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
33000         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
33001         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
33002         return (uint32_t)ret_conv;
33003 }
33004
33005 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) {
33006         LDKPublicKey per_commitment_point_ref;
33007         CHECK(per_commitment_point->arr_len == 33);
33008         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33009         LDKPublicKey countersignatory_revocation_base_point_ref;
33010         CHECK(countersignatory_revocation_base_point->arr_len == 33);
33011         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
33012         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
33013         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
33014         return (uint32_t)ret_conv;
33015 }
33016
33017 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
33018         LDKTxCreationKeys this_obj_conv;
33019         this_obj_conv.inner = (void*)(this_obj & (~1));
33020         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33022         TxCreationKeys_free(this_obj_conv);
33023 }
33024
33025 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
33026         LDKTxCreationKeys this_ptr_conv;
33027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33028         this_ptr_conv.is_owned = false;
33029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33030         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33031         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
33032         return ret_arr;
33033 }
33034
33035 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
33036         LDKTxCreationKeys this_ptr_conv;
33037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33038         this_ptr_conv.is_owned = false;
33039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33040         LDKPublicKey val_ref;
33041         CHECK(val->arr_len == 33);
33042         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33043         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
33044 }
33045
33046 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
33047         LDKTxCreationKeys this_ptr_conv;
33048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33049         this_ptr_conv.is_owned = false;
33050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33051         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33052         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
33053         return ret_arr;
33054 }
33055
33056 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
33057         LDKTxCreationKeys this_ptr_conv;
33058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33059         this_ptr_conv.is_owned = false;
33060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33061         LDKPublicKey val_ref;
33062         CHECK(val->arr_len == 33);
33063         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33064         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
33065 }
33066
33067 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
33068         LDKTxCreationKeys this_ptr_conv;
33069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33070         this_ptr_conv.is_owned = false;
33071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33072         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33073         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
33074         return ret_arr;
33075 }
33076
33077 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
33078         LDKTxCreationKeys this_ptr_conv;
33079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33080         this_ptr_conv.is_owned = false;
33081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33082         LDKPublicKey val_ref;
33083         CHECK(val->arr_len == 33);
33084         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33085         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
33086 }
33087
33088 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(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_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
33095         return ret_arr;
33096 }
33097
33098 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(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_countersignatory_htlc_key(&this_ptr_conv, val_ref);
33107 }
33108
33109 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_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_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
33116         return ret_arr;
33117 }
33118
33119 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) {
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_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
33128 }
33129
33130 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) {
33131         LDKPublicKey per_commitment_point_arg_ref;
33132         CHECK(per_commitment_point_arg->arr_len == 33);
33133         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
33134         LDKPublicKey revocation_key_arg_ref;
33135         CHECK(revocation_key_arg->arr_len == 33);
33136         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
33137         LDKPublicKey broadcaster_htlc_key_arg_ref;
33138         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
33139         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
33140         LDKPublicKey countersignatory_htlc_key_arg_ref;
33141         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
33142         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
33143         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
33144         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
33145         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
33146         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);
33147         uint32_t ret_ref = 0;
33148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33151         ret_ref = (uintptr_t)ret_var.inner;
33152         if (ret_var.is_owned) {
33153                 ret_ref |= 1;
33154         }
33155         return ret_ref;
33156 }
33157
33158 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
33159         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
33160 uint32_t ret_ref = 0;
33161 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33162 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33163 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33164 ret_ref = (uintptr_t)ret_var.inner;
33165 if (ret_var.is_owned) {
33166         ret_ref |= 1;
33167 }
33168         return ret_ref;
33169 }
33170 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
33171         LDKTxCreationKeys arg_conv;
33172         arg_conv.inner = (void*)(arg & (~1));
33173         arg_conv.is_owned = false;
33174         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33175         uint32_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
33176         return ret_val;
33177 }
33178
33179 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
33180         LDKTxCreationKeys orig_conv;
33181         orig_conv.inner = (void*)(orig & (~1));
33182         orig_conv.is_owned = false;
33183         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33184         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
33185         uint32_t ret_ref = 0;
33186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33189         ret_ref = (uintptr_t)ret_var.inner;
33190         if (ret_var.is_owned) {
33191                 ret_ref |= 1;
33192         }
33193         return ret_ref;
33194 }
33195
33196 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
33197         LDKTxCreationKeys obj_conv;
33198         obj_conv.inner = (void*)(obj & (~1));
33199         obj_conv.is_owned = false;
33200         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33201         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
33202         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33203         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33204         CVec_u8Z_free(ret_var);
33205         return ret_arr;
33206 }
33207
33208 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
33209         LDKu8slice ser_ref;
33210         ser_ref.datalen = ser->arr_len;
33211         ser_ref.data = ser->elems /* XXX ser leaks */;
33212         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
33213         *ret_conv = TxCreationKeys_read(ser_ref);
33214         return (uint32_t)ret_conv;
33215 }
33216
33217 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
33218         LDKChannelPublicKeys this_obj_conv;
33219         this_obj_conv.inner = (void*)(this_obj & (~1));
33220         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33222         ChannelPublicKeys_free(this_obj_conv);
33223 }
33224
33225 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
33226         LDKChannelPublicKeys this_ptr_conv;
33227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33228         this_ptr_conv.is_owned = false;
33229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33230         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33231         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
33232         return ret_arr;
33233 }
33234
33235 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
33236         LDKChannelPublicKeys this_ptr_conv;
33237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33238         this_ptr_conv.is_owned = false;
33239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33240         LDKPublicKey val_ref;
33241         CHECK(val->arr_len == 33);
33242         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33243         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
33244 }
33245
33246 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
33247         LDKChannelPublicKeys this_ptr_conv;
33248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33249         this_ptr_conv.is_owned = false;
33250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33251         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33252         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
33253         return ret_arr;
33254 }
33255
33256 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
33257         LDKChannelPublicKeys this_ptr_conv;
33258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33259         this_ptr_conv.is_owned = false;
33260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33261         LDKPublicKey val_ref;
33262         CHECK(val->arr_len == 33);
33263         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33264         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
33265 }
33266
33267 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
33268         LDKChannelPublicKeys this_ptr_conv;
33269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33270         this_ptr_conv.is_owned = false;
33271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33272         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33273         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
33274         return ret_arr;
33275 }
33276
33277 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
33278         LDKChannelPublicKeys this_ptr_conv;
33279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33280         this_ptr_conv.is_owned = false;
33281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33282         LDKPublicKey val_ref;
33283         CHECK(val->arr_len == 33);
33284         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33285         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
33286 }
33287
33288 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(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_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
33295         return ret_arr;
33296 }
33297
33298 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(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_delayed_payment_basepoint(&this_ptr_conv, val_ref);
33307 }
33308
33309 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_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_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
33316         return ret_arr;
33317 }
33318
33319 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_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_htlc_basepoint(&this_ptr_conv, val_ref);
33328 }
33329
33330 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) {
33331         LDKPublicKey funding_pubkey_arg_ref;
33332         CHECK(funding_pubkey_arg->arr_len == 33);
33333         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
33334         LDKPublicKey revocation_basepoint_arg_ref;
33335         CHECK(revocation_basepoint_arg->arr_len == 33);
33336         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
33337         LDKPublicKey payment_point_arg_ref;
33338         CHECK(payment_point_arg->arr_len == 33);
33339         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
33340         LDKPublicKey delayed_payment_basepoint_arg_ref;
33341         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
33342         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
33343         LDKPublicKey htlc_basepoint_arg_ref;
33344         CHECK(htlc_basepoint_arg->arr_len == 33);
33345         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
33346         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);
33347         uint32_t ret_ref = 0;
33348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33351         ret_ref = (uintptr_t)ret_var.inner;
33352         if (ret_var.is_owned) {
33353                 ret_ref |= 1;
33354         }
33355         return ret_ref;
33356 }
33357
33358 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
33359         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
33360 uint32_t ret_ref = 0;
33361 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33362 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33363 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33364 ret_ref = (uintptr_t)ret_var.inner;
33365 if (ret_var.is_owned) {
33366         ret_ref |= 1;
33367 }
33368         return ret_ref;
33369 }
33370 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
33371         LDKChannelPublicKeys arg_conv;
33372         arg_conv.inner = (void*)(arg & (~1));
33373         arg_conv.is_owned = false;
33374         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33375         uint32_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
33376         return ret_val;
33377 }
33378
33379 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
33380         LDKChannelPublicKeys orig_conv;
33381         orig_conv.inner = (void*)(orig & (~1));
33382         orig_conv.is_owned = false;
33383         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33384         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
33385         uint32_t ret_ref = 0;
33386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33389         ret_ref = (uintptr_t)ret_var.inner;
33390         if (ret_var.is_owned) {
33391                 ret_ref |= 1;
33392         }
33393         return ret_ref;
33394 }
33395
33396 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
33397         LDKChannelPublicKeys obj_conv;
33398         obj_conv.inner = (void*)(obj & (~1));
33399         obj_conv.is_owned = false;
33400         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33401         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
33402         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33403         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33404         CVec_u8Z_free(ret_var);
33405         return ret_arr;
33406 }
33407
33408 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
33409         LDKu8slice ser_ref;
33410         ser_ref.datalen = ser->arr_len;
33411         ser_ref.data = ser->elems /* XXX ser leaks */;
33412         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
33413         *ret_conv = ChannelPublicKeys_read(ser_ref);
33414         return (uint32_t)ret_conv;
33415 }
33416
33417 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) {
33418         LDKPublicKey per_commitment_point_ref;
33419         CHECK(per_commitment_point->arr_len == 33);
33420         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33421         LDKPublicKey broadcaster_delayed_payment_base_ref;
33422         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
33423         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
33424         LDKPublicKey broadcaster_htlc_base_ref;
33425         CHECK(broadcaster_htlc_base->arr_len == 33);
33426         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
33427         LDKPublicKey countersignatory_revocation_base_ref;
33428         CHECK(countersignatory_revocation_base->arr_len == 33);
33429         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
33430         LDKPublicKey countersignatory_htlc_base_ref;
33431         CHECK(countersignatory_htlc_base->arr_len == 33);
33432         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
33433         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
33434         *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);
33435         return (uint32_t)ret_conv;
33436 }
33437
33438 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) {
33439         LDKPublicKey per_commitment_point_ref;
33440         CHECK(per_commitment_point->arr_len == 33);
33441         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33442         LDKChannelPublicKeys broadcaster_keys_conv;
33443         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
33444         broadcaster_keys_conv.is_owned = false;
33445         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
33446         LDKChannelPublicKeys countersignatory_keys_conv;
33447         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
33448         countersignatory_keys_conv.is_owned = false;
33449         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
33450         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
33451         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
33452         return (uint32_t)ret_conv;
33453 }
33454
33455 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) {
33456         LDKPublicKey revocation_key_ref;
33457         CHECK(revocation_key->arr_len == 33);
33458         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
33459         LDKPublicKey broadcaster_delayed_payment_key_ref;
33460         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
33461         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
33462         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
33463         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33464         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33465         CVec_u8Z_free(ret_var);
33466         return ret_arr;
33467 }
33468
33469 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
33470         LDKHTLCOutputInCommitment this_obj_conv;
33471         this_obj_conv.inner = (void*)(this_obj & (~1));
33472         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33474         HTLCOutputInCommitment_free(this_obj_conv);
33475 }
33476
33477 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
33478         LDKHTLCOutputInCommitment this_ptr_conv;
33479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33480         this_ptr_conv.is_owned = false;
33481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33482         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
33483         return ret_val;
33484 }
33485
33486 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
33487         LDKHTLCOutputInCommitment this_ptr_conv;
33488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33489         this_ptr_conv.is_owned = false;
33490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33491         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
33492 }
33493
33494 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
33495         LDKHTLCOutputInCommitment this_ptr_conv;
33496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33497         this_ptr_conv.is_owned = false;
33498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33499         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
33500         return ret_val;
33501 }
33502
33503 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
33504         LDKHTLCOutputInCommitment this_ptr_conv;
33505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33506         this_ptr_conv.is_owned = false;
33507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33508         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
33509 }
33510
33511 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
33512         LDKHTLCOutputInCommitment this_ptr_conv;
33513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33514         this_ptr_conv.is_owned = false;
33515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33516         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
33517         return ret_val;
33518 }
33519
33520 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
33521         LDKHTLCOutputInCommitment this_ptr_conv;
33522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33523         this_ptr_conv.is_owned = false;
33524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33525         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
33526 }
33527
33528 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
33529         LDKHTLCOutputInCommitment this_ptr_conv;
33530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33531         this_ptr_conv.is_owned = false;
33532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33533         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33534         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
33535         return ret_arr;
33536 }
33537
33538 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
33539         LDKHTLCOutputInCommitment this_ptr_conv;
33540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33541         this_ptr_conv.is_owned = false;
33542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33543         LDKThirtyTwoBytes val_ref;
33544         CHECK(val->arr_len == 32);
33545         memcpy(val_ref.data, val->elems, 32); FREE(val);
33546         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
33547 }
33548
33549 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
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         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
33555         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
33556         uint32_t ret_ref = (uintptr_t)ret_copy;
33557         return ret_ref;
33558 }
33559
33560 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
33561         LDKHTLCOutputInCommitment this_ptr_conv;
33562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33563         this_ptr_conv.is_owned = false;
33564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33565         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33566         CHECK_ACCESS(val_ptr);
33567         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
33568         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
33569         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
33570 }
33571
33572 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) {
33573         LDKThirtyTwoBytes payment_hash_arg_ref;
33574         CHECK(payment_hash_arg->arr_len == 32);
33575         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
33576         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
33577         CHECK_ACCESS(transaction_output_index_arg_ptr);
33578         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
33579         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
33580         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
33581         uint32_t ret_ref = 0;
33582         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33583         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33585         ret_ref = (uintptr_t)ret_var.inner;
33586         if (ret_var.is_owned) {
33587                 ret_ref |= 1;
33588         }
33589         return ret_ref;
33590 }
33591
33592 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
33593         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
33594 uint32_t ret_ref = 0;
33595 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33596 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33597 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33598 ret_ref = (uintptr_t)ret_var.inner;
33599 if (ret_var.is_owned) {
33600         ret_ref |= 1;
33601 }
33602         return ret_ref;
33603 }
33604 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
33605         LDKHTLCOutputInCommitment arg_conv;
33606         arg_conv.inner = (void*)(arg & (~1));
33607         arg_conv.is_owned = false;
33608         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33609         uint32_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
33610         return ret_val;
33611 }
33612
33613 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
33614         LDKHTLCOutputInCommitment orig_conv;
33615         orig_conv.inner = (void*)(orig & (~1));
33616         orig_conv.is_owned = false;
33617         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33618         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
33619         uint32_t ret_ref = 0;
33620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33623         ret_ref = (uintptr_t)ret_var.inner;
33624         if (ret_var.is_owned) {
33625                 ret_ref |= 1;
33626         }
33627         return ret_ref;
33628 }
33629
33630 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
33631         LDKHTLCOutputInCommitment obj_conv;
33632         obj_conv.inner = (void*)(obj & (~1));
33633         obj_conv.is_owned = false;
33634         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33635         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
33636         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33637         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33638         CVec_u8Z_free(ret_var);
33639         return ret_arr;
33640 }
33641
33642 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
33643         LDKu8slice ser_ref;
33644         ser_ref.datalen = ser->arr_len;
33645         ser_ref.data = ser->elems /* XXX ser leaks */;
33646         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
33647         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
33648         return (uint32_t)ret_conv;
33649 }
33650
33651 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
33652         LDKHTLCOutputInCommitment htlc_conv;
33653         htlc_conv.inner = (void*)(htlc & (~1));
33654         htlc_conv.is_owned = false;
33655         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33656         LDKTxCreationKeys keys_conv;
33657         keys_conv.inner = (void*)(keys & (~1));
33658         keys_conv.is_owned = false;
33659         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
33660         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
33661         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33662         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33663         CVec_u8Z_free(ret_var);
33664         return ret_arr;
33665 }
33666
33667 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
33668         LDKPublicKey broadcaster_ref;
33669         CHECK(broadcaster->arr_len == 33);
33670         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
33671         LDKPublicKey countersignatory_ref;
33672         CHECK(countersignatory->arr_len == 33);
33673         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
33674         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
33675         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33676         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33677         CVec_u8Z_free(ret_var);
33678         return ret_arr;
33679 }
33680
33681 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) {
33682         unsigned char commitment_txid_arr[32];
33683         CHECK(commitment_txid->arr_len == 32);
33684         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
33685         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
33686         LDKHTLCOutputInCommitment htlc_conv;
33687         htlc_conv.inner = (void*)(htlc & (~1));
33688         htlc_conv.is_owned = false;
33689         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33690         LDKPublicKey broadcaster_delayed_payment_key_ref;
33691         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
33692         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
33693         LDKPublicKey revocation_key_ref;
33694         CHECK(revocation_key->arr_len == 33);
33695         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
33696         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);
33697         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33698         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33699         Transaction_free(ret_var);
33700         return ret_arr;
33701 }
33702
33703 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
33704         LDKPublicKey funding_pubkey_ref;
33705         CHECK(funding_pubkey->arr_len == 33);
33706         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
33707         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
33708         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33709         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33710         CVec_u8Z_free(ret_var);
33711         return ret_arr;
33712 }
33713
33714 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
33715         LDKChannelTransactionParameters this_obj_conv;
33716         this_obj_conv.inner = (void*)(this_obj & (~1));
33717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33719         ChannelTransactionParameters_free(this_obj_conv);
33720 }
33721
33722 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
33723         LDKChannelTransactionParameters this_ptr_conv;
33724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33725         this_ptr_conv.is_owned = false;
33726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33727         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
33728         uint32_t ret_ref = 0;
33729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33732         ret_ref = (uintptr_t)ret_var.inner;
33733         if (ret_var.is_owned) {
33734                 ret_ref |= 1;
33735         }
33736         return ret_ref;
33737 }
33738
33739 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
33740         LDKChannelTransactionParameters this_ptr_conv;
33741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33742         this_ptr_conv.is_owned = false;
33743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33744         LDKChannelPublicKeys val_conv;
33745         val_conv.inner = (void*)(val & (~1));
33746         val_conv.is_owned = (val & 1) || (val == 0);
33747         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33748         val_conv = ChannelPublicKeys_clone(&val_conv);
33749         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
33750 }
33751
33752 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
33753         LDKChannelTransactionParameters this_ptr_conv;
33754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33755         this_ptr_conv.is_owned = false;
33756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33757         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
33758         return ret_val;
33759 }
33760
33761 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) {
33762         LDKChannelTransactionParameters this_ptr_conv;
33763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33764         this_ptr_conv.is_owned = false;
33765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33766         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
33767 }
33768
33769 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
33770         LDKChannelTransactionParameters this_ptr_conv;
33771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33772         this_ptr_conv.is_owned = false;
33773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33774         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
33775         return ret_val;
33776 }
33777
33778 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
33779         LDKChannelTransactionParameters this_ptr_conv;
33780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33781         this_ptr_conv.is_owned = false;
33782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33783         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
33784 }
33785
33786 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
33787         LDKChannelTransactionParameters this_ptr_conv;
33788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33789         this_ptr_conv.is_owned = false;
33790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33791         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
33792         uint32_t ret_ref = 0;
33793         if ((uintptr_t)ret_var.inner > 4096) {
33794                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33795                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33797                 ret_ref = (uintptr_t)ret_var.inner;
33798                 if (ret_var.is_owned) {
33799                         ret_ref |= 1;
33800                 }
33801         }
33802         return ret_ref;
33803 }
33804
33805 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
33806         LDKChannelTransactionParameters this_ptr_conv;
33807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33808         this_ptr_conv.is_owned = false;
33809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33810         LDKCounterpartyChannelTransactionParameters val_conv;
33811         val_conv.inner = (void*)(val & (~1));
33812         val_conv.is_owned = (val & 1) || (val == 0);
33813         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33814         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
33815         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
33816 }
33817
33818 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
33819         LDKChannelTransactionParameters this_ptr_conv;
33820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33821         this_ptr_conv.is_owned = false;
33822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33823         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
33824         uint32_t ret_ref = 0;
33825         if ((uintptr_t)ret_var.inner > 4096) {
33826                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33827                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33829                 ret_ref = (uintptr_t)ret_var.inner;
33830                 if (ret_var.is_owned) {
33831                         ret_ref |= 1;
33832                 }
33833         }
33834         return ret_ref;
33835 }
33836
33837 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
33838         LDKChannelTransactionParameters this_ptr_conv;
33839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33840         this_ptr_conv.is_owned = false;
33841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33842         LDKOutPoint val_conv;
33843         val_conv.inner = (void*)(val & (~1));
33844         val_conv.is_owned = (val & 1) || (val == 0);
33845         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33846         val_conv = OutPoint_clone(&val_conv);
33847         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
33848 }
33849
33850 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
33851         LDKChannelTransactionParameters this_ptr_conv;
33852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33853         this_ptr_conv.is_owned = false;
33854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33855         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
33856         return ret_conv;
33857 }
33858
33859 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
33860         LDKChannelTransactionParameters this_ptr_conv;
33861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33862         this_ptr_conv.is_owned = false;
33863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33864         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
33865         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
33866 }
33867
33868 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) {
33869         LDKChannelPublicKeys holder_pubkeys_arg_conv;
33870         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
33871         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
33872         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
33873         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
33874         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
33875         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
33876         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
33877         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
33878         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
33879         LDKOutPoint funding_outpoint_arg_conv;
33880         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
33881         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
33882         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
33883         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
33884         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
33885         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);
33886         uint32_t ret_ref = 0;
33887         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33888         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33890         ret_ref = (uintptr_t)ret_var.inner;
33891         if (ret_var.is_owned) {
33892                 ret_ref |= 1;
33893         }
33894         return ret_ref;
33895 }
33896
33897 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
33898         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
33899 uint32_t ret_ref = 0;
33900 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33901 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33902 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33903 ret_ref = (uintptr_t)ret_var.inner;
33904 if (ret_var.is_owned) {
33905         ret_ref |= 1;
33906 }
33907         return ret_ref;
33908 }
33909 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
33910         LDKChannelTransactionParameters arg_conv;
33911         arg_conv.inner = (void*)(arg & (~1));
33912         arg_conv.is_owned = false;
33913         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33914         uint32_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
33915         return ret_val;
33916 }
33917
33918 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
33919         LDKChannelTransactionParameters orig_conv;
33920         orig_conv.inner = (void*)(orig & (~1));
33921         orig_conv.is_owned = false;
33922         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33923         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
33924         uint32_t ret_ref = 0;
33925         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33926         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33928         ret_ref = (uintptr_t)ret_var.inner;
33929         if (ret_var.is_owned) {
33930                 ret_ref |= 1;
33931         }
33932         return ret_ref;
33933 }
33934
33935 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
33936         LDKCounterpartyChannelTransactionParameters this_obj_conv;
33937         this_obj_conv.inner = (void*)(this_obj & (~1));
33938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33940         CounterpartyChannelTransactionParameters_free(this_obj_conv);
33941 }
33942
33943 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
33944         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33946         this_ptr_conv.is_owned = false;
33947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33948         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_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 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
33961         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33963         this_ptr_conv.is_owned = false;
33964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33965         LDKChannelPublicKeys val_conv;
33966         val_conv.inner = (void*)(val & (~1));
33967         val_conv.is_owned = (val & 1) || (val == 0);
33968         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33969         val_conv = ChannelPublicKeys_clone(&val_conv);
33970         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
33971 }
33972
33973 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
33974         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33976         this_ptr_conv.is_owned = false;
33977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33978         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
33979         return ret_val;
33980 }
33981
33982 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
33983         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
33984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33985         this_ptr_conv.is_owned = false;
33986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33987         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
33988 }
33989
33990 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
33991         LDKChannelPublicKeys pubkeys_arg_conv;
33992         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
33993         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
33994         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
33995         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
33996         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
33997         uint32_t ret_ref = 0;
33998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34001         ret_ref = (uintptr_t)ret_var.inner;
34002         if (ret_var.is_owned) {
34003                 ret_ref |= 1;
34004         }
34005         return ret_ref;
34006 }
34007
34008 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
34009         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
34010 uint32_t ret_ref = 0;
34011 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34012 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34013 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34014 ret_ref = (uintptr_t)ret_var.inner;
34015 if (ret_var.is_owned) {
34016         ret_ref |= 1;
34017 }
34018         return ret_ref;
34019 }
34020 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
34021         LDKCounterpartyChannelTransactionParameters arg_conv;
34022         arg_conv.inner = (void*)(arg & (~1));
34023         arg_conv.is_owned = false;
34024         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34025         uint32_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
34026         return ret_val;
34027 }
34028
34029 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
34030         LDKCounterpartyChannelTransactionParameters orig_conv;
34031         orig_conv.inner = (void*)(orig & (~1));
34032         orig_conv.is_owned = false;
34033         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34034         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
34035         uint32_t ret_ref = 0;
34036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34039         ret_ref = (uintptr_t)ret_var.inner;
34040         if (ret_var.is_owned) {
34041                 ret_ref |= 1;
34042         }
34043         return ret_ref;
34044 }
34045
34046 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
34047         LDKChannelTransactionParameters this_arg_conv;
34048         this_arg_conv.inner = (void*)(this_arg & (~1));
34049         this_arg_conv.is_owned = false;
34050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34051         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
34052         return ret_val;
34053 }
34054
34055 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
34056         LDKChannelTransactionParameters this_arg_conv;
34057         this_arg_conv.inner = (void*)(this_arg & (~1));
34058         this_arg_conv.is_owned = false;
34059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34060         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
34061         uint32_t ret_ref = 0;
34062         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34063         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34065         ret_ref = (uintptr_t)ret_var.inner;
34066         if (ret_var.is_owned) {
34067                 ret_ref |= 1;
34068         }
34069         return ret_ref;
34070 }
34071
34072 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
34073         LDKChannelTransactionParameters this_arg_conv;
34074         this_arg_conv.inner = (void*)(this_arg & (~1));
34075         this_arg_conv.is_owned = false;
34076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34077         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
34078         uint32_t ret_ref = 0;
34079         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34080         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34082         ret_ref = (uintptr_t)ret_var.inner;
34083         if (ret_var.is_owned) {
34084                 ret_ref |= 1;
34085         }
34086         return ret_ref;
34087 }
34088
34089 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
34090         LDKCounterpartyChannelTransactionParameters obj_conv;
34091         obj_conv.inner = (void*)(obj & (~1));
34092         obj_conv.is_owned = false;
34093         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34094         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
34095         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34096         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34097         CVec_u8Z_free(ret_var);
34098         return ret_arr;
34099 }
34100
34101 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
34102         LDKu8slice ser_ref;
34103         ser_ref.datalen = ser->arr_len;
34104         ser_ref.data = ser->elems /* XXX ser leaks */;
34105         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
34106         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
34107         return (uint32_t)ret_conv;
34108 }
34109
34110 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
34111         LDKChannelTransactionParameters obj_conv;
34112         obj_conv.inner = (void*)(obj & (~1));
34113         obj_conv.is_owned = false;
34114         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34115         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
34116         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34117         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34118         CVec_u8Z_free(ret_var);
34119         return ret_arr;
34120 }
34121
34122 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
34123         LDKu8slice ser_ref;
34124         ser_ref.datalen = ser->arr_len;
34125         ser_ref.data = ser->elems /* XXX ser leaks */;
34126         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
34127         *ret_conv = ChannelTransactionParameters_read(ser_ref);
34128         return (uint32_t)ret_conv;
34129 }
34130
34131 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
34132         LDKDirectedChannelTransactionParameters this_obj_conv;
34133         this_obj_conv.inner = (void*)(this_obj & (~1));
34134         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34136         DirectedChannelTransactionParameters_free(this_obj_conv);
34137 }
34138
34139 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
34140         LDKDirectedChannelTransactionParameters this_arg_conv;
34141         this_arg_conv.inner = (void*)(this_arg & (~1));
34142         this_arg_conv.is_owned = false;
34143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34144         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
34145         uint32_t ret_ref = 0;
34146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34149         ret_ref = (uintptr_t)ret_var.inner;
34150         if (ret_var.is_owned) {
34151                 ret_ref |= 1;
34152         }
34153         return ret_ref;
34154 }
34155
34156 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
34157         LDKDirectedChannelTransactionParameters this_arg_conv;
34158         this_arg_conv.inner = (void*)(this_arg & (~1));
34159         this_arg_conv.is_owned = false;
34160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34161         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
34162         uint32_t ret_ref = 0;
34163         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34164         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34166         ret_ref = (uintptr_t)ret_var.inner;
34167         if (ret_var.is_owned) {
34168                 ret_ref |= 1;
34169         }
34170         return ret_ref;
34171 }
34172
34173 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
34174         LDKDirectedChannelTransactionParameters this_arg_conv;
34175         this_arg_conv.inner = (void*)(this_arg & (~1));
34176         this_arg_conv.is_owned = false;
34177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34178         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
34179         return ret_val;
34180 }
34181
34182 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
34183         LDKDirectedChannelTransactionParameters this_arg_conv;
34184         this_arg_conv.inner = (void*)(this_arg & (~1));
34185         this_arg_conv.is_owned = false;
34186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34187         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
34188         return ret_val;
34189 }
34190
34191 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
34192         LDKDirectedChannelTransactionParameters this_arg_conv;
34193         this_arg_conv.inner = (void*)(this_arg & (~1));
34194         this_arg_conv.is_owned = false;
34195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34196         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
34197         uint32_t ret_ref = 0;
34198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34201         ret_ref = (uintptr_t)ret_var.inner;
34202         if (ret_var.is_owned) {
34203                 ret_ref |= 1;
34204         }
34205         return ret_ref;
34206 }
34207
34208 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
34209         LDKDirectedChannelTransactionParameters this_arg_conv;
34210         this_arg_conv.inner = (void*)(this_arg & (~1));
34211         this_arg_conv.is_owned = false;
34212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34213         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
34214         return ret_val;
34215 }
34216
34217 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
34218         LDKHolderCommitmentTransaction this_obj_conv;
34219         this_obj_conv.inner = (void*)(this_obj & (~1));
34220         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34222         HolderCommitmentTransaction_free(this_obj_conv);
34223 }
34224
34225 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
34226         LDKHolderCommitmentTransaction this_ptr_conv;
34227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34228         this_ptr_conv.is_owned = false;
34229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34230         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34231         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
34232         return ret_arr;
34233 }
34234
34235 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
34236         LDKHolderCommitmentTransaction this_ptr_conv;
34237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34238         this_ptr_conv.is_owned = false;
34239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34240         LDKSignature val_ref;
34241         CHECK(val->arr_len == 64);
34242         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
34243         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
34244 }
34245
34246 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
34247         LDKHolderCommitmentTransaction this_ptr_conv;
34248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34249         this_ptr_conv.is_owned = false;
34250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34251         LDKCVec_SignatureZ val_constr;
34252         val_constr.datalen = val->arr_len;
34253         if (val_constr.datalen > 0)
34254                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34255         else
34256                 val_constr.data = NULL;
34257         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
34258         for (size_t m = 0; m < val_constr.datalen; m++) {
34259                 int8_tArray val_conv_12 = val_vals[m];
34260                 LDKSignature val_conv_12_ref;
34261                 CHECK(val_conv_12->arr_len == 64);
34262                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
34263                 val_constr.data[m] = val_conv_12_ref;
34264         }
34265         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
34266 }
34267
34268 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
34269         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
34270 uint32_t ret_ref = 0;
34271 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34272 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34273 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34274 ret_ref = (uintptr_t)ret_var.inner;
34275 if (ret_var.is_owned) {
34276         ret_ref |= 1;
34277 }
34278         return ret_ref;
34279 }
34280 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
34281         LDKHolderCommitmentTransaction arg_conv;
34282         arg_conv.inner = (void*)(arg & (~1));
34283         arg_conv.is_owned = false;
34284         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34285         uint32_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
34286         return ret_val;
34287 }
34288
34289 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
34290         LDKHolderCommitmentTransaction orig_conv;
34291         orig_conv.inner = (void*)(orig & (~1));
34292         orig_conv.is_owned = false;
34293         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34294         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
34295         uint32_t ret_ref = 0;
34296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34299         ret_ref = (uintptr_t)ret_var.inner;
34300         if (ret_var.is_owned) {
34301                 ret_ref |= 1;
34302         }
34303         return ret_ref;
34304 }
34305
34306 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
34307         LDKHolderCommitmentTransaction obj_conv;
34308         obj_conv.inner = (void*)(obj & (~1));
34309         obj_conv.is_owned = false;
34310         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34311         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
34312         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34313         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34314         CVec_u8Z_free(ret_var);
34315         return ret_arr;
34316 }
34317
34318 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
34319         LDKu8slice ser_ref;
34320         ser_ref.datalen = ser->arr_len;
34321         ser_ref.data = ser->elems /* XXX ser leaks */;
34322         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
34323         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
34324         return (uint32_t)ret_conv;
34325 }
34326
34327 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) {
34328         LDKCommitmentTransaction commitment_tx_conv;
34329         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
34330         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
34331         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
34332         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
34333         LDKSignature counterparty_sig_ref;
34334         CHECK(counterparty_sig->arr_len == 64);
34335         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
34336         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
34337         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
34338         if (counterparty_htlc_sigs_constr.datalen > 0)
34339                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34340         else
34341                 counterparty_htlc_sigs_constr.data = NULL;
34342         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems /* XXX counterparty_htlc_sigs leaks */;
34343         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
34344                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
34345                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
34346                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
34347                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
34348                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
34349         }
34350         LDKPublicKey holder_funding_key_ref;
34351         CHECK(holder_funding_key->arr_len == 33);
34352         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
34353         LDKPublicKey counterparty_funding_key_ref;
34354         CHECK(counterparty_funding_key->arr_len == 33);
34355         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
34356         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
34357         uint32_t ret_ref = 0;
34358         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34359         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34361         ret_ref = (uintptr_t)ret_var.inner;
34362         if (ret_var.is_owned) {
34363                 ret_ref |= 1;
34364         }
34365         return ret_ref;
34366 }
34367
34368 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
34369         LDKBuiltCommitmentTransaction this_obj_conv;
34370         this_obj_conv.inner = (void*)(this_obj & (~1));
34371         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34373         BuiltCommitmentTransaction_free(this_obj_conv);
34374 }
34375
34376 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
34377         LDKBuiltCommitmentTransaction this_ptr_conv;
34378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34379         this_ptr_conv.is_owned = false;
34380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34381         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
34382         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34383         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34384         Transaction_free(ret_var);
34385         return ret_arr;
34386 }
34387
34388 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
34389         LDKBuiltCommitmentTransaction this_ptr_conv;
34390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34391         this_ptr_conv.is_owned = false;
34392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34393         LDKTransaction val_ref;
34394         val_ref.datalen = val->arr_len;
34395         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
34396         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
34397         val_ref.data_is_owned = true;
34398         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
34399 }
34400
34401 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
34402         LDKBuiltCommitmentTransaction this_ptr_conv;
34403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34404         this_ptr_conv.is_owned = false;
34405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34406         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34407         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
34408         return ret_arr;
34409 }
34410
34411 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
34412         LDKBuiltCommitmentTransaction this_ptr_conv;
34413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34414         this_ptr_conv.is_owned = false;
34415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34416         LDKThirtyTwoBytes val_ref;
34417         CHECK(val->arr_len == 32);
34418         memcpy(val_ref.data, val->elems, 32); FREE(val);
34419         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
34420 }
34421
34422 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
34423         LDKTransaction transaction_arg_ref;
34424         transaction_arg_ref.datalen = transaction_arg->arr_len;
34425         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
34426         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
34427         transaction_arg_ref.data_is_owned = true;
34428         LDKThirtyTwoBytes txid_arg_ref;
34429         CHECK(txid_arg->arr_len == 32);
34430         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
34431         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
34432         uint32_t ret_ref = 0;
34433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34436         ret_ref = (uintptr_t)ret_var.inner;
34437         if (ret_var.is_owned) {
34438                 ret_ref |= 1;
34439         }
34440         return ret_ref;
34441 }
34442
34443 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
34444         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
34445 uint32_t ret_ref = 0;
34446 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34447 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34448 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34449 ret_ref = (uintptr_t)ret_var.inner;
34450 if (ret_var.is_owned) {
34451         ret_ref |= 1;
34452 }
34453         return ret_ref;
34454 }
34455 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
34456         LDKBuiltCommitmentTransaction arg_conv;
34457         arg_conv.inner = (void*)(arg & (~1));
34458         arg_conv.is_owned = false;
34459         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34460         uint32_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
34461         return ret_val;
34462 }
34463
34464 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
34465         LDKBuiltCommitmentTransaction orig_conv;
34466         orig_conv.inner = (void*)(orig & (~1));
34467         orig_conv.is_owned = false;
34468         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34469         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
34470         uint32_t ret_ref = 0;
34471         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34472         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34474         ret_ref = (uintptr_t)ret_var.inner;
34475         if (ret_var.is_owned) {
34476                 ret_ref |= 1;
34477         }
34478         return ret_ref;
34479 }
34480
34481 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
34482         LDKBuiltCommitmentTransaction obj_conv;
34483         obj_conv.inner = (void*)(obj & (~1));
34484         obj_conv.is_owned = false;
34485         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34486         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
34487         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34488         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34489         CVec_u8Z_free(ret_var);
34490         return ret_arr;
34491 }
34492
34493 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
34494         LDKu8slice ser_ref;
34495         ser_ref.datalen = ser->arr_len;
34496         ser_ref.data = ser->elems /* XXX ser leaks */;
34497         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
34498         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
34499         return (uint32_t)ret_conv;
34500 }
34501
34502 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) {
34503         LDKBuiltCommitmentTransaction this_arg_conv;
34504         this_arg_conv.inner = (void*)(this_arg & (~1));
34505         this_arg_conv.is_owned = false;
34506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34507         LDKu8slice funding_redeemscript_ref;
34508         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34509         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34510         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34511         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
34512         return ret_arr;
34513 }
34514
34515 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) {
34516         LDKBuiltCommitmentTransaction this_arg_conv;
34517         this_arg_conv.inner = (void*)(this_arg & (~1));
34518         this_arg_conv.is_owned = false;
34519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34520         unsigned char funding_key_arr[32];
34521         CHECK(funding_key->arr_len == 32);
34522         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
34523         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34524         LDKu8slice funding_redeemscript_ref;
34525         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34526         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34527         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34528         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
34529         return ret_arr;
34530 }
34531
34532 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
34533         LDKClosingTransaction this_obj_conv;
34534         this_obj_conv.inner = (void*)(this_obj & (~1));
34535         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34537         ClosingTransaction_free(this_obj_conv);
34538 }
34539
34540 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
34541         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
34542 uint32_t ret_ref = 0;
34543 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34544 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34545 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34546 ret_ref = (uintptr_t)ret_var.inner;
34547 if (ret_var.is_owned) {
34548         ret_ref |= 1;
34549 }
34550         return ret_ref;
34551 }
34552 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
34553         LDKClosingTransaction arg_conv;
34554         arg_conv.inner = (void*)(arg & (~1));
34555         arg_conv.is_owned = false;
34556         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34557         uint32_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
34558         return ret_val;
34559 }
34560
34561 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
34562         LDKClosingTransaction orig_conv;
34563         orig_conv.inner = (void*)(orig & (~1));
34564         orig_conv.is_owned = false;
34565         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34566         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
34567         uint32_t ret_ref = 0;
34568         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34569         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34571         ret_ref = (uintptr_t)ret_var.inner;
34572         if (ret_var.is_owned) {
34573                 ret_ref |= 1;
34574         }
34575         return ret_ref;
34576 }
34577
34578 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
34579         LDKClosingTransaction o_conv;
34580         o_conv.inner = (void*)(o & (~1));
34581         o_conv.is_owned = false;
34582         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34583         int64_t ret_val = ClosingTransaction_hash(&o_conv);
34584         return ret_val;
34585 }
34586
34587 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) {
34588         LDKCVec_u8Z to_holder_script_ref;
34589         to_holder_script_ref.datalen = to_holder_script->arr_len;
34590         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
34591         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
34592         LDKCVec_u8Z to_counterparty_script_ref;
34593         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
34594         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
34595         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
34596         LDKOutPoint funding_outpoint_conv;
34597         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34598         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34599         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34600         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34601         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
34602         uint32_t ret_ref = 0;
34603         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34604         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34606         ret_ref = (uintptr_t)ret_var.inner;
34607         if (ret_var.is_owned) {
34608                 ret_ref |= 1;
34609         }
34610         return ret_ref;
34611 }
34612
34613 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
34614         LDKClosingTransaction this_arg_conv;
34615         this_arg_conv.inner = (void*)(this_arg & (~1));
34616         this_arg_conv.is_owned = false;
34617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34618         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
34619         uint32_t ret_ref = 0;
34620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34623         ret_ref = (uintptr_t)ret_var.inner;
34624         if (ret_var.is_owned) {
34625                 ret_ref |= 1;
34626         }
34627         return ret_ref;
34628 }
34629
34630 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
34631         LDKClosingTransaction this_arg_conv;
34632         this_arg_conv.inner = (void*)(this_arg & (~1));
34633         this_arg_conv.is_owned = false;
34634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34635         LDKOutPoint funding_outpoint_conv;
34636         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34637         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34638         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34639         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34640         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
34641         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
34642         return (uint32_t)ret_conv;
34643 }
34644
34645 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
34646         LDKClosingTransaction this_arg_conv;
34647         this_arg_conv.inner = (void*)(this_arg & (~1));
34648         this_arg_conv.is_owned = false;
34649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34650         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
34651         return ret_val;
34652 }
34653
34654 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
34655         LDKClosingTransaction this_arg_conv;
34656         this_arg_conv.inner = (void*)(this_arg & (~1));
34657         this_arg_conv.is_owned = false;
34658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34659         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
34660         return ret_val;
34661 }
34662
34663 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
34664         LDKClosingTransaction this_arg_conv;
34665         this_arg_conv.inner = (void*)(this_arg & (~1));
34666         this_arg_conv.is_owned = false;
34667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34668         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
34669         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34670         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34671         return ret_arr;
34672 }
34673
34674 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
34675         LDKClosingTransaction this_arg_conv;
34676         this_arg_conv.inner = (void*)(this_arg & (~1));
34677         this_arg_conv.is_owned = false;
34678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34679         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
34680         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34681         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34682         return ret_arr;
34683 }
34684
34685 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
34686         LDKTrustedClosingTransaction this_obj_conv;
34687         this_obj_conv.inner = (void*)(this_obj & (~1));
34688         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34690         TrustedClosingTransaction_free(this_obj_conv);
34691 }
34692
34693 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
34694         LDKTrustedClosingTransaction 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         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
34699         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34700         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34701         Transaction_free(ret_var);
34702         return ret_arr;
34703 }
34704
34705 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) {
34706         LDKTrustedClosingTransaction this_arg_conv;
34707         this_arg_conv.inner = (void*)(this_arg & (~1));
34708         this_arg_conv.is_owned = false;
34709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34710         LDKu8slice funding_redeemscript_ref;
34711         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34712         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34713         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34714         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
34715         return ret_arr;
34716 }
34717
34718 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) {
34719         LDKTrustedClosingTransaction this_arg_conv;
34720         this_arg_conv.inner = (void*)(this_arg & (~1));
34721         this_arg_conv.is_owned = false;
34722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34723         unsigned char funding_key_arr[32];
34724         CHECK(funding_key->arr_len == 32);
34725         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
34726         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34727         LDKu8slice funding_redeemscript_ref;
34728         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34729         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34730         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34731         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
34732         return ret_arr;
34733 }
34734
34735 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
34736         LDKCommitmentTransaction this_obj_conv;
34737         this_obj_conv.inner = (void*)(this_obj & (~1));
34738         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34740         CommitmentTransaction_free(this_obj_conv);
34741 }
34742
34743 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
34744         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
34745 uint32_t ret_ref = 0;
34746 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34747 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34748 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34749 ret_ref = (uintptr_t)ret_var.inner;
34750 if (ret_var.is_owned) {
34751         ret_ref |= 1;
34752 }
34753         return ret_ref;
34754 }
34755 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
34756         LDKCommitmentTransaction arg_conv;
34757         arg_conv.inner = (void*)(arg & (~1));
34758         arg_conv.is_owned = false;
34759         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34760         uint32_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
34761         return ret_val;
34762 }
34763
34764 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
34765         LDKCommitmentTransaction orig_conv;
34766         orig_conv.inner = (void*)(orig & (~1));
34767         orig_conv.is_owned = false;
34768         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34769         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
34770         uint32_t ret_ref = 0;
34771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34774         ret_ref = (uintptr_t)ret_var.inner;
34775         if (ret_var.is_owned) {
34776                 ret_ref |= 1;
34777         }
34778         return ret_ref;
34779 }
34780
34781 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
34782         LDKCommitmentTransaction obj_conv;
34783         obj_conv.inner = (void*)(obj & (~1));
34784         obj_conv.is_owned = false;
34785         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34786         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
34787         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34788         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34789         CVec_u8Z_free(ret_var);
34790         return ret_arr;
34791 }
34792
34793 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
34794         LDKu8slice ser_ref;
34795         ser_ref.datalen = ser->arr_len;
34796         ser_ref.data = ser->elems /* XXX ser leaks */;
34797         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
34798         *ret_conv = CommitmentTransaction_read(ser_ref);
34799         return (uint32_t)ret_conv;
34800 }
34801
34802 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
34803         LDKCommitmentTransaction this_arg_conv;
34804         this_arg_conv.inner = (void*)(this_arg & (~1));
34805         this_arg_conv.is_owned = false;
34806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34807         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
34808         return ret_val;
34809 }
34810
34811 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
34812         LDKCommitmentTransaction this_arg_conv;
34813         this_arg_conv.inner = (void*)(this_arg & (~1));
34814         this_arg_conv.is_owned = false;
34815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34816         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
34817         return ret_val;
34818 }
34819
34820 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
34821         LDKCommitmentTransaction this_arg_conv;
34822         this_arg_conv.inner = (void*)(this_arg & (~1));
34823         this_arg_conv.is_owned = false;
34824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34825         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
34826         return ret_val;
34827 }
34828
34829 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
34830         LDKCommitmentTransaction this_arg_conv;
34831         this_arg_conv.inner = (void*)(this_arg & (~1));
34832         this_arg_conv.is_owned = false;
34833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34834         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
34835         return ret_val;
34836 }
34837
34838 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
34839         LDKCommitmentTransaction this_arg_conv;
34840         this_arg_conv.inner = (void*)(this_arg & (~1));
34841         this_arg_conv.is_owned = false;
34842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34843         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
34844         uint32_t ret_ref = 0;
34845         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34846         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34848         ret_ref = (uintptr_t)ret_var.inner;
34849         if (ret_var.is_owned) {
34850                 ret_ref |= 1;
34851         }
34852         return ret_ref;
34853 }
34854
34855 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) {
34856         LDKCommitmentTransaction this_arg_conv;
34857         this_arg_conv.inner = (void*)(this_arg & (~1));
34858         this_arg_conv.is_owned = false;
34859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34860         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34861         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34862         channel_parameters_conv.is_owned = false;
34863         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34864         LDKChannelPublicKeys broadcaster_keys_conv;
34865         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
34866         broadcaster_keys_conv.is_owned = false;
34867         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
34868         LDKChannelPublicKeys countersignatory_keys_conv;
34869         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
34870         countersignatory_keys_conv.is_owned = false;
34871         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
34872         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
34873         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
34874         return (uint32_t)ret_conv;
34875 }
34876
34877 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
34878         LDKTrustedCommitmentTransaction this_obj_conv;
34879         this_obj_conv.inner = (void*)(this_obj & (~1));
34880         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34882         TrustedCommitmentTransaction_free(this_obj_conv);
34883 }
34884
34885 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
34886         LDKTrustedCommitmentTransaction this_arg_conv;
34887         this_arg_conv.inner = (void*)(this_arg & (~1));
34888         this_arg_conv.is_owned = false;
34889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34890         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34891         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
34892         return ret_arr;
34893 }
34894
34895 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
34896         LDKTrustedCommitmentTransaction this_arg_conv;
34897         this_arg_conv.inner = (void*)(this_arg & (~1));
34898         this_arg_conv.is_owned = false;
34899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34900         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
34901         uint32_t ret_ref = 0;
34902         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34903         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34905         ret_ref = (uintptr_t)ret_var.inner;
34906         if (ret_var.is_owned) {
34907                 ret_ref |= 1;
34908         }
34909         return ret_ref;
34910 }
34911
34912 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
34913         LDKTrustedCommitmentTransaction this_arg_conv;
34914         this_arg_conv.inner = (void*)(this_arg & (~1));
34915         this_arg_conv.is_owned = false;
34916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34917         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
34918         uint32_t ret_ref = 0;
34919         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34920         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34922         ret_ref = (uintptr_t)ret_var.inner;
34923         if (ret_var.is_owned) {
34924                 ret_ref |= 1;
34925         }
34926         return ret_ref;
34927 }
34928
34929 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
34930         LDKTrustedCommitmentTransaction this_arg_conv;
34931         this_arg_conv.inner = (void*)(this_arg & (~1));
34932         this_arg_conv.is_owned = false;
34933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34934         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
34935         return ret_val;
34936 }
34937
34938 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) {
34939         LDKTrustedCommitmentTransaction this_arg_conv;
34940         this_arg_conv.inner = (void*)(this_arg & (~1));
34941         this_arg_conv.is_owned = false;
34942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34943         unsigned char htlc_base_key_arr[32];
34944         CHECK(htlc_base_key->arr_len == 32);
34945         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
34946         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
34947         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34948         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34949         channel_parameters_conv.is_owned = false;
34950         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34951         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
34952         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
34953         return (uint32_t)ret_conv;
34954 }
34955
34956 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) {
34957         LDKPublicKey broadcaster_payment_basepoint_ref;
34958         CHECK(broadcaster_payment_basepoint->arr_len == 33);
34959         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
34960         LDKPublicKey countersignatory_payment_basepoint_ref;
34961         CHECK(countersignatory_payment_basepoint->arr_len == 33);
34962         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
34963         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
34964         return ret_val;
34965 }
34966
34967 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
34968         LDKInitFeatures a_conv;
34969         a_conv.inner = (void*)(a & (~1));
34970         a_conv.is_owned = false;
34971         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34972         LDKInitFeatures b_conv;
34973         b_conv.inner = (void*)(b & (~1));
34974         b_conv.is_owned = false;
34975         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34976         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
34977         return ret_val;
34978 }
34979
34980 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
34981         LDKNodeFeatures a_conv;
34982         a_conv.inner = (void*)(a & (~1));
34983         a_conv.is_owned = false;
34984         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34985         LDKNodeFeatures b_conv;
34986         b_conv.inner = (void*)(b & (~1));
34987         b_conv.is_owned = false;
34988         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34989         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
34990         return ret_val;
34991 }
34992
34993 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
34994         LDKChannelFeatures a_conv;
34995         a_conv.inner = (void*)(a & (~1));
34996         a_conv.is_owned = false;
34997         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34998         LDKChannelFeatures b_conv;
34999         b_conv.inner = (void*)(b & (~1));
35000         b_conv.is_owned = false;
35001         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35002         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
35003         return ret_val;
35004 }
35005
35006 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
35007         LDKInvoiceFeatures a_conv;
35008         a_conv.inner = (void*)(a & (~1));
35009         a_conv.is_owned = false;
35010         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35011         LDKInvoiceFeatures b_conv;
35012         b_conv.inner = (void*)(b & (~1));
35013         b_conv.is_owned = false;
35014         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35015         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
35016         return ret_val;
35017 }
35018
35019 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
35020         LDKChannelTypeFeatures a_conv;
35021         a_conv.inner = (void*)(a & (~1));
35022         a_conv.is_owned = false;
35023         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35024         LDKChannelTypeFeatures b_conv;
35025         b_conv.inner = (void*)(b & (~1));
35026         b_conv.is_owned = false;
35027         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35028         jboolean ret_val = ChannelTypeFeatures_eq(&a_conv, &b_conv);
35029         return ret_val;
35030 }
35031
35032 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
35033         LDKInitFeatures ret_var = InitFeatures_clone(arg);
35034 uint32_t ret_ref = 0;
35035 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35036 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35037 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35038 ret_ref = (uintptr_t)ret_var.inner;
35039 if (ret_var.is_owned) {
35040         ret_ref |= 1;
35041 }
35042         return ret_ref;
35043 }
35044 uint32_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
35045         LDKInitFeatures arg_conv;
35046         arg_conv.inner = (void*)(arg & (~1));
35047         arg_conv.is_owned = false;
35048         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35049         uint32_t ret_val = InitFeatures_clone_ptr(&arg_conv);
35050         return ret_val;
35051 }
35052
35053 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
35054         LDKInitFeatures orig_conv;
35055         orig_conv.inner = (void*)(orig & (~1));
35056         orig_conv.is_owned = false;
35057         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35058         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
35059         uint32_t ret_ref = 0;
35060         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35061         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35063         ret_ref = (uintptr_t)ret_var.inner;
35064         if (ret_var.is_owned) {
35065                 ret_ref |= 1;
35066         }
35067         return ret_ref;
35068 }
35069
35070 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
35071         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
35072 uint32_t ret_ref = 0;
35073 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35074 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35075 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35076 ret_ref = (uintptr_t)ret_var.inner;
35077 if (ret_var.is_owned) {
35078         ret_ref |= 1;
35079 }
35080         return ret_ref;
35081 }
35082 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
35083         LDKNodeFeatures arg_conv;
35084         arg_conv.inner = (void*)(arg & (~1));
35085         arg_conv.is_owned = false;
35086         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35087         uint32_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
35088         return ret_val;
35089 }
35090
35091 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
35092         LDKNodeFeatures orig_conv;
35093         orig_conv.inner = (void*)(orig & (~1));
35094         orig_conv.is_owned = false;
35095         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35096         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
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
35108 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
35109         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
35110 uint32_t ret_ref = 0;
35111 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35112 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35113 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35114 ret_ref = (uintptr_t)ret_var.inner;
35115 if (ret_var.is_owned) {
35116         ret_ref |= 1;
35117 }
35118         return ret_ref;
35119 }
35120 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
35121         LDKChannelFeatures arg_conv;
35122         arg_conv.inner = (void*)(arg & (~1));
35123         arg_conv.is_owned = false;
35124         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35125         uint32_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
35126         return ret_val;
35127 }
35128
35129 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
35130         LDKChannelFeatures orig_conv;
35131         orig_conv.inner = (void*)(orig & (~1));
35132         orig_conv.is_owned = false;
35133         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35134         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
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
35146 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
35147         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
35148 uint32_t ret_ref = 0;
35149 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35150 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35151 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35152 ret_ref = (uintptr_t)ret_var.inner;
35153 if (ret_var.is_owned) {
35154         ret_ref |= 1;
35155 }
35156         return ret_ref;
35157 }
35158 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
35159         LDKInvoiceFeatures arg_conv;
35160         arg_conv.inner = (void*)(arg & (~1));
35161         arg_conv.is_owned = false;
35162         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35163         uint32_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
35164         return ret_val;
35165 }
35166
35167 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
35168         LDKInvoiceFeatures orig_conv;
35169         orig_conv.inner = (void*)(orig & (~1));
35170         orig_conv.is_owned = false;
35171         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35172         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
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
35184 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
35185         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
35186 uint32_t ret_ref = 0;
35187 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35188 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35189 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35190 ret_ref = (uintptr_t)ret_var.inner;
35191 if (ret_var.is_owned) {
35192         ret_ref |= 1;
35193 }
35194         return ret_ref;
35195 }
35196 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
35197         LDKChannelTypeFeatures arg_conv;
35198         arg_conv.inner = (void*)(arg & (~1));
35199         arg_conv.is_owned = false;
35200         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35201         uint32_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
35202         return ret_val;
35203 }
35204
35205 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
35206         LDKChannelTypeFeatures orig_conv;
35207         orig_conv.inner = (void*)(orig & (~1));
35208         orig_conv.is_owned = false;
35209         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35210         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
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
35222 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
35223         LDKInitFeatures this_obj_conv;
35224         this_obj_conv.inner = (void*)(this_obj & (~1));
35225         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35227         InitFeatures_free(this_obj_conv);
35228 }
35229
35230 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
35231         LDKNodeFeatures this_obj_conv;
35232         this_obj_conv.inner = (void*)(this_obj & (~1));
35233         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35235         NodeFeatures_free(this_obj_conv);
35236 }
35237
35238 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
35239         LDKChannelFeatures this_obj_conv;
35240         this_obj_conv.inner = (void*)(this_obj & (~1));
35241         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35243         ChannelFeatures_free(this_obj_conv);
35244 }
35245
35246 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
35247         LDKInvoiceFeatures this_obj_conv;
35248         this_obj_conv.inner = (void*)(this_obj & (~1));
35249         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35251         InvoiceFeatures_free(this_obj_conv);
35252 }
35253
35254 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
35255         LDKChannelTypeFeatures this_obj_conv;
35256         this_obj_conv.inner = (void*)(this_obj & (~1));
35257         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35259         ChannelTypeFeatures_free(this_obj_conv);
35260 }
35261
35262 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
35263         LDKInitFeatures ret_var = InitFeatures_empty();
35264         uint32_t ret_ref = 0;
35265         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35266         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35268         ret_ref = (uintptr_t)ret_var.inner;
35269         if (ret_var.is_owned) {
35270                 ret_ref |= 1;
35271         }
35272         return ret_ref;
35273 }
35274
35275 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
35276         LDKInitFeatures ret_var = InitFeatures_known();
35277         uint32_t ret_ref = 0;
35278         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35279         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35281         ret_ref = (uintptr_t)ret_var.inner;
35282         if (ret_var.is_owned) {
35283                 ret_ref |= 1;
35284         }
35285         return ret_ref;
35286 }
35287
35288 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
35289         LDKInitFeatures this_arg_conv;
35290         this_arg_conv.inner = (void*)(this_arg & (~1));
35291         this_arg_conv.is_owned = false;
35292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35293         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
35294         return ret_val;
35295 }
35296
35297 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
35298         LDKNodeFeatures ret_var = NodeFeatures_empty();
35299         uint32_t ret_ref = 0;
35300         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35301         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35303         ret_ref = (uintptr_t)ret_var.inner;
35304         if (ret_var.is_owned) {
35305                 ret_ref |= 1;
35306         }
35307         return ret_ref;
35308 }
35309
35310 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
35311         LDKNodeFeatures ret_var = NodeFeatures_known();
35312         uint32_t ret_ref = 0;
35313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35316         ret_ref = (uintptr_t)ret_var.inner;
35317         if (ret_var.is_owned) {
35318                 ret_ref |= 1;
35319         }
35320         return ret_ref;
35321 }
35322
35323 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
35324         LDKNodeFeatures this_arg_conv;
35325         this_arg_conv.inner = (void*)(this_arg & (~1));
35326         this_arg_conv.is_owned = false;
35327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35328         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
35329         return ret_val;
35330 }
35331
35332 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
35333         LDKChannelFeatures ret_var = ChannelFeatures_empty();
35334         uint32_t ret_ref = 0;
35335         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35336         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35338         ret_ref = (uintptr_t)ret_var.inner;
35339         if (ret_var.is_owned) {
35340                 ret_ref |= 1;
35341         }
35342         return ret_ref;
35343 }
35344
35345 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
35346         LDKChannelFeatures ret_var = ChannelFeatures_known();
35347         uint32_t ret_ref = 0;
35348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35351         ret_ref = (uintptr_t)ret_var.inner;
35352         if (ret_var.is_owned) {
35353                 ret_ref |= 1;
35354         }
35355         return ret_ref;
35356 }
35357
35358 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
35359         LDKChannelFeatures this_arg_conv;
35360         this_arg_conv.inner = (void*)(this_arg & (~1));
35361         this_arg_conv.is_owned = false;
35362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35363         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
35364         return ret_val;
35365 }
35366
35367 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
35368         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
35369         uint32_t ret_ref = 0;
35370         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35371         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35373         ret_ref = (uintptr_t)ret_var.inner;
35374         if (ret_var.is_owned) {
35375                 ret_ref |= 1;
35376         }
35377         return ret_ref;
35378 }
35379
35380 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
35381         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
35382         uint32_t ret_ref = 0;
35383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35386         ret_ref = (uintptr_t)ret_var.inner;
35387         if (ret_var.is_owned) {
35388                 ret_ref |= 1;
35389         }
35390         return ret_ref;
35391 }
35392
35393 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
35394         LDKInvoiceFeatures this_arg_conv;
35395         this_arg_conv.inner = (void*)(this_arg & (~1));
35396         this_arg_conv.is_owned = false;
35397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35398         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
35399         return ret_val;
35400 }
35401
35402 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
35403         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
35404         uint32_t ret_ref = 0;
35405         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35406         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35408         ret_ref = (uintptr_t)ret_var.inner;
35409         if (ret_var.is_owned) {
35410                 ret_ref |= 1;
35411         }
35412         return ret_ref;
35413 }
35414
35415 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
35416         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
35417         uint32_t ret_ref = 0;
35418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35421         ret_ref = (uintptr_t)ret_var.inner;
35422         if (ret_var.is_owned) {
35423                 ret_ref |= 1;
35424         }
35425         return ret_ref;
35426 }
35427
35428 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
35429         LDKChannelTypeFeatures this_arg_conv;
35430         this_arg_conv.inner = (void*)(this_arg & (~1));
35431         this_arg_conv.is_owned = false;
35432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35433         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
35434         return ret_val;
35435 }
35436
35437 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
35438         LDKInitFeatures obj_conv;
35439         obj_conv.inner = (void*)(obj & (~1));
35440         obj_conv.is_owned = false;
35441         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35442         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
35443         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35444         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35445         CVec_u8Z_free(ret_var);
35446         return ret_arr;
35447 }
35448
35449 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
35450         LDKu8slice ser_ref;
35451         ser_ref.datalen = ser->arr_len;
35452         ser_ref.data = ser->elems /* XXX ser leaks */;
35453         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
35454         *ret_conv = InitFeatures_read(ser_ref);
35455         return (uint32_t)ret_conv;
35456 }
35457
35458 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
35459         LDKChannelFeatures obj_conv;
35460         obj_conv.inner = (void*)(obj & (~1));
35461         obj_conv.is_owned = false;
35462         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35463         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
35464         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35465         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35466         CVec_u8Z_free(ret_var);
35467         return ret_arr;
35468 }
35469
35470 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
35471         LDKu8slice ser_ref;
35472         ser_ref.datalen = ser->arr_len;
35473         ser_ref.data = ser->elems /* XXX ser leaks */;
35474         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
35475         *ret_conv = ChannelFeatures_read(ser_ref);
35476         return (uint32_t)ret_conv;
35477 }
35478
35479 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
35480         LDKNodeFeatures obj_conv;
35481         obj_conv.inner = (void*)(obj & (~1));
35482         obj_conv.is_owned = false;
35483         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35484         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
35485         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35486         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35487         CVec_u8Z_free(ret_var);
35488         return ret_arr;
35489 }
35490
35491 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
35492         LDKu8slice ser_ref;
35493         ser_ref.datalen = ser->arr_len;
35494         ser_ref.data = ser->elems /* XXX ser leaks */;
35495         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
35496         *ret_conv = NodeFeatures_read(ser_ref);
35497         return (uint32_t)ret_conv;
35498 }
35499
35500 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
35501         LDKInvoiceFeatures 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 = InvoiceFeatures_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_InvoiceFeatures_read"))) TS_InvoiceFeatures_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_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
35517         *ret_conv = InvoiceFeatures_read(ser_ref);
35518         return (uint32_t)ret_conv;
35519 }
35520
35521 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
35522         LDKChannelTypeFeatures 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 = ChannelTypeFeatures_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_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_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_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
35538         *ret_conv = ChannelTypeFeatures_read(ser_ref);
35539         return (uint32_t)ret_conv;
35540 }
35541
35542 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
35543         LDKShutdownScript this_obj_conv;
35544         this_obj_conv.inner = (void*)(this_obj & (~1));
35545         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35547         ShutdownScript_free(this_obj_conv);
35548 }
35549
35550 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
35551         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
35552 uint32_t ret_ref = 0;
35553 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35554 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35555 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35556 ret_ref = (uintptr_t)ret_var.inner;
35557 if (ret_var.is_owned) {
35558         ret_ref |= 1;
35559 }
35560         return ret_ref;
35561 }
35562 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
35563         LDKShutdownScript arg_conv;
35564         arg_conv.inner = (void*)(arg & (~1));
35565         arg_conv.is_owned = false;
35566         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35567         uint32_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
35568         return ret_val;
35569 }
35570
35571 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
35572         LDKShutdownScript orig_conv;
35573         orig_conv.inner = (void*)(orig & (~1));
35574         orig_conv.is_owned = false;
35575         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35576         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
35577         uint32_t ret_ref = 0;
35578         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35579         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35581         ret_ref = (uintptr_t)ret_var.inner;
35582         if (ret_var.is_owned) {
35583                 ret_ref |= 1;
35584         }
35585         return ret_ref;
35586 }
35587
35588 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
35589         LDKInvalidShutdownScript this_obj_conv;
35590         this_obj_conv.inner = (void*)(this_obj & (~1));
35591         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35593         InvalidShutdownScript_free(this_obj_conv);
35594 }
35595
35596 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
35597         LDKInvalidShutdownScript this_ptr_conv;
35598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35599         this_ptr_conv.is_owned = false;
35600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35601         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
35602         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35603         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35604         return ret_arr;
35605 }
35606
35607 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
35608         LDKInvalidShutdownScript this_ptr_conv;
35609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35610         this_ptr_conv.is_owned = false;
35611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35612         LDKCVec_u8Z val_ref;
35613         val_ref.datalen = val->arr_len;
35614         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35615         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
35616         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
35617 }
35618
35619 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
35620         LDKCVec_u8Z script_arg_ref;
35621         script_arg_ref.datalen = script_arg->arr_len;
35622         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
35623         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
35624         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
35625         uint32_t ret_ref = 0;
35626         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35627         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35629         ret_ref = (uintptr_t)ret_var.inner;
35630         if (ret_var.is_owned) {
35631                 ret_ref |= 1;
35632         }
35633         return ret_ref;
35634 }
35635
35636 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
35637         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
35638 uint32_t ret_ref = 0;
35639 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35640 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35641 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35642 ret_ref = (uintptr_t)ret_var.inner;
35643 if (ret_var.is_owned) {
35644         ret_ref |= 1;
35645 }
35646         return ret_ref;
35647 }
35648 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
35649         LDKInvalidShutdownScript arg_conv;
35650         arg_conv.inner = (void*)(arg & (~1));
35651         arg_conv.is_owned = false;
35652         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35653         uint32_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
35654         return ret_val;
35655 }
35656
35657 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
35658         LDKInvalidShutdownScript orig_conv;
35659         orig_conv.inner = (void*)(orig & (~1));
35660         orig_conv.is_owned = false;
35661         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35662         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
35663         uint32_t ret_ref = 0;
35664         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35665         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35667         ret_ref = (uintptr_t)ret_var.inner;
35668         if (ret_var.is_owned) {
35669                 ret_ref |= 1;
35670         }
35671         return ret_ref;
35672 }
35673
35674 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
35675         LDKShutdownScript obj_conv;
35676         obj_conv.inner = (void*)(obj & (~1));
35677         obj_conv.is_owned = false;
35678         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35679         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
35680         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35681         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35682         CVec_u8Z_free(ret_var);
35683         return ret_arr;
35684 }
35685
35686 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
35687         LDKu8slice ser_ref;
35688         ser_ref.datalen = ser->arr_len;
35689         ser_ref.data = ser->elems /* XXX ser leaks */;
35690         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
35691         *ret_conv = ShutdownScript_read(ser_ref);
35692         return (uint32_t)ret_conv;
35693 }
35694
35695 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
35696         unsigned char pubkey_hash_arr[20];
35697         CHECK(pubkey_hash->arr_len == 20);
35698         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
35699         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
35700         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
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
35712 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
35713         unsigned char script_hash_arr[32];
35714         CHECK(script_hash->arr_len == 32);
35715         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
35716         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
35717         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
35718         uint32_t ret_ref = 0;
35719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35722         ret_ref = (uintptr_t)ret_var.inner;
35723         if (ret_var.is_owned) {
35724                 ret_ref |= 1;
35725         }
35726         return ret_ref;
35727 }
35728
35729 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
35730         LDKu8slice program_ref;
35731         program_ref.datalen = program->arr_len;
35732         program_ref.data = program->elems /* XXX program leaks */;
35733         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
35734         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
35735         return (uint32_t)ret_conv;
35736 }
35737
35738 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
35739         LDKShutdownScript this_arg_conv;
35740         this_arg_conv.inner = (void*)(this_arg & (~1));
35741         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
35742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35743         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
35744         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
35745         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35746         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35747         CVec_u8Z_free(ret_var);
35748         return ret_arr;
35749 }
35750
35751 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
35752         LDKShutdownScript this_arg_conv;
35753         this_arg_conv.inner = (void*)(this_arg & (~1));
35754         this_arg_conv.is_owned = false;
35755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35756         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35757         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
35758         return ret_arr;
35759 }
35760
35761 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
35762         LDKShutdownScript this_arg_conv;
35763         this_arg_conv.inner = (void*)(this_arg & (~1));
35764         this_arg_conv.is_owned = false;
35765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35766         LDKInitFeatures features_conv;
35767         features_conv.inner = (void*)(features & (~1));
35768         features_conv.is_owned = false;
35769         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
35770         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
35771         return ret_val;
35772 }
35773
35774 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
35775         if ((this_ptr & 1) != 0) return;
35776         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35777         CHECK_ACCESS(this_ptr_ptr);
35778         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
35779         FREE((void*)this_ptr);
35780         CustomMessageReader_free(this_ptr_conv);
35781 }
35782
35783 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
35784         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35785         *ret_ret = Type_clone(arg);
35786         return (uint32_t)ret_ret;
35787 }
35788 uint32_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
35789         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
35790         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
35791         LDKType* arg_conv = (LDKType*)arg_ptr;
35792         uint32_t ret_val = Type_clone_ptr(arg_conv);
35793         return ret_val;
35794 }
35795
35796 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
35797         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
35798         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
35799         LDKType* orig_conv = (LDKType*)orig_ptr;
35800         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35801         *ret_ret = Type_clone(orig_conv);
35802         return (uint32_t)ret_ret;
35803 }
35804
35805 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
35806         if ((this_ptr & 1) != 0) return;
35807         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35808         CHECK_ACCESS(this_ptr_ptr);
35809         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
35810         FREE((void*)this_ptr);
35811         Type_free(this_ptr_conv);
35812 }
35813
35814 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
35815         LDKNodeId this_obj_conv;
35816         this_obj_conv.inner = (void*)(this_obj & (~1));
35817         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35819         NodeId_free(this_obj_conv);
35820 }
35821
35822 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
35823         LDKNodeId ret_var = NodeId_clone(arg);
35824 uint32_t ret_ref = 0;
35825 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35826 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35827 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35828 ret_ref = (uintptr_t)ret_var.inner;
35829 if (ret_var.is_owned) {
35830         ret_ref |= 1;
35831 }
35832         return ret_ref;
35833 }
35834 uint32_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
35835         LDKNodeId arg_conv;
35836         arg_conv.inner = (void*)(arg & (~1));
35837         arg_conv.is_owned = false;
35838         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35839         uint32_t ret_val = NodeId_clone_ptr(&arg_conv);
35840         return ret_val;
35841 }
35842
35843 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
35844         LDKNodeId orig_conv;
35845         orig_conv.inner = (void*)(orig & (~1));
35846         orig_conv.is_owned = false;
35847         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35848         LDKNodeId ret_var = NodeId_clone(&orig_conv);
35849         uint32_t ret_ref = 0;
35850         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35851         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35853         ret_ref = (uintptr_t)ret_var.inner;
35854         if (ret_var.is_owned) {
35855                 ret_ref |= 1;
35856         }
35857         return ret_ref;
35858 }
35859
35860 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
35861         LDKPublicKey pubkey_ref;
35862         CHECK(pubkey->arr_len == 33);
35863         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
35864         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
35865         uint32_t ret_ref = 0;
35866         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35867         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35869         ret_ref = (uintptr_t)ret_var.inner;
35870         if (ret_var.is_owned) {
35871                 ret_ref |= 1;
35872         }
35873         return ret_ref;
35874 }
35875
35876 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
35877         LDKNodeId this_arg_conv;
35878         this_arg_conv.inner = (void*)(this_arg & (~1));
35879         this_arg_conv.is_owned = false;
35880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35881         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
35882         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35883         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35884         return ret_arr;
35885 }
35886
35887 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
35888         LDKNodeId o_conv;
35889         o_conv.inner = (void*)(o & (~1));
35890         o_conv.is_owned = false;
35891         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35892         int64_t ret_val = NodeId_hash(&o_conv);
35893         return ret_val;
35894 }
35895
35896 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
35897         LDKNodeId obj_conv;
35898         obj_conv.inner = (void*)(obj & (~1));
35899         obj_conv.is_owned = false;
35900         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35901         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
35902         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35903         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35904         CVec_u8Z_free(ret_var);
35905         return ret_arr;
35906 }
35907
35908 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
35909         LDKu8slice ser_ref;
35910         ser_ref.datalen = ser->arr_len;
35911         ser_ref.data = ser->elems /* XXX ser leaks */;
35912         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
35913         *ret_conv = NodeId_read(ser_ref);
35914         return (uint32_t)ret_conv;
35915 }
35916
35917 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
35918         LDKNetworkGraph this_obj_conv;
35919         this_obj_conv.inner = (void*)(this_obj & (~1));
35920         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35922         NetworkGraph_free(this_obj_conv);
35923 }
35924
35925 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
35926         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
35927 uint32_t ret_ref = 0;
35928 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35929 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35930 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35931 ret_ref = (uintptr_t)ret_var.inner;
35932 if (ret_var.is_owned) {
35933         ret_ref |= 1;
35934 }
35935         return ret_ref;
35936 }
35937 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone_ptr"))) TS_NetworkGraph_clone_ptr(uint32_t arg) {
35938         LDKNetworkGraph arg_conv;
35939         arg_conv.inner = (void*)(arg & (~1));
35940         arg_conv.is_owned = false;
35941         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35942         uint32_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
35943         return ret_val;
35944 }
35945
35946 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone"))) TS_NetworkGraph_clone(uint32_t orig) {
35947         LDKNetworkGraph orig_conv;
35948         orig_conv.inner = (void*)(orig & (~1));
35949         orig_conv.is_owned = false;
35950         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35951         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
35952         uint32_t ret_ref = 0;
35953         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35954         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35956         ret_ref = (uintptr_t)ret_var.inner;
35957         if (ret_var.is_owned) {
35958                 ret_ref |= 1;
35959         }
35960         return ret_ref;
35961 }
35962
35963 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
35964         LDKReadOnlyNetworkGraph this_obj_conv;
35965         this_obj_conv.inner = (void*)(this_obj & (~1));
35966         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35968         ReadOnlyNetworkGraph_free(this_obj_conv);
35969 }
35970
35971 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
35972         if ((this_ptr & 1) != 0) return;
35973         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35974         CHECK_ACCESS(this_ptr_ptr);
35975         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
35976         FREE((void*)this_ptr);
35977         NetworkUpdate_free(this_ptr_conv);
35978 }
35979
35980 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
35981         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35982         *ret_copy = NetworkUpdate_clone(arg);
35983 uint32_t ret_ref = (uintptr_t)ret_copy;
35984         return ret_ref;
35985 }
35986 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
35987         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
35988         uint32_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
35989         return ret_val;
35990 }
35991
35992 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
35993         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
35994         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
35995         *ret_copy = NetworkUpdate_clone(orig_conv);
35996         uint32_t ret_ref = (uintptr_t)ret_copy;
35997         return ret_ref;
35998 }
35999
36000 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
36001         LDKChannelUpdate msg_conv;
36002         msg_conv.inner = (void*)(msg & (~1));
36003         msg_conv.is_owned = (msg & 1) || (msg == 0);
36004         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36005         msg_conv = ChannelUpdate_clone(&msg_conv);
36006         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36007         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
36008         uint32_t ret_ref = (uintptr_t)ret_copy;
36009         return ret_ref;
36010 }
36011
36012 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_closed"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
36013         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36014         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
36015         uint32_t ret_ref = (uintptr_t)ret_copy;
36016         return ret_ref;
36017 }
36018
36019 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
36020         LDKPublicKey node_id_ref;
36021         CHECK(node_id->arr_len == 33);
36022         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
36023         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36024         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
36025         uint32_t ret_ref = (uintptr_t)ret_copy;
36026         return ret_ref;
36027 }
36028
36029 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
36030         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
36031         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
36032         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36033         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36034         CVec_u8Z_free(ret_var);
36035         return ret_arr;
36036 }
36037
36038 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
36039         LDKu8slice ser_ref;
36040         ser_ref.datalen = ser->arr_len;
36041         ser_ref.data = ser->elems /* XXX ser leaks */;
36042         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
36043         *ret_conv = NetworkUpdate_read(ser_ref);
36044         return (uint32_t)ret_conv;
36045 }
36046
36047 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_EventHandler"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
36048         LDKNetGraphMsgHandler this_arg_conv;
36049         this_arg_conv.inner = (void*)(this_arg & (~1));
36050         this_arg_conv.is_owned = false;
36051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36052         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
36053         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
36054         return (uint32_t)ret_ret;
36055 }
36056
36057 void  __attribute__((export_name("TS_NetGraphMsgHandler_free"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
36058         LDKNetGraphMsgHandler this_obj_conv;
36059         this_obj_conv.inner = (void*)(this_obj & (~1));
36060         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36062         NetGraphMsgHandler_free(this_obj_conv);
36063 }
36064
36065 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_new"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
36066         LDKNetworkGraph network_graph_conv;
36067         network_graph_conv.inner = (void*)(network_graph & (~1));
36068         network_graph_conv.is_owned = false;
36069         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
36070         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
36071         CHECK_ACCESS(chain_access_ptr);
36072         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36073         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
36074         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36075                 // Manually implement clone for Java trait instances
36076                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
36077                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36078                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
36079                 }
36080         }
36081         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
36082         CHECK_ACCESS(logger_ptr);
36083         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
36084         if (logger_conv.free == LDKLogger_JCalls_free) {
36085                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36086                 LDKLogger_JCalls_cloned(&logger_conv);
36087         }
36088         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
36089         uint32_t ret_ref = 0;
36090         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36091         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36093         ret_ref = (uintptr_t)ret_var.inner;
36094         if (ret_var.is_owned) {
36095                 ret_ref |= 1;
36096         }
36097         return ret_ref;
36098 }
36099
36100 void  __attribute__((export_name("TS_NetGraphMsgHandler_add_chain_access"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
36101         LDKNetGraphMsgHandler this_arg_conv;
36102         this_arg_conv.inner = (void*)(this_arg & (~1));
36103         this_arg_conv.is_owned = false;
36104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36105         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
36106         CHECK_ACCESS(chain_access_ptr);
36107         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36108         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
36109         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36110                 // Manually implement clone for Java trait instances
36111                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
36112                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36113                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
36114                 }
36115         }
36116         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
36117 }
36118
36119 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_RoutingMessageHandler"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
36120         LDKNetGraphMsgHandler this_arg_conv;
36121         this_arg_conv.inner = (void*)(this_arg & (~1));
36122         this_arg_conv.is_owned = false;
36123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36124         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
36125         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
36126         return (uint32_t)ret_ret;
36127 }
36128
36129 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_MessageSendEventsProvider"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
36130         LDKNetGraphMsgHandler this_arg_conv;
36131         this_arg_conv.inner = (void*)(this_arg & (~1));
36132         this_arg_conv.is_owned = false;
36133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36134         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36135         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
36136         return (uint32_t)ret_ret;
36137 }
36138
36139 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint32_t this_obj) {
36140         LDKChannelUpdateInfo this_obj_conv;
36141         this_obj_conv.inner = (void*)(this_obj & (~1));
36142         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36144         ChannelUpdateInfo_free(this_obj_conv);
36145 }
36146
36147 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint32_t this_ptr) {
36148         LDKChannelUpdateInfo this_ptr_conv;
36149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36150         this_ptr_conv.is_owned = false;
36151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36152         int32_t ret_val = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
36153         return ret_val;
36154 }
36155
36156 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint32_t this_ptr, int32_t val) {
36157         LDKChannelUpdateInfo this_ptr_conv;
36158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36159         this_ptr_conv.is_owned = false;
36160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36161         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
36162 }
36163
36164 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint32_t this_ptr) {
36165         LDKChannelUpdateInfo this_ptr_conv;
36166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36167         this_ptr_conv.is_owned = false;
36168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36169         jboolean ret_val = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
36170         return ret_val;
36171 }
36172
36173 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint32_t this_ptr, jboolean val) {
36174         LDKChannelUpdateInfo this_ptr_conv;
36175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36176         this_ptr_conv.is_owned = false;
36177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36178         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
36179 }
36180
36181 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
36182         LDKChannelUpdateInfo this_ptr_conv;
36183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36184         this_ptr_conv.is_owned = false;
36185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36186         int16_t ret_val = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
36187         return ret_val;
36188 }
36189
36190 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
36191         LDKChannelUpdateInfo this_ptr_conv;
36192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36193         this_ptr_conv.is_owned = false;
36194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36195         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
36196 }
36197
36198 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
36199         LDKChannelUpdateInfo this_ptr_conv;
36200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36201         this_ptr_conv.is_owned = false;
36202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36203         int64_t ret_val = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
36204         return ret_val;
36205 }
36206
36207 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
36208         LDKChannelUpdateInfo this_ptr_conv;
36209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36210         this_ptr_conv.is_owned = false;
36211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36212         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
36213 }
36214
36215 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
36216         LDKChannelUpdateInfo this_ptr_conv;
36217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36218         this_ptr_conv.is_owned = false;
36219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36220         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36221         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
36222         uint32_t ret_ref = (uintptr_t)ret_copy;
36223         return ret_ref;
36224 }
36225
36226 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
36227         LDKChannelUpdateInfo this_ptr_conv;
36228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36229         this_ptr_conv.is_owned = false;
36230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36231         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36232         CHECK_ACCESS(val_ptr);
36233         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36234         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
36235         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
36236 }
36237
36238 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint32_t this_ptr) {
36239         LDKChannelUpdateInfo this_ptr_conv;
36240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36241         this_ptr_conv.is_owned = false;
36242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36243         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
36244         uint32_t ret_ref = 0;
36245         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36246         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36248         ret_ref = (uintptr_t)ret_var.inner;
36249         if (ret_var.is_owned) {
36250                 ret_ref |= 1;
36251         }
36252         return ret_ref;
36253 }
36254
36255 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint32_t this_ptr, uint32_t val) {
36256         LDKChannelUpdateInfo this_ptr_conv;
36257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36258         this_ptr_conv.is_owned = false;
36259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36260         LDKRoutingFees val_conv;
36261         val_conv.inner = (void*)(val & (~1));
36262         val_conv.is_owned = (val & 1) || (val == 0);
36263         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36264         val_conv = RoutingFees_clone(&val_conv);
36265         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
36266 }
36267
36268 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint32_t this_ptr) {
36269         LDKChannelUpdateInfo this_ptr_conv;
36270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36271         this_ptr_conv.is_owned = false;
36272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36273         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
36274         uint32_t ret_ref = 0;
36275         if ((uintptr_t)ret_var.inner > 4096) {
36276                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36277                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36279                 ret_ref = (uintptr_t)ret_var.inner;
36280                 if (ret_var.is_owned) {
36281                         ret_ref |= 1;
36282                 }
36283         }
36284         return ret_ref;
36285 }
36286
36287 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
36288         LDKChannelUpdateInfo this_ptr_conv;
36289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36290         this_ptr_conv.is_owned = false;
36291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36292         LDKChannelUpdate val_conv;
36293         val_conv.inner = (void*)(val & (~1));
36294         val_conv.is_owned = (val & 1) || (val == 0);
36295         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36296         val_conv = ChannelUpdate_clone(&val_conv);
36297         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
36298 }
36299
36300 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) {
36301         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
36302         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
36303         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
36304         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
36305         LDKRoutingFees fees_arg_conv;
36306         fees_arg_conv.inner = (void*)(fees_arg & (~1));
36307         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
36308         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
36309         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
36310         LDKChannelUpdate last_update_message_arg_conv;
36311         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
36312         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
36313         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
36314         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
36315         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);
36316         uint32_t ret_ref = 0;
36317         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36318         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36320         ret_ref = (uintptr_t)ret_var.inner;
36321         if (ret_var.is_owned) {
36322                 ret_ref |= 1;
36323         }
36324         return ret_ref;
36325 }
36326
36327 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
36328         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
36329 uint32_t ret_ref = 0;
36330 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36331 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36332 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36333 ret_ref = (uintptr_t)ret_var.inner;
36334 if (ret_var.is_owned) {
36335         ret_ref |= 1;
36336 }
36337         return ret_ref;
36338 }
36339 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint32_t arg) {
36340         LDKChannelUpdateInfo arg_conv;
36341         arg_conv.inner = (void*)(arg & (~1));
36342         arg_conv.is_owned = false;
36343         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36344         uint32_t ret_val = ChannelUpdateInfo_clone_ptr(&arg_conv);
36345         return ret_val;
36346 }
36347
36348 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint32_t orig) {
36349         LDKChannelUpdateInfo orig_conv;
36350         orig_conv.inner = (void*)(orig & (~1));
36351         orig_conv.is_owned = false;
36352         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36353         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
36354         uint32_t ret_ref = 0;
36355         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36356         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36358         ret_ref = (uintptr_t)ret_var.inner;
36359         if (ret_var.is_owned) {
36360                 ret_ref |= 1;
36361         }
36362         return ret_ref;
36363 }
36364
36365 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint32_t obj) {
36366         LDKChannelUpdateInfo obj_conv;
36367         obj_conv.inner = (void*)(obj & (~1));
36368         obj_conv.is_owned = false;
36369         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36370         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
36371         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36372         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36373         CVec_u8Z_free(ret_var);
36374         return ret_arr;
36375 }
36376
36377 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_read(int8_tArray ser) {
36378         LDKu8slice ser_ref;
36379         ser_ref.datalen = ser->arr_len;
36380         ser_ref.data = ser->elems /* XXX ser leaks */;
36381         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
36382         *ret_conv = ChannelUpdateInfo_read(ser_ref);
36383         return (uint32_t)ret_conv;
36384 }
36385
36386 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
36387         LDKChannelInfo this_obj_conv;
36388         this_obj_conv.inner = (void*)(this_obj & (~1));
36389         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36391         ChannelInfo_free(this_obj_conv);
36392 }
36393
36394 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
36395         LDKChannelInfo this_ptr_conv;
36396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36397         this_ptr_conv.is_owned = false;
36398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36399         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
36400         uint32_t ret_ref = 0;
36401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36404         ret_ref = (uintptr_t)ret_var.inner;
36405         if (ret_var.is_owned) {
36406                 ret_ref |= 1;
36407         }
36408         return ret_ref;
36409 }
36410
36411 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
36412         LDKChannelInfo this_ptr_conv;
36413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36414         this_ptr_conv.is_owned = false;
36415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36416         LDKChannelFeatures val_conv;
36417         val_conv.inner = (void*)(val & (~1));
36418         val_conv.is_owned = (val & 1) || (val == 0);
36419         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36420         val_conv = ChannelFeatures_clone(&val_conv);
36421         ChannelInfo_set_features(&this_ptr_conv, val_conv);
36422 }
36423
36424 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
36425         LDKChannelInfo this_ptr_conv;
36426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36427         this_ptr_conv.is_owned = false;
36428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36429         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
36430         uint32_t ret_ref = 0;
36431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36434         ret_ref = (uintptr_t)ret_var.inner;
36435         if (ret_var.is_owned) {
36436                 ret_ref |= 1;
36437         }
36438         return ret_ref;
36439 }
36440
36441 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
36442         LDKChannelInfo this_ptr_conv;
36443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36444         this_ptr_conv.is_owned = false;
36445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36446         LDKNodeId val_conv;
36447         val_conv.inner = (void*)(val & (~1));
36448         val_conv.is_owned = (val & 1) || (val == 0);
36449         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36450         val_conv = NodeId_clone(&val_conv);
36451         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
36452 }
36453
36454 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
36455         LDKChannelInfo this_ptr_conv;
36456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36457         this_ptr_conv.is_owned = false;
36458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36459         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
36460         uint32_t ret_ref = 0;
36461         if ((uintptr_t)ret_var.inner > 4096) {
36462                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36463                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36465                 ret_ref = (uintptr_t)ret_var.inner;
36466                 if (ret_var.is_owned) {
36467                         ret_ref |= 1;
36468                 }
36469         }
36470         return ret_ref;
36471 }
36472
36473 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
36474         LDKChannelInfo this_ptr_conv;
36475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36476         this_ptr_conv.is_owned = false;
36477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36478         LDKChannelUpdateInfo val_conv;
36479         val_conv.inner = (void*)(val & (~1));
36480         val_conv.is_owned = (val & 1) || (val == 0);
36481         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36482         val_conv = ChannelUpdateInfo_clone(&val_conv);
36483         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
36484 }
36485
36486 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
36487         LDKChannelInfo this_ptr_conv;
36488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36489         this_ptr_conv.is_owned = false;
36490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36491         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
36492         uint32_t ret_ref = 0;
36493         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36494         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36496         ret_ref = (uintptr_t)ret_var.inner;
36497         if (ret_var.is_owned) {
36498                 ret_ref |= 1;
36499         }
36500         return ret_ref;
36501 }
36502
36503 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
36504         LDKChannelInfo this_ptr_conv;
36505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36506         this_ptr_conv.is_owned = false;
36507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36508         LDKNodeId val_conv;
36509         val_conv.inner = (void*)(val & (~1));
36510         val_conv.is_owned = (val & 1) || (val == 0);
36511         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36512         val_conv = NodeId_clone(&val_conv);
36513         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
36514 }
36515
36516 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
36517         LDKChannelInfo this_ptr_conv;
36518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36519         this_ptr_conv.is_owned = false;
36520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36521         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
36522         uint32_t ret_ref = 0;
36523         if ((uintptr_t)ret_var.inner > 4096) {
36524                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36525                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36527                 ret_ref = (uintptr_t)ret_var.inner;
36528                 if (ret_var.is_owned) {
36529                         ret_ref |= 1;
36530                 }
36531         }
36532         return ret_ref;
36533 }
36534
36535 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
36536         LDKChannelInfo this_ptr_conv;
36537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36538         this_ptr_conv.is_owned = false;
36539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36540         LDKChannelUpdateInfo val_conv;
36541         val_conv.inner = (void*)(val & (~1));
36542         val_conv.is_owned = (val & 1) || (val == 0);
36543         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36544         val_conv = ChannelUpdateInfo_clone(&val_conv);
36545         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
36546 }
36547
36548 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
36549         LDKChannelInfo this_ptr_conv;
36550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36551         this_ptr_conv.is_owned = false;
36552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36553         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36554         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
36555         uint32_t ret_ref = (uintptr_t)ret_copy;
36556         return ret_ref;
36557 }
36558
36559 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
36560         LDKChannelInfo this_ptr_conv;
36561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36562         this_ptr_conv.is_owned = false;
36563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36564         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36565         CHECK_ACCESS(val_ptr);
36566         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36567         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
36568         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
36569 }
36570
36571 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
36572         LDKChannelInfo this_ptr_conv;
36573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36574         this_ptr_conv.is_owned = false;
36575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36576         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
36577         uint32_t ret_ref = 0;
36578         if ((uintptr_t)ret_var.inner > 4096) {
36579                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36580                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36582                 ret_ref = (uintptr_t)ret_var.inner;
36583                 if (ret_var.is_owned) {
36584                         ret_ref |= 1;
36585                 }
36586         }
36587         return ret_ref;
36588 }
36589
36590 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
36591         LDKChannelInfo this_ptr_conv;
36592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36593         this_ptr_conv.is_owned = false;
36594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36595         LDKChannelAnnouncement val_conv;
36596         val_conv.inner = (void*)(val & (~1));
36597         val_conv.is_owned = (val & 1) || (val == 0);
36598         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36599         val_conv = ChannelAnnouncement_clone(&val_conv);
36600         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
36601 }
36602
36603 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
36604         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
36605 uint32_t ret_ref = 0;
36606 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36607 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36608 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36609 ret_ref = (uintptr_t)ret_var.inner;
36610 if (ret_var.is_owned) {
36611         ret_ref |= 1;
36612 }
36613         return ret_ref;
36614 }
36615 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
36616         LDKChannelInfo arg_conv;
36617         arg_conv.inner = (void*)(arg & (~1));
36618         arg_conv.is_owned = false;
36619         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36620         uint32_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
36621         return ret_val;
36622 }
36623
36624 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
36625         LDKChannelInfo orig_conv;
36626         orig_conv.inner = (void*)(orig & (~1));
36627         orig_conv.is_owned = false;
36628         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36629         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
36630         uint32_t ret_ref = 0;
36631         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36632         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36634         ret_ref = (uintptr_t)ret_var.inner;
36635         if (ret_var.is_owned) {
36636                 ret_ref |= 1;
36637         }
36638         return ret_ref;
36639 }
36640
36641 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
36642         LDKChannelInfo obj_conv;
36643         obj_conv.inner = (void*)(obj & (~1));
36644         obj_conv.is_owned = false;
36645         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36646         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
36647         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36648         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36649         CVec_u8Z_free(ret_var);
36650         return ret_arr;
36651 }
36652
36653 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
36654         LDKu8slice ser_ref;
36655         ser_ref.datalen = ser->arr_len;
36656         ser_ref.data = ser->elems /* XXX ser leaks */;
36657         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
36658         *ret_conv = ChannelInfo_read(ser_ref);
36659         return (uint32_t)ret_conv;
36660 }
36661
36662 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint32_t this_obj) {
36663         LDKDirectedChannelInfo this_obj_conv;
36664         this_obj_conv.inner = (void*)(this_obj & (~1));
36665         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36667         DirectedChannelInfo_free(this_obj_conv);
36668 }
36669
36670 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
36671         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
36672 uint32_t ret_ref = 0;
36673 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36674 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36675 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36676 ret_ref = (uintptr_t)ret_var.inner;
36677 if (ret_var.is_owned) {
36678         ret_ref |= 1;
36679 }
36680         return ret_ref;
36681 }
36682 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint32_t arg) {
36683         LDKDirectedChannelInfo arg_conv;
36684         arg_conv.inner = (void*)(arg & (~1));
36685         arg_conv.is_owned = false;
36686         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36687         uint32_t ret_val = DirectedChannelInfo_clone_ptr(&arg_conv);
36688         return ret_val;
36689 }
36690
36691 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint32_t orig) {
36692         LDKDirectedChannelInfo orig_conv;
36693         orig_conv.inner = (void*)(orig & (~1));
36694         orig_conv.is_owned = false;
36695         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36696         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
36697         uint32_t ret_ref = 0;
36698         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36699         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36701         ret_ref = (uintptr_t)ret_var.inner;
36702         if (ret_var.is_owned) {
36703                 ret_ref |= 1;
36704         }
36705         return ret_ref;
36706 }
36707
36708 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint32_t this_arg) {
36709         LDKDirectedChannelInfo this_arg_conv;
36710         this_arg_conv.inner = (void*)(this_arg & (~1));
36711         this_arg_conv.is_owned = false;
36712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36713         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
36714         uint32_t ret_ref = 0;
36715         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36716         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36718         ret_ref = (uintptr_t)ret_var.inner;
36719         if (ret_var.is_owned) {
36720                 ret_ref |= 1;
36721         }
36722         return ret_ref;
36723 }
36724
36725 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint32_t this_arg) {
36726         LDKDirectedChannelInfo this_arg_conv;
36727         this_arg_conv.inner = (void*)(this_arg & (~1));
36728         this_arg_conv.is_owned = false;
36729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36730         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
36731         uint32_t ret_ref = 0;
36732         if ((uintptr_t)ret_var.inner > 4096) {
36733                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36734                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36736                 ret_ref = (uintptr_t)ret_var.inner;
36737                 if (ret_var.is_owned) {
36738                         ret_ref |= 1;
36739                 }
36740         }
36741         return ret_ref;
36742 }
36743
36744 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint32_t this_arg) {
36745         LDKDirectedChannelInfo this_arg_conv;
36746         this_arg_conv.inner = (void*)(this_arg & (~1));
36747         this_arg_conv.is_owned = false;
36748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36749         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36750         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
36751         uint32_t ret_ref = (uintptr_t)ret_copy;
36752         return ret_ref;
36753 }
36754
36755 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint32_t this_ptr) {
36756         if ((this_ptr & 1) != 0) return;
36757         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36758         CHECK_ACCESS(this_ptr_ptr);
36759         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
36760         FREE((void*)this_ptr);
36761         EffectiveCapacity_free(this_ptr_conv);
36762 }
36763
36764 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
36765         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36766         *ret_copy = EffectiveCapacity_clone(arg);
36767 uint32_t ret_ref = (uintptr_t)ret_copy;
36768         return ret_ref;
36769 }
36770 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint32_t arg) {
36771         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
36772         uint32_t ret_val = EffectiveCapacity_clone_ptr(arg_conv);
36773         return ret_val;
36774 }
36775
36776 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint32_t orig) {
36777         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
36778         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36779         *ret_copy = EffectiveCapacity_clone(orig_conv);
36780         uint32_t ret_ref = (uintptr_t)ret_copy;
36781         return ret_ref;
36782 }
36783
36784 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
36785         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36786         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
36787         uint32_t ret_ref = (uintptr_t)ret_copy;
36788         return ret_ref;
36789 }
36790
36791 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
36792         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36793         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
36794         uint32_t ret_ref = (uintptr_t)ret_copy;
36795         return ret_ref;
36796 }
36797
36798 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat) {
36799         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36800         *ret_copy = EffectiveCapacity_total(capacity_msat);
36801         uint32_t ret_ref = (uintptr_t)ret_copy;
36802         return ret_ref;
36803 }
36804
36805 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
36806         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36807         *ret_copy = EffectiveCapacity_infinite();
36808         uint32_t ret_ref = (uintptr_t)ret_copy;
36809         return ret_ref;
36810 }
36811
36812 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
36813         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36814         *ret_copy = EffectiveCapacity_unknown();
36815         uint32_t ret_ref = (uintptr_t)ret_copy;
36816         return ret_ref;
36817 }
36818
36819 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint32_t this_arg) {
36820         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
36821         int64_t ret_val = EffectiveCapacity_as_msat(this_arg_conv);
36822         return ret_val;
36823 }
36824
36825 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
36826         LDKRoutingFees this_obj_conv;
36827         this_obj_conv.inner = (void*)(this_obj & (~1));
36828         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36830         RoutingFees_free(this_obj_conv);
36831 }
36832
36833 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
36834         LDKRoutingFees this_ptr_conv;
36835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36836         this_ptr_conv.is_owned = false;
36837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36838         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
36839         return ret_val;
36840 }
36841
36842 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
36843         LDKRoutingFees this_ptr_conv;
36844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36845         this_ptr_conv.is_owned = false;
36846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36847         RoutingFees_set_base_msat(&this_ptr_conv, val);
36848 }
36849
36850 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
36851         LDKRoutingFees this_ptr_conv;
36852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36853         this_ptr_conv.is_owned = false;
36854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36855         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
36856         return ret_val;
36857 }
36858
36859 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
36860         LDKRoutingFees this_ptr_conv;
36861         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36862         this_ptr_conv.is_owned = false;
36863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36864         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
36865 }
36866
36867 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
36868         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
36869         uint32_t ret_ref = 0;
36870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36873         ret_ref = (uintptr_t)ret_var.inner;
36874         if (ret_var.is_owned) {
36875                 ret_ref |= 1;
36876         }
36877         return ret_ref;
36878 }
36879
36880 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
36881         LDKRoutingFees a_conv;
36882         a_conv.inner = (void*)(a & (~1));
36883         a_conv.is_owned = false;
36884         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36885         LDKRoutingFees b_conv;
36886         b_conv.inner = (void*)(b & (~1));
36887         b_conv.is_owned = false;
36888         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36889         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
36890         return ret_val;
36891 }
36892
36893 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
36894         LDKRoutingFees ret_var = RoutingFees_clone(arg);
36895 uint32_t ret_ref = 0;
36896 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36897 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36898 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36899 ret_ref = (uintptr_t)ret_var.inner;
36900 if (ret_var.is_owned) {
36901         ret_ref |= 1;
36902 }
36903         return ret_ref;
36904 }
36905 uint32_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
36906         LDKRoutingFees arg_conv;
36907         arg_conv.inner = (void*)(arg & (~1));
36908         arg_conv.is_owned = false;
36909         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36910         uint32_t ret_val = RoutingFees_clone_ptr(&arg_conv);
36911         return ret_val;
36912 }
36913
36914 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
36915         LDKRoutingFees orig_conv;
36916         orig_conv.inner = (void*)(orig & (~1));
36917         orig_conv.is_owned = false;
36918         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36919         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
36920         uint32_t ret_ref = 0;
36921         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36922         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36924         ret_ref = (uintptr_t)ret_var.inner;
36925         if (ret_var.is_owned) {
36926                 ret_ref |= 1;
36927         }
36928         return ret_ref;
36929 }
36930
36931 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
36932         LDKRoutingFees o_conv;
36933         o_conv.inner = (void*)(o & (~1));
36934         o_conv.is_owned = false;
36935         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36936         int64_t ret_val = RoutingFees_hash(&o_conv);
36937         return ret_val;
36938 }
36939
36940 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
36941         LDKRoutingFees obj_conv;
36942         obj_conv.inner = (void*)(obj & (~1));
36943         obj_conv.is_owned = false;
36944         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36945         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
36946         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36947         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36948         CVec_u8Z_free(ret_var);
36949         return ret_arr;
36950 }
36951
36952 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
36953         LDKu8slice ser_ref;
36954         ser_ref.datalen = ser->arr_len;
36955         ser_ref.data = ser->elems /* XXX ser leaks */;
36956         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
36957         *ret_conv = RoutingFees_read(ser_ref);
36958         return (uint32_t)ret_conv;
36959 }
36960
36961 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
36962         LDKNodeAnnouncementInfo this_obj_conv;
36963         this_obj_conv.inner = (void*)(this_obj & (~1));
36964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36966         NodeAnnouncementInfo_free(this_obj_conv);
36967 }
36968
36969 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
36970         LDKNodeAnnouncementInfo this_ptr_conv;
36971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36972         this_ptr_conv.is_owned = false;
36973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36974         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
36975         uint32_t ret_ref = 0;
36976         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36977         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36979         ret_ref = (uintptr_t)ret_var.inner;
36980         if (ret_var.is_owned) {
36981                 ret_ref |= 1;
36982         }
36983         return ret_ref;
36984 }
36985
36986 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
36987         LDKNodeAnnouncementInfo this_ptr_conv;
36988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36989         this_ptr_conv.is_owned = false;
36990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36991         LDKNodeFeatures val_conv;
36992         val_conv.inner = (void*)(val & (~1));
36993         val_conv.is_owned = (val & 1) || (val == 0);
36994         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36995         val_conv = NodeFeatures_clone(&val_conv);
36996         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
36997 }
36998
36999 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
37000         LDKNodeAnnouncementInfo this_ptr_conv;
37001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37002         this_ptr_conv.is_owned = false;
37003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37004         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
37005         return ret_val;
37006 }
37007
37008 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
37009         LDKNodeAnnouncementInfo this_ptr_conv;
37010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37011         this_ptr_conv.is_owned = false;
37012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37013         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
37014 }
37015
37016 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
37017         LDKNodeAnnouncementInfo this_ptr_conv;
37018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37019         this_ptr_conv.is_owned = false;
37020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37021         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
37022         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
37023         return ret_arr;
37024 }
37025
37026 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
37027         LDKNodeAnnouncementInfo this_ptr_conv;
37028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37029         this_ptr_conv.is_owned = false;
37030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37031         LDKThreeBytes val_ref;
37032         CHECK(val->arr_len == 3);
37033         memcpy(val_ref.data, val->elems, 3); FREE(val);
37034         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
37035 }
37036
37037 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
37038         LDKNodeAnnouncementInfo this_ptr_conv;
37039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37040         this_ptr_conv.is_owned = false;
37041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37042         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37043         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
37044         return ret_arr;
37045 }
37046
37047 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
37048         LDKNodeAnnouncementInfo this_ptr_conv;
37049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37050         this_ptr_conv.is_owned = false;
37051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37052         LDKThirtyTwoBytes val_ref;
37053         CHECK(val->arr_len == 32);
37054         memcpy(val_ref.data, val->elems, 32); FREE(val);
37055         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
37056 }
37057
37058 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
37059         LDKNodeAnnouncementInfo this_ptr_conv;
37060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37061         this_ptr_conv.is_owned = false;
37062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37063         LDKCVec_NetAddressZ val_constr;
37064         val_constr.datalen = val->arr_len;
37065         if (val_constr.datalen > 0)
37066                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
37067         else
37068                 val_constr.data = NULL;
37069         uint32_t* val_vals = val->elems /* XXX val leaks */;
37070         for (size_t m = 0; m < val_constr.datalen; m++) {
37071                 uint32_t val_conv_12 = val_vals[m];
37072                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
37073                 CHECK_ACCESS(val_conv_12_ptr);
37074                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
37075                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
37076                 val_constr.data[m] = val_conv_12_conv;
37077         }
37078         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
37079 }
37080
37081 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
37082         LDKNodeAnnouncementInfo this_ptr_conv;
37083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37084         this_ptr_conv.is_owned = false;
37085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37086         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
37087         uint32_t ret_ref = 0;
37088         if ((uintptr_t)ret_var.inner > 4096) {
37089                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37090                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37092                 ret_ref = (uintptr_t)ret_var.inner;
37093                 if (ret_var.is_owned) {
37094                         ret_ref |= 1;
37095                 }
37096         }
37097         return ret_ref;
37098 }
37099
37100 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
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         LDKNodeAnnouncement val_conv;
37106         val_conv.inner = (void*)(val & (~1));
37107         val_conv.is_owned = (val & 1) || (val == 0);
37108         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37109         val_conv = NodeAnnouncement_clone(&val_conv);
37110         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
37111 }
37112
37113 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) {
37114         LDKNodeFeatures features_arg_conv;
37115         features_arg_conv.inner = (void*)(features_arg & (~1));
37116         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
37117         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
37118         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
37119         LDKThreeBytes rgb_arg_ref;
37120         CHECK(rgb_arg->arr_len == 3);
37121         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
37122         LDKThirtyTwoBytes alias_arg_ref;
37123         CHECK(alias_arg->arr_len == 32);
37124         memcpy(alias_arg_ref.data, alias_arg->elems, 32); FREE(alias_arg);
37125         LDKCVec_NetAddressZ addresses_arg_constr;
37126         addresses_arg_constr.datalen = addresses_arg->arr_len;
37127         if (addresses_arg_constr.datalen > 0)
37128                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
37129         else
37130                 addresses_arg_constr.data = NULL;
37131         uint32_t* addresses_arg_vals = addresses_arg->elems /* XXX addresses_arg leaks */;
37132         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
37133                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
37134                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
37135                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
37136                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
37137                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
37138         }
37139         LDKNodeAnnouncement announcement_message_arg_conv;
37140         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
37141         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
37142         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
37143         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
37144         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
37145         uint32_t ret_ref = 0;
37146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37149         ret_ref = (uintptr_t)ret_var.inner;
37150         if (ret_var.is_owned) {
37151                 ret_ref |= 1;
37152         }
37153         return ret_ref;
37154 }
37155
37156 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
37157         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
37158 uint32_t ret_ref = 0;
37159 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37160 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37161 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37162 ret_ref = (uintptr_t)ret_var.inner;
37163 if (ret_var.is_owned) {
37164         ret_ref |= 1;
37165 }
37166         return ret_ref;
37167 }
37168 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
37169         LDKNodeAnnouncementInfo arg_conv;
37170         arg_conv.inner = (void*)(arg & (~1));
37171         arg_conv.is_owned = false;
37172         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37173         uint32_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
37174         return ret_val;
37175 }
37176
37177 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
37178         LDKNodeAnnouncementInfo orig_conv;
37179         orig_conv.inner = (void*)(orig & (~1));
37180         orig_conv.is_owned = false;
37181         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37182         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
37183         uint32_t ret_ref = 0;
37184         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37185         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37187         ret_ref = (uintptr_t)ret_var.inner;
37188         if (ret_var.is_owned) {
37189                 ret_ref |= 1;
37190         }
37191         return ret_ref;
37192 }
37193
37194 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
37195         LDKNodeAnnouncementInfo obj_conv;
37196         obj_conv.inner = (void*)(obj & (~1));
37197         obj_conv.is_owned = false;
37198         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37199         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
37200         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37201         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37202         CVec_u8Z_free(ret_var);
37203         return ret_arr;
37204 }
37205
37206 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
37207         LDKu8slice ser_ref;
37208         ser_ref.datalen = ser->arr_len;
37209         ser_ref.data = ser->elems /* XXX ser leaks */;
37210         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
37211         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
37212         return (uint32_t)ret_conv;
37213 }
37214
37215 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
37216         LDKNodeInfo this_obj_conv;
37217         this_obj_conv.inner = (void*)(this_obj & (~1));
37218         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37220         NodeInfo_free(this_obj_conv);
37221 }
37222
37223 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
37224         LDKNodeInfo this_ptr_conv;
37225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37226         this_ptr_conv.is_owned = false;
37227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37228         LDKCVec_u64Z val_constr;
37229         val_constr.datalen = val->arr_len;
37230         if (val_constr.datalen > 0)
37231                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37232         else
37233                 val_constr.data = NULL;
37234         int64_t* val_vals = val->elems /* XXX val leaks */;
37235         for (size_t i = 0; i < val_constr.datalen; i++) {
37236                 int64_t val_conv_8 = val_vals[i];
37237                 val_constr.data[i] = val_conv_8;
37238         }
37239         NodeInfo_set_channels(&this_ptr_conv, val_constr);
37240 }
37241
37242 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
37243         LDKNodeInfo this_ptr_conv;
37244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37245         this_ptr_conv.is_owned = false;
37246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37247         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
37248         uint32_t ret_ref = 0;
37249         if ((uintptr_t)ret_var.inner > 4096) {
37250                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37251                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37253                 ret_ref = (uintptr_t)ret_var.inner;
37254                 if (ret_var.is_owned) {
37255                         ret_ref |= 1;
37256                 }
37257         }
37258         return ret_ref;
37259 }
37260
37261 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) {
37262         LDKNodeInfo this_ptr_conv;
37263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37264         this_ptr_conv.is_owned = false;
37265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37266         LDKRoutingFees val_conv;
37267         val_conv.inner = (void*)(val & (~1));
37268         val_conv.is_owned = (val & 1) || (val == 0);
37269         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37270         val_conv = RoutingFees_clone(&val_conv);
37271         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
37272 }
37273
37274 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
37275         LDKNodeInfo this_ptr_conv;
37276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37277         this_ptr_conv.is_owned = false;
37278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37279         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
37280         uint32_t ret_ref = 0;
37281         if ((uintptr_t)ret_var.inner > 4096) {
37282                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37283                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37285                 ret_ref = (uintptr_t)ret_var.inner;
37286                 if (ret_var.is_owned) {
37287                         ret_ref |= 1;
37288                 }
37289         }
37290         return ret_ref;
37291 }
37292
37293 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
37294         LDKNodeInfo this_ptr_conv;
37295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37296         this_ptr_conv.is_owned = false;
37297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37298         LDKNodeAnnouncementInfo val_conv;
37299         val_conv.inner = (void*)(val & (~1));
37300         val_conv.is_owned = (val & 1) || (val == 0);
37301         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37302         val_conv = NodeAnnouncementInfo_clone(&val_conv);
37303         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
37304 }
37305
37306 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) {
37307         LDKCVec_u64Z channels_arg_constr;
37308         channels_arg_constr.datalen = channels_arg->arr_len;
37309         if (channels_arg_constr.datalen > 0)
37310                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37311         else
37312                 channels_arg_constr.data = NULL;
37313         int64_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
37314         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
37315                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
37316                 channels_arg_constr.data[i] = channels_arg_conv_8;
37317         }
37318         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
37319         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
37320         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
37321         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
37322         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
37323         LDKNodeAnnouncementInfo announcement_info_arg_conv;
37324         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
37325         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
37326         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
37327         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
37328         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
37329         uint32_t ret_ref = 0;
37330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37333         ret_ref = (uintptr_t)ret_var.inner;
37334         if (ret_var.is_owned) {
37335                 ret_ref |= 1;
37336         }
37337         return ret_ref;
37338 }
37339
37340 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
37341         LDKNodeInfo ret_var = NodeInfo_clone(arg);
37342 uint32_t ret_ref = 0;
37343 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37344 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37345 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37346 ret_ref = (uintptr_t)ret_var.inner;
37347 if (ret_var.is_owned) {
37348         ret_ref |= 1;
37349 }
37350         return ret_ref;
37351 }
37352 uint32_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
37353         LDKNodeInfo arg_conv;
37354         arg_conv.inner = (void*)(arg & (~1));
37355         arg_conv.is_owned = false;
37356         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37357         uint32_t ret_val = NodeInfo_clone_ptr(&arg_conv);
37358         return ret_val;
37359 }
37360
37361 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
37362         LDKNodeInfo orig_conv;
37363         orig_conv.inner = (void*)(orig & (~1));
37364         orig_conv.is_owned = false;
37365         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37366         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
37367         uint32_t ret_ref = 0;
37368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37371         ret_ref = (uintptr_t)ret_var.inner;
37372         if (ret_var.is_owned) {
37373                 ret_ref |= 1;
37374         }
37375         return ret_ref;
37376 }
37377
37378 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
37379         LDKNodeInfo obj_conv;
37380         obj_conv.inner = (void*)(obj & (~1));
37381         obj_conv.is_owned = false;
37382         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37383         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
37384         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37385         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37386         CVec_u8Z_free(ret_var);
37387         return ret_arr;
37388 }
37389
37390 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
37391         LDKu8slice ser_ref;
37392         ser_ref.datalen = ser->arr_len;
37393         ser_ref.data = ser->elems /* XXX ser leaks */;
37394         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
37395         *ret_conv = NodeInfo_read(ser_ref);
37396         return (uint32_t)ret_conv;
37397 }
37398
37399 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
37400         LDKNetworkGraph obj_conv;
37401         obj_conv.inner = (void*)(obj & (~1));
37402         obj_conv.is_owned = false;
37403         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37404         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
37405         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37406         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37407         CVec_u8Z_free(ret_var);
37408         return ret_arr;
37409 }
37410
37411 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser) {
37412         LDKu8slice ser_ref;
37413         ser_ref.datalen = ser->arr_len;
37414         ser_ref.data = ser->elems /* XXX ser leaks */;
37415         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
37416         *ret_conv = NetworkGraph_read(ser_ref);
37417         return (uint32_t)ret_conv;
37418 }
37419
37420 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
37421         LDKThirtyTwoBytes genesis_hash_ref;
37422         CHECK(genesis_hash->arr_len == 32);
37423         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
37424         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
37425         uint32_t ret_ref = 0;
37426         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37427         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37429         ret_ref = (uintptr_t)ret_var.inner;
37430         if (ret_var.is_owned) {
37431                 ret_ref |= 1;
37432         }
37433         return ret_ref;
37434 }
37435
37436 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
37437         LDKNetworkGraph this_arg_conv;
37438         this_arg_conv.inner = (void*)(this_arg & (~1));
37439         this_arg_conv.is_owned = false;
37440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37441         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
37442         uint32_t ret_ref = 0;
37443         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37444         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37446         ret_ref = (uintptr_t)ret_var.inner;
37447         if (ret_var.is_owned) {
37448                 ret_ref |= 1;
37449         }
37450         return ret_ref;
37451 }
37452
37453 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
37454         LDKNetworkGraph this_arg_conv;
37455         this_arg_conv.inner = (void*)(this_arg & (~1));
37456         this_arg_conv.is_owned = false;
37457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37458         LDKNodeAnnouncement msg_conv;
37459         msg_conv.inner = (void*)(msg & (~1));
37460         msg_conv.is_owned = false;
37461         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37462         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37463         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
37464         return (uint32_t)ret_conv;
37465 }
37466
37467 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) {
37468         LDKNetworkGraph this_arg_conv;
37469         this_arg_conv.inner = (void*)(this_arg & (~1));
37470         this_arg_conv.is_owned = false;
37471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37472         LDKUnsignedNodeAnnouncement msg_conv;
37473         msg_conv.inner = (void*)(msg & (~1));
37474         msg_conv.is_owned = false;
37475         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37476         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37477         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
37478         return (uint32_t)ret_conv;
37479 }
37480
37481 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) {
37482         LDKNetworkGraph this_arg_conv;
37483         this_arg_conv.inner = (void*)(this_arg & (~1));
37484         this_arg_conv.is_owned = false;
37485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37486         LDKChannelAnnouncement msg_conv;
37487         msg_conv.inner = (void*)(msg & (~1));
37488         msg_conv.is_owned = false;
37489         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37490         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
37491         CHECK_ACCESS(chain_access_ptr);
37492         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37493         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
37494         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37495                 // Manually implement clone for Java trait instances
37496                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
37497                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37498                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
37499                 }
37500         }
37501         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37502         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
37503         return (uint32_t)ret_conv;
37504 }
37505
37506 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) {
37507         LDKNetworkGraph this_arg_conv;
37508         this_arg_conv.inner = (void*)(this_arg & (~1));
37509         this_arg_conv.is_owned = false;
37510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37511         LDKUnsignedChannelAnnouncement msg_conv;
37512         msg_conv.inner = (void*)(msg & (~1));
37513         msg_conv.is_owned = false;
37514         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37515         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
37516         CHECK_ACCESS(chain_access_ptr);
37517         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37518         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
37519         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37520                 // Manually implement clone for Java trait instances
37521                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
37522                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37523                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
37524                 }
37525         }
37526         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37527         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
37528         return (uint32_t)ret_conv;
37529 }
37530
37531 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) {
37532         LDKNetworkGraph this_arg_conv;
37533         this_arg_conv.inner = (void*)(this_arg & (~1));
37534         this_arg_conv.is_owned = false;
37535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37536         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
37537 }
37538
37539 void  __attribute__((export_name("TS_NetworkGraph_fail_node"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
37540         LDKNetworkGraph this_arg_conv;
37541         this_arg_conv.inner = (void*)(this_arg & (~1));
37542         this_arg_conv.is_owned = false;
37543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37544         LDKPublicKey _node_id_ref;
37545         CHECK(_node_id->arr_len == 33);
37546         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
37547         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
37548 }
37549
37550 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) {
37551         LDKNetworkGraph this_arg_conv;
37552         this_arg_conv.inner = (void*)(this_arg & (~1));
37553         this_arg_conv.is_owned = false;
37554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37555         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
37556 }
37557
37558 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
37559         LDKNetworkGraph this_arg_conv;
37560         this_arg_conv.inner = (void*)(this_arg & (~1));
37561         this_arg_conv.is_owned = false;
37562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37563         LDKChannelUpdate msg_conv;
37564         msg_conv.inner = (void*)(msg & (~1));
37565         msg_conv.is_owned = false;
37566         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37567         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37568         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
37569         return (uint32_t)ret_conv;
37570 }
37571
37572 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
37573         LDKNetworkGraph this_arg_conv;
37574         this_arg_conv.inner = (void*)(this_arg & (~1));
37575         this_arg_conv.is_owned = false;
37576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37577         LDKUnsignedChannelUpdate msg_conv;
37578         msg_conv.inner = (void*)(msg & (~1));
37579         msg_conv.is_owned = false;
37580         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37581         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37582         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
37583         return (uint32_t)ret_conv;
37584 }
37585
37586 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
37587         LDKReadOnlyNetworkGraph this_arg_conv;
37588         this_arg_conv.inner = (void*)(this_arg & (~1));
37589         this_arg_conv.is_owned = false;
37590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37591         LDKPublicKey pubkey_ref;
37592         CHECK(pubkey->arr_len == 33);
37593         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
37594         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
37595         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
37596         uint32_t ret_ref = (uintptr_t)ret_copy;
37597         return ret_ref;
37598 }
37599
37600 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
37601         LDKRouteHop this_obj_conv;
37602         this_obj_conv.inner = (void*)(this_obj & (~1));
37603         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37605         RouteHop_free(this_obj_conv);
37606 }
37607
37608 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
37609         LDKRouteHop this_ptr_conv;
37610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37611         this_ptr_conv.is_owned = false;
37612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37613         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
37614         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
37615         return ret_arr;
37616 }
37617
37618 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
37619         LDKRouteHop this_ptr_conv;
37620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37621         this_ptr_conv.is_owned = false;
37622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37623         LDKPublicKey val_ref;
37624         CHECK(val->arr_len == 33);
37625         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
37626         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
37627 }
37628
37629 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
37630         LDKRouteHop this_ptr_conv;
37631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37632         this_ptr_conv.is_owned = false;
37633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37634         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
37635         uint32_t ret_ref = 0;
37636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37639         ret_ref = (uintptr_t)ret_var.inner;
37640         if (ret_var.is_owned) {
37641                 ret_ref |= 1;
37642         }
37643         return ret_ref;
37644 }
37645
37646 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
37647         LDKRouteHop this_ptr_conv;
37648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37649         this_ptr_conv.is_owned = false;
37650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37651         LDKNodeFeatures val_conv;
37652         val_conv.inner = (void*)(val & (~1));
37653         val_conv.is_owned = (val & 1) || (val == 0);
37654         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37655         val_conv = NodeFeatures_clone(&val_conv);
37656         RouteHop_set_node_features(&this_ptr_conv, val_conv);
37657 }
37658
37659 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
37660         LDKRouteHop this_ptr_conv;
37661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37662         this_ptr_conv.is_owned = false;
37663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37664         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
37665         return ret_val;
37666 }
37667
37668 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
37669         LDKRouteHop this_ptr_conv;
37670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37671         this_ptr_conv.is_owned = false;
37672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37673         RouteHop_set_short_channel_id(&this_ptr_conv, val);
37674 }
37675
37676 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
37677         LDKRouteHop this_ptr_conv;
37678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37679         this_ptr_conv.is_owned = false;
37680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37681         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
37682         uint32_t ret_ref = 0;
37683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37686         ret_ref = (uintptr_t)ret_var.inner;
37687         if (ret_var.is_owned) {
37688                 ret_ref |= 1;
37689         }
37690         return ret_ref;
37691 }
37692
37693 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
37694         LDKRouteHop this_ptr_conv;
37695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37696         this_ptr_conv.is_owned = false;
37697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37698         LDKChannelFeatures val_conv;
37699         val_conv.inner = (void*)(val & (~1));
37700         val_conv.is_owned = (val & 1) || (val == 0);
37701         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37702         val_conv = ChannelFeatures_clone(&val_conv);
37703         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
37704 }
37705
37706 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
37707         LDKRouteHop this_ptr_conv;
37708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37709         this_ptr_conv.is_owned = false;
37710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37711         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
37712         return ret_val;
37713 }
37714
37715 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
37716         LDKRouteHop this_ptr_conv;
37717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37718         this_ptr_conv.is_owned = false;
37719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37720         RouteHop_set_fee_msat(&this_ptr_conv, val);
37721 }
37722
37723 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
37724         LDKRouteHop this_ptr_conv;
37725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37726         this_ptr_conv.is_owned = false;
37727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37728         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
37729         return ret_val;
37730 }
37731
37732 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
37733         LDKRouteHop this_ptr_conv;
37734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37735         this_ptr_conv.is_owned = false;
37736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37737         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
37738 }
37739
37740 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) {
37741         LDKPublicKey pubkey_arg_ref;
37742         CHECK(pubkey_arg->arr_len == 33);
37743         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
37744         LDKNodeFeatures node_features_arg_conv;
37745         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
37746         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
37747         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
37748         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
37749         LDKChannelFeatures channel_features_arg_conv;
37750         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
37751         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
37752         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
37753         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
37754         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);
37755         uint32_t ret_ref = 0;
37756         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37757         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37759         ret_ref = (uintptr_t)ret_var.inner;
37760         if (ret_var.is_owned) {
37761                 ret_ref |= 1;
37762         }
37763         return ret_ref;
37764 }
37765
37766 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
37767         LDKRouteHop ret_var = RouteHop_clone(arg);
37768 uint32_t ret_ref = 0;
37769 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37770 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37771 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37772 ret_ref = (uintptr_t)ret_var.inner;
37773 if (ret_var.is_owned) {
37774         ret_ref |= 1;
37775 }
37776         return ret_ref;
37777 }
37778 uint32_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
37779         LDKRouteHop arg_conv;
37780         arg_conv.inner = (void*)(arg & (~1));
37781         arg_conv.is_owned = false;
37782         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37783         uint32_t ret_val = RouteHop_clone_ptr(&arg_conv);
37784         return ret_val;
37785 }
37786
37787 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
37788         LDKRouteHop orig_conv;
37789         orig_conv.inner = (void*)(orig & (~1));
37790         orig_conv.is_owned = false;
37791         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37792         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
37793         uint32_t ret_ref = 0;
37794         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37795         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37797         ret_ref = (uintptr_t)ret_var.inner;
37798         if (ret_var.is_owned) {
37799                 ret_ref |= 1;
37800         }
37801         return ret_ref;
37802 }
37803
37804 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
37805         LDKRouteHop o_conv;
37806         o_conv.inner = (void*)(o & (~1));
37807         o_conv.is_owned = false;
37808         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37809         int64_t ret_val = RouteHop_hash(&o_conv);
37810         return ret_val;
37811 }
37812
37813 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
37814         LDKRouteHop a_conv;
37815         a_conv.inner = (void*)(a & (~1));
37816         a_conv.is_owned = false;
37817         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37818         LDKRouteHop b_conv;
37819         b_conv.inner = (void*)(b & (~1));
37820         b_conv.is_owned = false;
37821         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37822         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
37823         return ret_val;
37824 }
37825
37826 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
37827         LDKRouteHop obj_conv;
37828         obj_conv.inner = (void*)(obj & (~1));
37829         obj_conv.is_owned = false;
37830         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37831         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
37832         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37833         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37834         CVec_u8Z_free(ret_var);
37835         return ret_arr;
37836 }
37837
37838 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
37839         LDKu8slice ser_ref;
37840         ser_ref.datalen = ser->arr_len;
37841         ser_ref.data = ser->elems /* XXX ser leaks */;
37842         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
37843         *ret_conv = RouteHop_read(ser_ref);
37844         return (uint32_t)ret_conv;
37845 }
37846
37847 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
37848         LDKRoute this_obj_conv;
37849         this_obj_conv.inner = (void*)(this_obj & (~1));
37850         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37852         Route_free(this_obj_conv);
37853 }
37854
37855 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
37856         LDKRoute this_ptr_conv;
37857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37858         this_ptr_conv.is_owned = false;
37859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37860         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
37861         ptrArray ret_arr = NULL;
37862         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
37863         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
37864         for (size_t m = 0; m < ret_var.datalen; m++) {
37865                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
37866                 uint32_tArray ret_conv_12_arr = NULL;
37867                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
37868                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
37869                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
37870                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
37871                         uint32_t ret_conv_12_conv_10_ref = 0;
37872                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37873                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37874                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
37875                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
37876                         if (ret_conv_12_conv_10_var.is_owned) {
37877                                 ret_conv_12_conv_10_ref |= 1;
37878                         }
37879                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
37880                 }
37881                 
37882                 FREE(ret_conv_12_var.data);
37883                 ret_arr_ptr[m] = ret_conv_12_arr;
37884         }
37885         
37886         FREE(ret_var.data);
37887         return ret_arr;
37888 }
37889
37890 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
37891         LDKRoute this_ptr_conv;
37892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37893         this_ptr_conv.is_owned = false;
37894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37895         LDKCVec_CVec_RouteHopZZ val_constr;
37896         val_constr.datalen = val->arr_len;
37897         if (val_constr.datalen > 0)
37898                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37899         else
37900                 val_constr.data = NULL;
37901         uint32_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
37902         for (size_t m = 0; m < val_constr.datalen; m++) {
37903                 uint32_tArray val_conv_12 = val_vals[m];
37904                 LDKCVec_RouteHopZ val_conv_12_constr;
37905                 val_conv_12_constr.datalen = val_conv_12->arr_len;
37906                 if (val_conv_12_constr.datalen > 0)
37907                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37908                 else
37909                         val_conv_12_constr.data = NULL;
37910                 uint32_t* val_conv_12_vals = val_conv_12->elems /* XXX val_conv_12 leaks */;
37911                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
37912                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
37913                         LDKRouteHop val_conv_12_conv_10_conv;
37914                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
37915                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
37916                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
37917                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
37918                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
37919                 }
37920                 val_constr.data[m] = val_conv_12_constr;
37921         }
37922         Route_set_paths(&this_ptr_conv, val_constr);
37923 }
37924
37925 uint32_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint32_t this_ptr) {
37926         LDKRoute this_ptr_conv;
37927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37928         this_ptr_conv.is_owned = false;
37929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37930         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
37931         uint32_t ret_ref = 0;
37932         if ((uintptr_t)ret_var.inner > 4096) {
37933                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37934                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37936                 ret_ref = (uintptr_t)ret_var.inner;
37937                 if (ret_var.is_owned) {
37938                         ret_ref |= 1;
37939                 }
37940         }
37941         return ret_ref;
37942 }
37943
37944 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint32_t this_ptr, uint32_t val) {
37945         LDKRoute this_ptr_conv;
37946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37947         this_ptr_conv.is_owned = false;
37948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37949         LDKPaymentParameters val_conv;
37950         val_conv.inner = (void*)(val & (~1));
37951         val_conv.is_owned = (val & 1) || (val == 0);
37952         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37953         val_conv = PaymentParameters_clone(&val_conv);
37954         Route_set_payment_params(&this_ptr_conv, val_conv);
37955 }
37956
37957 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payment_params_arg) {
37958         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
37959         paths_arg_constr.datalen = paths_arg->arr_len;
37960         if (paths_arg_constr.datalen > 0)
37961                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37962         else
37963                 paths_arg_constr.data = NULL;
37964         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems /* XXX paths_arg leaks */;
37965         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
37966                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
37967                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
37968                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
37969                 if (paths_arg_conv_12_constr.datalen > 0)
37970                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37971                 else
37972                         paths_arg_conv_12_constr.data = NULL;
37973                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems /* XXX paths_arg_conv_12 leaks */;
37974                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
37975                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
37976                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
37977                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
37978                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
37979                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
37980                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
37981                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
37982                 }
37983                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
37984         }
37985         LDKPaymentParameters payment_params_arg_conv;
37986         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
37987         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
37988         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
37989         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
37990         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
37991         uint32_t ret_ref = 0;
37992         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37993         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37995         ret_ref = (uintptr_t)ret_var.inner;
37996         if (ret_var.is_owned) {
37997                 ret_ref |= 1;
37998         }
37999         return ret_ref;
38000 }
38001
38002 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
38003         LDKRoute ret_var = Route_clone(arg);
38004 uint32_t ret_ref = 0;
38005 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38006 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38007 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38008 ret_ref = (uintptr_t)ret_var.inner;
38009 if (ret_var.is_owned) {
38010         ret_ref |= 1;
38011 }
38012         return ret_ref;
38013 }
38014 uint32_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
38015         LDKRoute arg_conv;
38016         arg_conv.inner = (void*)(arg & (~1));
38017         arg_conv.is_owned = false;
38018         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38019         uint32_t ret_val = Route_clone_ptr(&arg_conv);
38020         return ret_val;
38021 }
38022
38023 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
38024         LDKRoute orig_conv;
38025         orig_conv.inner = (void*)(orig & (~1));
38026         orig_conv.is_owned = false;
38027         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38028         LDKRoute ret_var = Route_clone(&orig_conv);
38029         uint32_t ret_ref = 0;
38030         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38031         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38033         ret_ref = (uintptr_t)ret_var.inner;
38034         if (ret_var.is_owned) {
38035                 ret_ref |= 1;
38036         }
38037         return ret_ref;
38038 }
38039
38040 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
38041         LDKRoute o_conv;
38042         o_conv.inner = (void*)(o & (~1));
38043         o_conv.is_owned = false;
38044         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38045         int64_t ret_val = Route_hash(&o_conv);
38046         return ret_val;
38047 }
38048
38049 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
38050         LDKRoute a_conv;
38051         a_conv.inner = (void*)(a & (~1));
38052         a_conv.is_owned = false;
38053         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38054         LDKRoute b_conv;
38055         b_conv.inner = (void*)(b & (~1));
38056         b_conv.is_owned = false;
38057         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38058         jboolean ret_val = Route_eq(&a_conv, &b_conv);
38059         return ret_val;
38060 }
38061
38062 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
38063         LDKRoute this_arg_conv;
38064         this_arg_conv.inner = (void*)(this_arg & (~1));
38065         this_arg_conv.is_owned = false;
38066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38067         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
38068         return ret_val;
38069 }
38070
38071 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
38072         LDKRoute this_arg_conv;
38073         this_arg_conv.inner = (void*)(this_arg & (~1));
38074         this_arg_conv.is_owned = false;
38075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38076         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
38077         return ret_val;
38078 }
38079
38080 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
38081         LDKRoute obj_conv;
38082         obj_conv.inner = (void*)(obj & (~1));
38083         obj_conv.is_owned = false;
38084         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38085         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
38086         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38087         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38088         CVec_u8Z_free(ret_var);
38089         return ret_arr;
38090 }
38091
38092 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
38093         LDKu8slice ser_ref;
38094         ser_ref.datalen = ser->arr_len;
38095         ser_ref.data = ser->elems /* XXX ser leaks */;
38096         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
38097         *ret_conv = Route_read(ser_ref);
38098         return (uint32_t)ret_conv;
38099 }
38100
38101 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
38102         LDKRouteParameters this_obj_conv;
38103         this_obj_conv.inner = (void*)(this_obj & (~1));
38104         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38106         RouteParameters_free(this_obj_conv);
38107 }
38108
38109 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint32_t this_ptr) {
38110         LDKRouteParameters this_ptr_conv;
38111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38112         this_ptr_conv.is_owned = false;
38113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38114         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
38115         uint32_t ret_ref = 0;
38116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38119         ret_ref = (uintptr_t)ret_var.inner;
38120         if (ret_var.is_owned) {
38121                 ret_ref |= 1;
38122         }
38123         return ret_ref;
38124 }
38125
38126 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint32_t this_ptr, uint32_t val) {
38127         LDKRouteParameters this_ptr_conv;
38128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38129         this_ptr_conv.is_owned = false;
38130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38131         LDKPaymentParameters val_conv;
38132         val_conv.inner = (void*)(val & (~1));
38133         val_conv.is_owned = (val & 1) || (val == 0);
38134         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38135         val_conv = PaymentParameters_clone(&val_conv);
38136         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
38137 }
38138
38139 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
38140         LDKRouteParameters this_ptr_conv;
38141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38142         this_ptr_conv.is_owned = false;
38143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38144         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
38145         return ret_val;
38146 }
38147
38148 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
38149         LDKRouteParameters this_ptr_conv;
38150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38151         this_ptr_conv.is_owned = false;
38152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38153         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
38154 }
38155
38156 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
38157         LDKRouteParameters this_ptr_conv;
38158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38159         this_ptr_conv.is_owned = false;
38160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38161         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
38162         return ret_val;
38163 }
38164
38165 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) {
38166         LDKRouteParameters this_ptr_conv;
38167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38168         this_ptr_conv.is_owned = false;
38169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38170         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
38171 }
38172
38173 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) {
38174         LDKPaymentParameters payment_params_arg_conv;
38175         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
38176         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
38177         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
38178         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
38179         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
38180         uint32_t ret_ref = 0;
38181         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38182         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38184         ret_ref = (uintptr_t)ret_var.inner;
38185         if (ret_var.is_owned) {
38186                 ret_ref |= 1;
38187         }
38188         return ret_ref;
38189 }
38190
38191 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
38192         LDKRouteParameters ret_var = RouteParameters_clone(arg);
38193 uint32_t ret_ref = 0;
38194 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38195 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38196 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38197 ret_ref = (uintptr_t)ret_var.inner;
38198 if (ret_var.is_owned) {
38199         ret_ref |= 1;
38200 }
38201         return ret_ref;
38202 }
38203 uint32_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
38204         LDKRouteParameters arg_conv;
38205         arg_conv.inner = (void*)(arg & (~1));
38206         arg_conv.is_owned = false;
38207         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38208         uint32_t ret_val = RouteParameters_clone_ptr(&arg_conv);
38209         return ret_val;
38210 }
38211
38212 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
38213         LDKRouteParameters orig_conv;
38214         orig_conv.inner = (void*)(orig & (~1));
38215         orig_conv.is_owned = false;
38216         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38217         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
38218         uint32_t ret_ref = 0;
38219         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38220         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38222         ret_ref = (uintptr_t)ret_var.inner;
38223         if (ret_var.is_owned) {
38224                 ret_ref |= 1;
38225         }
38226         return ret_ref;
38227 }
38228
38229 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
38230         LDKRouteParameters obj_conv;
38231         obj_conv.inner = (void*)(obj & (~1));
38232         obj_conv.is_owned = false;
38233         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38234         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
38235         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38236         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38237         CVec_u8Z_free(ret_var);
38238         return ret_arr;
38239 }
38240
38241 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
38242         LDKu8slice ser_ref;
38243         ser_ref.datalen = ser->arr_len;
38244         ser_ref.data = ser->elems /* XXX ser leaks */;
38245         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
38246         *ret_conv = RouteParameters_read(ser_ref);
38247         return (uint32_t)ret_conv;
38248 }
38249
38250 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint32_t this_obj) {
38251         LDKPaymentParameters this_obj_conv;
38252         this_obj_conv.inner = (void*)(this_obj & (~1));
38253         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38255         PaymentParameters_free(this_obj_conv);
38256 }
38257
38258 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint32_t this_ptr) {
38259         LDKPaymentParameters this_ptr_conv;
38260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38261         this_ptr_conv.is_owned = false;
38262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38263         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38264         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
38265         return ret_arr;
38266 }
38267
38268 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint32_t this_ptr, int8_tArray val) {
38269         LDKPaymentParameters this_ptr_conv;
38270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38271         this_ptr_conv.is_owned = false;
38272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38273         LDKPublicKey val_ref;
38274         CHECK(val->arr_len == 33);
38275         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38276         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
38277 }
38278
38279 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint32_t this_ptr) {
38280         LDKPaymentParameters this_ptr_conv;
38281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38282         this_ptr_conv.is_owned = false;
38283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38284         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
38285         uint32_t ret_ref = 0;
38286         if ((uintptr_t)ret_var.inner > 4096) {
38287                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38288                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38290                 ret_ref = (uintptr_t)ret_var.inner;
38291                 if (ret_var.is_owned) {
38292                         ret_ref |= 1;
38293                 }
38294         }
38295         return ret_ref;
38296 }
38297
38298 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint32_t this_ptr, uint32_t val) {
38299         LDKPaymentParameters this_ptr_conv;
38300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38301         this_ptr_conv.is_owned = false;
38302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38303         LDKInvoiceFeatures val_conv;
38304         val_conv.inner = (void*)(val & (~1));
38305         val_conv.is_owned = (val & 1) || (val == 0);
38306         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38307         val_conv = InvoiceFeatures_clone(&val_conv);
38308         PaymentParameters_set_features(&this_ptr_conv, val_conv);
38309 }
38310
38311 uint32_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint32_t this_ptr) {
38312         LDKPaymentParameters this_ptr_conv;
38313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38314         this_ptr_conv.is_owned = false;
38315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38316         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
38317         uint32_tArray ret_arr = NULL;
38318         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
38319         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
38320         for (size_t l = 0; l < ret_var.datalen; l++) {
38321                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
38322                 uint32_t ret_conv_11_ref = 0;
38323                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38324                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38325                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
38326                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
38327                 if (ret_conv_11_var.is_owned) {
38328                         ret_conv_11_ref |= 1;
38329                 }
38330                 ret_arr_ptr[l] = ret_conv_11_ref;
38331         }
38332         
38333         FREE(ret_var.data);
38334         return ret_arr;
38335 }
38336
38337 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
38338         LDKPaymentParameters this_ptr_conv;
38339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38340         this_ptr_conv.is_owned = false;
38341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38342         LDKCVec_RouteHintZ val_constr;
38343         val_constr.datalen = val->arr_len;
38344         if (val_constr.datalen > 0)
38345                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
38346         else
38347                 val_constr.data = NULL;
38348         uint32_t* val_vals = val->elems /* XXX val leaks */;
38349         for (size_t l = 0; l < val_constr.datalen; l++) {
38350                 uint32_t val_conv_11 = val_vals[l];
38351                 LDKRouteHint val_conv_11_conv;
38352                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
38353                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
38354                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
38355                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
38356                 val_constr.data[l] = val_conv_11_conv;
38357         }
38358         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
38359 }
38360
38361 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint32_t this_ptr) {
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         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38367         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
38368         uint32_t ret_ref = (uintptr_t)ret_copy;
38369         return ret_ref;
38370 }
38371
38372 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint32_t this_ptr, uint32_t val) {
38373         LDKPaymentParameters this_ptr_conv;
38374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38375         this_ptr_conv.is_owned = false;
38376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38377         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38378         CHECK_ACCESS(val_ptr);
38379         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38380         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38381         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
38382 }
38383
38384 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) {
38385         LDKPaymentParameters this_ptr_conv;
38386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38387         this_ptr_conv.is_owned = false;
38388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38389         int32_t ret_val = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
38390         return ret_val;
38391 }
38392
38393 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) {
38394         LDKPaymentParameters this_ptr_conv;
38395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38396         this_ptr_conv.is_owned = false;
38397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38398         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
38399 }
38400
38401 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) {
38402         LDKPublicKey payee_pubkey_arg_ref;
38403         CHECK(payee_pubkey_arg->arr_len == 33);
38404         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
38405         LDKInvoiceFeatures features_arg_conv;
38406         features_arg_conv.inner = (void*)(features_arg & (~1));
38407         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
38408         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
38409         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
38410         LDKCVec_RouteHintZ route_hints_arg_constr;
38411         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
38412         if (route_hints_arg_constr.datalen > 0)
38413                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
38414         else
38415                 route_hints_arg_constr.data = NULL;
38416         uint32_t* route_hints_arg_vals = route_hints_arg->elems /* XXX route_hints_arg leaks */;
38417         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
38418                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
38419                 LDKRouteHint route_hints_arg_conv_11_conv;
38420                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
38421                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
38422                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
38423                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
38424                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
38425         }
38426         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
38427         CHECK_ACCESS(expiry_time_arg_ptr);
38428         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
38429         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
38430         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);
38431         uint32_t ret_ref = 0;
38432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38435         ret_ref = (uintptr_t)ret_var.inner;
38436         if (ret_var.is_owned) {
38437                 ret_ref |= 1;
38438         }
38439         return ret_ref;
38440 }
38441
38442 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
38443         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
38444 uint32_t ret_ref = 0;
38445 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38446 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38447 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38448 ret_ref = (uintptr_t)ret_var.inner;
38449 if (ret_var.is_owned) {
38450         ret_ref |= 1;
38451 }
38452         return ret_ref;
38453 }
38454 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint32_t arg) {
38455         LDKPaymentParameters arg_conv;
38456         arg_conv.inner = (void*)(arg & (~1));
38457         arg_conv.is_owned = false;
38458         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38459         uint32_t ret_val = PaymentParameters_clone_ptr(&arg_conv);
38460         return ret_val;
38461 }
38462
38463 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint32_t orig) {
38464         LDKPaymentParameters orig_conv;
38465         orig_conv.inner = (void*)(orig & (~1));
38466         orig_conv.is_owned = false;
38467         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38468         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
38469         uint32_t ret_ref = 0;
38470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38473         ret_ref = (uintptr_t)ret_var.inner;
38474         if (ret_var.is_owned) {
38475                 ret_ref |= 1;
38476         }
38477         return ret_ref;
38478 }
38479
38480 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint32_t o) {
38481         LDKPaymentParameters o_conv;
38482         o_conv.inner = (void*)(o & (~1));
38483         o_conv.is_owned = false;
38484         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38485         int64_t ret_val = PaymentParameters_hash(&o_conv);
38486         return ret_val;
38487 }
38488
38489 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint32_t a, uint32_t b) {
38490         LDKPaymentParameters a_conv;
38491         a_conv.inner = (void*)(a & (~1));
38492         a_conv.is_owned = false;
38493         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38494         LDKPaymentParameters b_conv;
38495         b_conv.inner = (void*)(b & (~1));
38496         b_conv.is_owned = false;
38497         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38498         jboolean ret_val = PaymentParameters_eq(&a_conv, &b_conv);
38499         return ret_val;
38500 }
38501
38502 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint32_t obj) {
38503         LDKPaymentParameters obj_conv;
38504         obj_conv.inner = (void*)(obj & (~1));
38505         obj_conv.is_owned = false;
38506         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38507         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
38508         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38509         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38510         CVec_u8Z_free(ret_var);
38511         return ret_arr;
38512 }
38513
38514 uint32_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
38515         LDKu8slice ser_ref;
38516         ser_ref.datalen = ser->arr_len;
38517         ser_ref.data = ser->elems /* XXX ser leaks */;
38518         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
38519         *ret_conv = PaymentParameters_read(ser_ref);
38520         return (uint32_t)ret_conv;
38521 }
38522
38523 uint32_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
38524         LDKPublicKey payee_pubkey_ref;
38525         CHECK(payee_pubkey->arr_len == 33);
38526         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
38527         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
38528         uint32_t ret_ref = 0;
38529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38532         ret_ref = (uintptr_t)ret_var.inner;
38533         if (ret_var.is_owned) {
38534                 ret_ref |= 1;
38535         }
38536         return ret_ref;
38537 }
38538
38539 uint32_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
38540         LDKPublicKey payee_pubkey_ref;
38541         CHECK(payee_pubkey->arr_len == 33);
38542         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
38543         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
38544         uint32_t ret_ref = 0;
38545         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38546         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38548         ret_ref = (uintptr_t)ret_var.inner;
38549         if (ret_var.is_owned) {
38550                 ret_ref |= 1;
38551         }
38552         return ret_ref;
38553 }
38554
38555 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
38556         LDKRouteHint this_obj_conv;
38557         this_obj_conv.inner = (void*)(this_obj & (~1));
38558         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38560         RouteHint_free(this_obj_conv);
38561 }
38562
38563 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
38564         LDKRouteHint this_ptr_conv;
38565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38566         this_ptr_conv.is_owned = false;
38567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38568         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
38569         uint32_tArray ret_arr = NULL;
38570         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
38571         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
38572         for (size_t o = 0; o < ret_var.datalen; o++) {
38573                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
38574                 uint32_t ret_conv_14_ref = 0;
38575                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38576                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38577                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
38578                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
38579                 if (ret_conv_14_var.is_owned) {
38580                         ret_conv_14_ref |= 1;
38581                 }
38582                 ret_arr_ptr[o] = ret_conv_14_ref;
38583         }
38584         
38585         FREE(ret_var.data);
38586         return ret_arr;
38587 }
38588
38589 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
38590         LDKRouteHint this_ptr_conv;
38591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38592         this_ptr_conv.is_owned = false;
38593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38594         LDKCVec_RouteHintHopZ val_constr;
38595         val_constr.datalen = val->arr_len;
38596         if (val_constr.datalen > 0)
38597                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
38598         else
38599                 val_constr.data = NULL;
38600         uint32_t* val_vals = val->elems /* XXX val leaks */;
38601         for (size_t o = 0; o < val_constr.datalen; o++) {
38602                 uint32_t val_conv_14 = val_vals[o];
38603                 LDKRouteHintHop val_conv_14_conv;
38604                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
38605                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
38606                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
38607                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
38608                 val_constr.data[o] = val_conv_14_conv;
38609         }
38610         RouteHint_set_a(&this_ptr_conv, val_constr);
38611 }
38612
38613 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
38614         LDKCVec_RouteHintHopZ a_arg_constr;
38615         a_arg_constr.datalen = a_arg->arr_len;
38616         if (a_arg_constr.datalen > 0)
38617                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
38618         else
38619                 a_arg_constr.data = NULL;
38620         uint32_t* a_arg_vals = a_arg->elems /* XXX a_arg leaks */;
38621         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
38622                 uint32_t a_arg_conv_14 = a_arg_vals[o];
38623                 LDKRouteHintHop a_arg_conv_14_conv;
38624                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
38625                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
38626                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
38627                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
38628                 a_arg_constr.data[o] = a_arg_conv_14_conv;
38629         }
38630         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
38631         uint32_t ret_ref = 0;
38632         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38633         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38635         ret_ref = (uintptr_t)ret_var.inner;
38636         if (ret_var.is_owned) {
38637                 ret_ref |= 1;
38638         }
38639         return ret_ref;
38640 }
38641
38642 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
38643         LDKRouteHint ret_var = RouteHint_clone(arg);
38644 uint32_t ret_ref = 0;
38645 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38646 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38647 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38648 ret_ref = (uintptr_t)ret_var.inner;
38649 if (ret_var.is_owned) {
38650         ret_ref |= 1;
38651 }
38652         return ret_ref;
38653 }
38654 uint32_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
38655         LDKRouteHint arg_conv;
38656         arg_conv.inner = (void*)(arg & (~1));
38657         arg_conv.is_owned = false;
38658         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38659         uint32_t ret_val = RouteHint_clone_ptr(&arg_conv);
38660         return ret_val;
38661 }
38662
38663 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
38664         LDKRouteHint orig_conv;
38665         orig_conv.inner = (void*)(orig & (~1));
38666         orig_conv.is_owned = false;
38667         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38668         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
38669         uint32_t ret_ref = 0;
38670         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38671         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38673         ret_ref = (uintptr_t)ret_var.inner;
38674         if (ret_var.is_owned) {
38675                 ret_ref |= 1;
38676         }
38677         return ret_ref;
38678 }
38679
38680 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
38681         LDKRouteHint o_conv;
38682         o_conv.inner = (void*)(o & (~1));
38683         o_conv.is_owned = false;
38684         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38685         int64_t ret_val = RouteHint_hash(&o_conv);
38686         return ret_val;
38687 }
38688
38689 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
38690         LDKRouteHint a_conv;
38691         a_conv.inner = (void*)(a & (~1));
38692         a_conv.is_owned = false;
38693         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38694         LDKRouteHint b_conv;
38695         b_conv.inner = (void*)(b & (~1));
38696         b_conv.is_owned = false;
38697         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38698         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
38699         return ret_val;
38700 }
38701
38702 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
38703         LDKRouteHint obj_conv;
38704         obj_conv.inner = (void*)(obj & (~1));
38705         obj_conv.is_owned = false;
38706         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38707         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
38708         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38709         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38710         CVec_u8Z_free(ret_var);
38711         return ret_arr;
38712 }
38713
38714 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
38715         LDKu8slice ser_ref;
38716         ser_ref.datalen = ser->arr_len;
38717         ser_ref.data = ser->elems /* XXX ser leaks */;
38718         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
38719         *ret_conv = RouteHint_read(ser_ref);
38720         return (uint32_t)ret_conv;
38721 }
38722
38723 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
38724         LDKRouteHintHop this_obj_conv;
38725         this_obj_conv.inner = (void*)(this_obj & (~1));
38726         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38728         RouteHintHop_free(this_obj_conv);
38729 }
38730
38731 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
38732         LDKRouteHintHop this_ptr_conv;
38733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38734         this_ptr_conv.is_owned = false;
38735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38736         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38737         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
38738         return ret_arr;
38739 }
38740
38741 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
38742         LDKRouteHintHop this_ptr_conv;
38743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38744         this_ptr_conv.is_owned = false;
38745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38746         LDKPublicKey val_ref;
38747         CHECK(val->arr_len == 33);
38748         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38749         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
38750 }
38751
38752 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
38753         LDKRouteHintHop this_ptr_conv;
38754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38755         this_ptr_conv.is_owned = false;
38756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38757         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
38758         return ret_val;
38759 }
38760
38761 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
38762         LDKRouteHintHop this_ptr_conv;
38763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38764         this_ptr_conv.is_owned = false;
38765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38766         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
38767 }
38768
38769 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
38770         LDKRouteHintHop this_ptr_conv;
38771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38772         this_ptr_conv.is_owned = false;
38773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38774         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
38775         uint32_t ret_ref = 0;
38776         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38777         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38779         ret_ref = (uintptr_t)ret_var.inner;
38780         if (ret_var.is_owned) {
38781                 ret_ref |= 1;
38782         }
38783         return ret_ref;
38784 }
38785
38786 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
38787         LDKRouteHintHop this_ptr_conv;
38788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38789         this_ptr_conv.is_owned = false;
38790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38791         LDKRoutingFees val_conv;
38792         val_conv.inner = (void*)(val & (~1));
38793         val_conv.is_owned = (val & 1) || (val == 0);
38794         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38795         val_conv = RoutingFees_clone(&val_conv);
38796         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
38797 }
38798
38799 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
38800         LDKRouteHintHop this_ptr_conv;
38801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38802         this_ptr_conv.is_owned = false;
38803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38804         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
38805         return ret_val;
38806 }
38807
38808 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
38809         LDKRouteHintHop this_ptr_conv;
38810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38811         this_ptr_conv.is_owned = false;
38812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38813         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
38814 }
38815
38816 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
38817         LDKRouteHintHop this_ptr_conv;
38818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38819         this_ptr_conv.is_owned = false;
38820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38821         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38822         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
38823         uint32_t ret_ref = (uintptr_t)ret_copy;
38824         return ret_ref;
38825 }
38826
38827 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
38828         LDKRouteHintHop this_ptr_conv;
38829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38830         this_ptr_conv.is_owned = false;
38831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38832         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38833         CHECK_ACCESS(val_ptr);
38834         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38835         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38836         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
38837 }
38838
38839 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
38840         LDKRouteHintHop this_ptr_conv;
38841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38842         this_ptr_conv.is_owned = false;
38843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38844         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38845         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
38846         uint32_t ret_ref = (uintptr_t)ret_copy;
38847         return ret_ref;
38848 }
38849
38850 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
38851         LDKRouteHintHop this_ptr_conv;
38852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38853         this_ptr_conv.is_owned = false;
38854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38855         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38856         CHECK_ACCESS(val_ptr);
38857         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38858         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38859         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
38860 }
38861
38862 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) {
38863         LDKPublicKey src_node_id_arg_ref;
38864         CHECK(src_node_id_arg->arr_len == 33);
38865         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
38866         LDKRoutingFees fees_arg_conv;
38867         fees_arg_conv.inner = (void*)(fees_arg & (~1));
38868         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
38869         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
38870         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
38871         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
38872         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
38873         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
38874         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
38875         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
38876         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
38877         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
38878         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
38879         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);
38880         uint32_t ret_ref = 0;
38881         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38882         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38884         ret_ref = (uintptr_t)ret_var.inner;
38885         if (ret_var.is_owned) {
38886                 ret_ref |= 1;
38887         }
38888         return ret_ref;
38889 }
38890
38891 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
38892         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
38893 uint32_t ret_ref = 0;
38894 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38895 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38896 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38897 ret_ref = (uintptr_t)ret_var.inner;
38898 if (ret_var.is_owned) {
38899         ret_ref |= 1;
38900 }
38901         return ret_ref;
38902 }
38903 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
38904         LDKRouteHintHop arg_conv;
38905         arg_conv.inner = (void*)(arg & (~1));
38906         arg_conv.is_owned = false;
38907         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38908         uint32_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
38909         return ret_val;
38910 }
38911
38912 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
38913         LDKRouteHintHop orig_conv;
38914         orig_conv.inner = (void*)(orig & (~1));
38915         orig_conv.is_owned = false;
38916         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38917         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
38918         uint32_t ret_ref = 0;
38919         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38920         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38922         ret_ref = (uintptr_t)ret_var.inner;
38923         if (ret_var.is_owned) {
38924                 ret_ref |= 1;
38925         }
38926         return ret_ref;
38927 }
38928
38929 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
38930         LDKRouteHintHop o_conv;
38931         o_conv.inner = (void*)(o & (~1));
38932         o_conv.is_owned = false;
38933         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38934         int64_t ret_val = RouteHintHop_hash(&o_conv);
38935         return ret_val;
38936 }
38937
38938 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
38939         LDKRouteHintHop a_conv;
38940         a_conv.inner = (void*)(a & (~1));
38941         a_conv.is_owned = false;
38942         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38943         LDKRouteHintHop b_conv;
38944         b_conv.inner = (void*)(b & (~1));
38945         b_conv.is_owned = false;
38946         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38947         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
38948         return ret_val;
38949 }
38950
38951 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
38952         LDKRouteHintHop obj_conv;
38953         obj_conv.inner = (void*)(obj & (~1));
38954         obj_conv.is_owned = false;
38955         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38956         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
38957         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38958         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38959         CVec_u8Z_free(ret_var);
38960         return ret_arr;
38961 }
38962
38963 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
38964         LDKu8slice ser_ref;
38965         ser_ref.datalen = ser->arr_len;
38966         ser_ref.data = ser->elems /* XXX ser leaks */;
38967         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
38968         *ret_conv = RouteHintHop_read(ser_ref);
38969         return (uint32_t)ret_conv;
38970 }
38971
38972 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) {
38973         LDKPublicKey our_node_pubkey_ref;
38974         CHECK(our_node_pubkey->arr_len == 33);
38975         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
38976         LDKRouteParameters route_params_conv;
38977         route_params_conv.inner = (void*)(route_params & (~1));
38978         route_params_conv.is_owned = false;
38979         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
38980         LDKNetworkGraph network_conv;
38981         network_conv.inner = (void*)(network & (~1));
38982         network_conv.is_owned = false;
38983         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
38984         LDKCVec_ChannelDetailsZ first_hops_constr;
38985         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
38986         if (first_hops != 0) {
38987                 first_hops_constr.datalen = first_hops->arr_len;
38988                 if (first_hops_constr.datalen > 0)
38989                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
38990                 else
38991                         first_hops_constr.data = NULL;
38992                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
38993                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
38994                         uint32_t first_hops_conv_16 = first_hops_vals[q];
38995                         LDKChannelDetails first_hops_conv_16_conv;
38996                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
38997                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
38998                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
38999                         first_hops_constr.data[q] = first_hops_conv_16_conv;
39000                 }
39001                 first_hops_ptr = &first_hops_constr;
39002         }
39003         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
39004         CHECK_ACCESS(logger_ptr);
39005         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39006         if (logger_conv.free == LDKLogger_JCalls_free) {
39007                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39008                 LDKLogger_JCalls_cloned(&logger_conv);
39009         }
39010         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
39011         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
39012         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
39013         unsigned char random_seed_bytes_arr[32];
39014         CHECK(random_seed_bytes->arr_len == 32);
39015         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
39016         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
39017         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
39018         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
39019         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
39020         return (uint32_t)ret_conv;
39021 }
39022
39023 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
39024         if ((this_ptr & 1) != 0) return;
39025         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39026         CHECK_ACCESS(this_ptr_ptr);
39027         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
39028         FREE((void*)this_ptr);
39029         Score_free(this_ptr_conv);
39030 }
39031
39032 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
39033         if ((this_ptr & 1) != 0) return;
39034         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39035         CHECK_ACCESS(this_ptr_ptr);
39036         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
39037         FREE((void*)this_ptr);
39038         LockableScore_free(this_ptr_conv);
39039 }
39040
39041 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
39042         LDKMultiThreadedLockableScore this_obj_conv;
39043         this_obj_conv.inner = (void*)(this_obj & (~1));
39044         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39046         MultiThreadedLockableScore_free(this_obj_conv);
39047 }
39048
39049 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
39050         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
39051         CHECK_ACCESS(score_ptr);
39052         LDKScore score_conv = *(LDKScore*)(score_ptr);
39053         if (score_conv.free == LDKScore_JCalls_free) {
39054                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39055                 LDKScore_JCalls_cloned(&score_conv);
39056         }
39057         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
39058         uint32_t ret_ref = 0;
39059         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39060         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39062         ret_ref = (uintptr_t)ret_var.inner;
39063         if (ret_var.is_owned) {
39064                 ret_ref |= 1;
39065         }
39066         return ret_ref;
39067 }
39068
39069 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint32_t this_obj) {
39070         LDKFixedPenaltyScorer this_obj_conv;
39071         this_obj_conv.inner = (void*)(this_obj & (~1));
39072         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39074         FixedPenaltyScorer_free(this_obj_conv);
39075 }
39076
39077 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
39078         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
39079 uint32_t ret_ref = 0;
39080 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39081 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39082 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39083 ret_ref = (uintptr_t)ret_var.inner;
39084 if (ret_var.is_owned) {
39085         ret_ref |= 1;
39086 }
39087         return ret_ref;
39088 }
39089 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint32_t arg) {
39090         LDKFixedPenaltyScorer arg_conv;
39091         arg_conv.inner = (void*)(arg & (~1));
39092         arg_conv.is_owned = false;
39093         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39094         uint32_t ret_val = FixedPenaltyScorer_clone_ptr(&arg_conv);
39095         return ret_val;
39096 }
39097
39098 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint32_t orig) {
39099         LDKFixedPenaltyScorer orig_conv;
39100         orig_conv.inner = (void*)(orig & (~1));
39101         orig_conv.is_owned = false;
39102         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39103         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
39104         uint32_t ret_ref = 0;
39105         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39106         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39108         ret_ref = (uintptr_t)ret_var.inner;
39109         if (ret_var.is_owned) {
39110                 ret_ref |= 1;
39111         }
39112         return ret_ref;
39113 }
39114
39115 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
39116         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
39117         uint32_t ret_ref = 0;
39118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39121         ret_ref = (uintptr_t)ret_var.inner;
39122         if (ret_var.is_owned) {
39123                 ret_ref |= 1;
39124         }
39125         return ret_ref;
39126 }
39127
39128 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint32_t this_arg) {
39129         LDKFixedPenaltyScorer this_arg_conv;
39130         this_arg_conv.inner = (void*)(this_arg & (~1));
39131         this_arg_conv.is_owned = false;
39132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39133         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
39134         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
39135         return (uint32_t)ret_ret;
39136 }
39137
39138 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint32_t obj) {
39139         LDKFixedPenaltyScorer obj_conv;
39140         obj_conv.inner = (void*)(obj & (~1));
39141         obj_conv.is_owned = false;
39142         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39143         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
39144         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39145         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39146         CVec_u8Z_free(ret_var);
39147         return ret_arr;
39148 }
39149
39150 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser, int64_t arg) {
39151         LDKu8slice ser_ref;
39152         ser_ref.datalen = ser->arr_len;
39153         ser_ref.data = ser->elems /* XXX ser leaks */;
39154         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
39155         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
39156         return (uint32_t)ret_conv;
39157 }
39158
39159 void  __attribute__((export_name("TS_Scorer_free"))) TS_Scorer_free(uint32_t this_obj) {
39160         LDKScorer this_obj_conv;
39161         this_obj_conv.inner = (void*)(this_obj & (~1));
39162         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39164         Scorer_free(this_obj_conv);
39165 }
39166
39167 void  __attribute__((export_name("TS_ScoringParameters_free"))) TS_ScoringParameters_free(uint32_t this_obj) {
39168         LDKScoringParameters this_obj_conv;
39169         this_obj_conv.inner = (void*)(this_obj & (~1));
39170         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39172         ScoringParameters_free(this_obj_conv);
39173 }
39174
39175 int64_t  __attribute__((export_name("TS_ScoringParameters_get_base_penalty_msat"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
39176         LDKScoringParameters this_ptr_conv;
39177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39178         this_ptr_conv.is_owned = false;
39179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39180         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
39181         return ret_val;
39182 }
39183
39184 void  __attribute__((export_name("TS_ScoringParameters_set_base_penalty_msat"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
39185         LDKScoringParameters this_ptr_conv;
39186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39187         this_ptr_conv.is_owned = false;
39188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39189         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
39190 }
39191
39192 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_msat"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
39193         LDKScoringParameters this_ptr_conv;
39194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39195         this_ptr_conv.is_owned = false;
39196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39197         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
39198         return ret_val;
39199 }
39200
39201 void  __attribute__((export_name("TS_ScoringParameters_set_failure_penalty_msat"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
39202         LDKScoringParameters this_ptr_conv;
39203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39204         this_ptr_conv.is_owned = false;
39205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39206         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
39207 }
39208
39209 int16_t  __attribute__((export_name("TS_ScoringParameters_get_overuse_penalty_start_1024th"))) TS_ScoringParameters_get_overuse_penalty_start_1024th(uint32_t this_ptr) {
39210         LDKScoringParameters this_ptr_conv;
39211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39212         this_ptr_conv.is_owned = false;
39213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39214         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
39215         return ret_val;
39216 }
39217
39218 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) {
39219         LDKScoringParameters this_ptr_conv;
39220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39221         this_ptr_conv.is_owned = false;
39222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39223         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
39224 }
39225
39226 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) {
39227         LDKScoringParameters this_ptr_conv;
39228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39229         this_ptr_conv.is_owned = false;
39230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39231         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
39232         return ret_val;
39233 }
39234
39235 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) {
39236         LDKScoringParameters this_ptr_conv;
39237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39238         this_ptr_conv.is_owned = false;
39239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39240         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
39241 }
39242
39243 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_half_life"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
39244         LDKScoringParameters this_ptr_conv;
39245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39246         this_ptr_conv.is_owned = false;
39247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39248         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
39249         return ret_val;
39250 }
39251
39252 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) {
39253         LDKScoringParameters this_ptr_conv;
39254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39255         this_ptr_conv.is_owned = false;
39256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39257         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
39258 }
39259
39260 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) {
39261         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);
39262         uint32_t ret_ref = 0;
39263         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39264         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39266         ret_ref = (uintptr_t)ret_var.inner;
39267         if (ret_var.is_owned) {
39268                 ret_ref |= 1;
39269         }
39270         return ret_ref;
39271 }
39272
39273 static inline uintptr_t ScoringParameters_clone_ptr(LDKScoringParameters *NONNULL_PTR arg) {
39274         LDKScoringParameters ret_var = ScoringParameters_clone(arg);
39275 uint32_t ret_ref = 0;
39276 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39277 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39278 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39279 ret_ref = (uintptr_t)ret_var.inner;
39280 if (ret_var.is_owned) {
39281         ret_ref |= 1;
39282 }
39283         return ret_ref;
39284 }
39285 uint32_t  __attribute__((export_name("TS_ScoringParameters_clone_ptr"))) TS_ScoringParameters_clone_ptr(uint32_t arg) {
39286         LDKScoringParameters arg_conv;
39287         arg_conv.inner = (void*)(arg & (~1));
39288         arg_conv.is_owned = false;
39289         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39290         uint32_t ret_val = ScoringParameters_clone_ptr(&arg_conv);
39291         return ret_val;
39292 }
39293
39294 uint32_t  __attribute__((export_name("TS_ScoringParameters_clone"))) TS_ScoringParameters_clone(uint32_t orig) {
39295         LDKScoringParameters orig_conv;
39296         orig_conv.inner = (void*)(orig & (~1));
39297         orig_conv.is_owned = false;
39298         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39299         LDKScoringParameters ret_var = ScoringParameters_clone(&orig_conv);
39300         uint32_t ret_ref = 0;
39301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39304         ret_ref = (uintptr_t)ret_var.inner;
39305         if (ret_var.is_owned) {
39306                 ret_ref |= 1;
39307         }
39308         return ret_ref;
39309 }
39310
39311 int8_tArray  __attribute__((export_name("TS_ScoringParameters_write"))) TS_ScoringParameters_write(uint32_t obj) {
39312         LDKScoringParameters obj_conv;
39313         obj_conv.inner = (void*)(obj & (~1));
39314         obj_conv.is_owned = false;
39315         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39316         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
39317         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39318         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39319         CVec_u8Z_free(ret_var);
39320         return ret_arr;
39321 }
39322
39323 uint32_t  __attribute__((export_name("TS_ScoringParameters_read"))) TS_ScoringParameters_read(int8_tArray ser) {
39324         LDKu8slice ser_ref;
39325         ser_ref.datalen = ser->arr_len;
39326         ser_ref.data = ser->elems /* XXX ser leaks */;
39327         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
39328         *ret_conv = ScoringParameters_read(ser_ref);
39329         return (uint32_t)ret_conv;
39330 }
39331
39332 uint32_t  __attribute__((export_name("TS_Scorer_new"))) TS_Scorer_new(uint32_t params) {
39333         LDKScoringParameters params_conv;
39334         params_conv.inner = (void*)(params & (~1));
39335         params_conv.is_owned = (params & 1) || (params == 0);
39336         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
39337         params_conv = ScoringParameters_clone(&params_conv);
39338         LDKScorer ret_var = Scorer_new(params_conv);
39339         uint32_t ret_ref = 0;
39340         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39341         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39343         ret_ref = (uintptr_t)ret_var.inner;
39344         if (ret_var.is_owned) {
39345                 ret_ref |= 1;
39346         }
39347         return ret_ref;
39348 }
39349
39350 uint32_t  __attribute__((export_name("TS_Scorer_default"))) TS_Scorer_default() {
39351         LDKScorer ret_var = Scorer_default();
39352         uint32_t ret_ref = 0;
39353         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39354         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39356         ret_ref = (uintptr_t)ret_var.inner;
39357         if (ret_var.is_owned) {
39358                 ret_ref |= 1;
39359         }
39360         return ret_ref;
39361 }
39362
39363 uint32_t  __attribute__((export_name("TS_ScoringParameters_default"))) TS_ScoringParameters_default() {
39364         LDKScoringParameters ret_var = ScoringParameters_default();
39365         uint32_t ret_ref = 0;
39366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39369         ret_ref = (uintptr_t)ret_var.inner;
39370         if (ret_var.is_owned) {
39371                 ret_ref |= 1;
39372         }
39373         return ret_ref;
39374 }
39375
39376 uint32_t  __attribute__((export_name("TS_Scorer_as_Score"))) TS_Scorer_as_Score(uint32_t this_arg) {
39377         LDKScorer this_arg_conv;
39378         this_arg_conv.inner = (void*)(this_arg & (~1));
39379         this_arg_conv.is_owned = false;
39380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39381         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
39382         *ret_ret = Scorer_as_Score(&this_arg_conv);
39383         return (uint32_t)ret_ret;
39384 }
39385
39386 int8_tArray  __attribute__((export_name("TS_Scorer_write"))) TS_Scorer_write(uint32_t obj) {
39387         LDKScorer obj_conv;
39388         obj_conv.inner = (void*)(obj & (~1));
39389         obj_conv.is_owned = false;
39390         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39391         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
39392         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39393         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39394         CVec_u8Z_free(ret_var);
39395         return ret_arr;
39396 }
39397
39398 uint32_t  __attribute__((export_name("TS_Scorer_read"))) TS_Scorer_read(int8_tArray ser) {
39399         LDKu8slice ser_ref;
39400         ser_ref.datalen = ser->arr_len;
39401         ser_ref.data = ser->elems /* XXX ser leaks */;
39402         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
39403         *ret_conv = Scorer_read(ser_ref);
39404         return (uint32_t)ret_conv;
39405 }
39406
39407 void  __attribute__((export_name("TS_ProbabilisticScorer_free"))) TS_ProbabilisticScorer_free(uint32_t this_obj) {
39408         LDKProbabilisticScorer this_obj_conv;
39409         this_obj_conv.inner = (void*)(this_obj & (~1));
39410         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39412         ProbabilisticScorer_free(this_obj_conv);
39413 }
39414
39415 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint32_t this_obj) {
39416         LDKProbabilisticScoringParameters this_obj_conv;
39417         this_obj_conv.inner = (void*)(this_obj & (~1));
39418         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39420         ProbabilisticScoringParameters_free(this_obj_conv);
39421 }
39422
39423 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
39424         LDKProbabilisticScoringParameters this_ptr_conv;
39425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39426         this_ptr_conv.is_owned = false;
39427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39428         int64_t ret_val = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
39429         return ret_val;
39430 }
39431
39432 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
39433         LDKProbabilisticScoringParameters this_ptr_conv;
39434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39435         this_ptr_conv.is_owned = false;
39436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39437         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
39438 }
39439
39440 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint32_t this_ptr) {
39441         LDKProbabilisticScoringParameters this_ptr_conv;
39442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39443         this_ptr_conv.is_owned = false;
39444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39445         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
39446         return ret_val;
39447 }
39448
39449 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) {
39450         LDKProbabilisticScoringParameters this_ptr_conv;
39451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39452         this_ptr_conv.is_owned = false;
39453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39454         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
39455 }
39456
39457 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint32_t this_ptr) {
39458         LDKProbabilisticScoringParameters this_ptr_conv;
39459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39460         this_ptr_conv.is_owned = false;
39461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39462         int64_t ret_val = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
39463         return ret_val;
39464 }
39465
39466 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) {
39467         LDKProbabilisticScoringParameters this_ptr_conv;
39468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39469         this_ptr_conv.is_owned = false;
39470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39471         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
39472 }
39473
39474 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(uint32_t this_ptr) {
39475         LDKProbabilisticScoringParameters this_ptr_conv;
39476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39477         this_ptr_conv.is_owned = false;
39478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39479         int64_t ret_val = ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(&this_ptr_conv);
39480         return ret_val;
39481 }
39482
39483 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) {
39484         LDKProbabilisticScoringParameters this_ptr_conv;
39485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39486         this_ptr_conv.is_owned = false;
39487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39488         ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(&this_ptr_conv, val);
39489 }
39490
39491 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) {
39492         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(base_penalty_msat_arg, liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg, amount_penalty_multiplier_msat_arg);
39493         uint32_t ret_ref = 0;
39494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39497         ret_ref = (uintptr_t)ret_var.inner;
39498         if (ret_var.is_owned) {
39499                 ret_ref |= 1;
39500         }
39501         return ret_ref;
39502 }
39503
39504 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
39505         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
39506 uint32_t ret_ref = 0;
39507 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39508 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39509 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39510 ret_ref = (uintptr_t)ret_var.inner;
39511 if (ret_var.is_owned) {
39512         ret_ref |= 1;
39513 }
39514         return ret_ref;
39515 }
39516 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint32_t arg) {
39517         LDKProbabilisticScoringParameters arg_conv;
39518         arg_conv.inner = (void*)(arg & (~1));
39519         arg_conv.is_owned = false;
39520         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39521         uint32_t ret_val = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
39522         return ret_val;
39523 }
39524
39525 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint32_t orig) {
39526         LDKProbabilisticScoringParameters orig_conv;
39527         orig_conv.inner = (void*)(orig & (~1));
39528         orig_conv.is_owned = false;
39529         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39530         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
39531         uint32_t ret_ref = 0;
39532         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39533         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39535         ret_ref = (uintptr_t)ret_var.inner;
39536         if (ret_var.is_owned) {
39537                 ret_ref |= 1;
39538         }
39539         return ret_ref;
39540 }
39541
39542 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_new"))) TS_ProbabilisticScorer_new(uint32_t params, uint32_t network_graph) {
39543         LDKProbabilisticScoringParameters params_conv;
39544         params_conv.inner = (void*)(params & (~1));
39545         params_conv.is_owned = (params & 1) || (params == 0);
39546         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
39547         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
39548         LDKNetworkGraph network_graph_conv;
39549         network_graph_conv.inner = (void*)(network_graph & (~1));
39550         network_graph_conv.is_owned = false;
39551         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39552         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv);
39553         uint32_t ret_ref = 0;
39554         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39555         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39557         ret_ref = (uintptr_t)ret_var.inner;
39558         if (ret_var.is_owned) {
39559                 ret_ref |= 1;
39560         }
39561         return ret_ref;
39562 }
39563
39564 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
39565         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
39566         uint32_t ret_ref = 0;
39567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39570         ret_ref = (uintptr_t)ret_var.inner;
39571         if (ret_var.is_owned) {
39572                 ret_ref |= 1;
39573         }
39574         return ret_ref;
39575 }
39576
39577 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_as_Score"))) TS_ProbabilisticScorer_as_Score(uint32_t this_arg) {
39578         LDKProbabilisticScorer this_arg_conv;
39579         this_arg_conv.inner = (void*)(this_arg & (~1));
39580         this_arg_conv.is_owned = false;
39581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39582         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
39583         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
39584         return (uint32_t)ret_ret;
39585 }
39586
39587 int8_tArray  __attribute__((export_name("TS_ProbabilisticScorer_write"))) TS_ProbabilisticScorer_write(uint32_t obj) {
39588         LDKProbabilisticScorer obj_conv;
39589         obj_conv.inner = (void*)(obj & (~1));
39590         obj_conv.is_owned = false;
39591         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39592         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
39593         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39594         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39595         CVec_u8Z_free(ret_var);
39596         return ret_arr;
39597 }
39598
39599 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_read"))) TS_ProbabilisticScorer_read(int8_tArray ser, uint32_t arg_a, uint32_t arg_b) {
39600         LDKu8slice ser_ref;
39601         ser_ref.datalen = ser->arr_len;
39602         ser_ref.data = ser->elems /* XXX ser leaks */;
39603         LDKProbabilisticScoringParameters arg_a_conv;
39604         arg_a_conv.inner = (void*)(arg_a & (~1));
39605         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
39606         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
39607         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
39608         LDKNetworkGraph arg_b_conv;
39609         arg_b_conv.inner = (void*)(arg_b & (~1));
39610         arg_b_conv.is_owned = false;
39611         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
39612         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
39613         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv);
39614         return (uint32_t)ret_conv;
39615 }
39616
39617 void  __attribute__((export_name("TS_ParseError_free"))) TS_ParseError_free(uint32_t this_ptr) {
39618         if ((this_ptr & 1) != 0) return;
39619         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39620         CHECK_ACCESS(this_ptr_ptr);
39621         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
39622         FREE((void*)this_ptr);
39623         ParseError_free(this_ptr_conv);
39624 }
39625
39626 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
39627         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39628         *ret_copy = ParseError_clone(arg);
39629 uint32_t ret_ref = (uintptr_t)ret_copy;
39630         return ret_ref;
39631 }
39632 uint32_t  __attribute__((export_name("TS_ParseError_clone_ptr"))) TS_ParseError_clone_ptr(uint32_t arg) {
39633         LDKParseError* arg_conv = (LDKParseError*)arg;
39634         uint32_t ret_val = ParseError_clone_ptr(arg_conv);
39635         return ret_val;
39636 }
39637
39638 uint32_t  __attribute__((export_name("TS_ParseError_clone"))) TS_ParseError_clone(uint32_t orig) {
39639         LDKParseError* orig_conv = (LDKParseError*)orig;
39640         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39641         *ret_copy = ParseError_clone(orig_conv);
39642         uint32_t ret_ref = (uintptr_t)ret_copy;
39643         return ret_ref;
39644 }
39645
39646 uint32_t  __attribute__((export_name("TS_ParseError_bech32_error"))) TS_ParseError_bech32_error(uint32_t a) {
39647         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
39648         CHECK_ACCESS(a_ptr);
39649         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
39650         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
39651         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39652         *ret_copy = ParseError_bech32_error(a_conv);
39653         uint32_t ret_ref = (uintptr_t)ret_copy;
39654         return ret_ref;
39655 }
39656
39657 uint32_t  __attribute__((export_name("TS_ParseError_parse_amount_error"))) TS_ParseError_parse_amount_error(int32_t a) {
39658         
39659         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39660         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
39661         uint32_t ret_ref = (uintptr_t)ret_copy;
39662         return ret_ref;
39663 }
39664
39665 uint32_t  __attribute__((export_name("TS_ParseError_malformed_signature"))) TS_ParseError_malformed_signature(uint32_t a) {
39666         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_js(a);
39667         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39668         *ret_copy = ParseError_malformed_signature(a_conv);
39669         uint32_t ret_ref = (uintptr_t)ret_copy;
39670         return ret_ref;
39671 }
39672
39673 uint32_t  __attribute__((export_name("TS_ParseError_bad_prefix"))) TS_ParseError_bad_prefix() {
39674         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39675         *ret_copy = ParseError_bad_prefix();
39676         uint32_t ret_ref = (uintptr_t)ret_copy;
39677         return ret_ref;
39678 }
39679
39680 uint32_t  __attribute__((export_name("TS_ParseError_unknown_currency"))) TS_ParseError_unknown_currency() {
39681         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39682         *ret_copy = ParseError_unknown_currency();
39683         uint32_t ret_ref = (uintptr_t)ret_copy;
39684         return ret_ref;
39685 }
39686
39687 uint32_t  __attribute__((export_name("TS_ParseError_unknown_si_prefix"))) TS_ParseError_unknown_si_prefix() {
39688         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39689         *ret_copy = ParseError_unknown_si_prefix();
39690         uint32_t ret_ref = (uintptr_t)ret_copy;
39691         return ret_ref;
39692 }
39693
39694 uint32_t  __attribute__((export_name("TS_ParseError_malformed_hrp"))) TS_ParseError_malformed_hrp() {
39695         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39696         *ret_copy = ParseError_malformed_hrp();
39697         uint32_t ret_ref = (uintptr_t)ret_copy;
39698         return ret_ref;
39699 }
39700
39701 uint32_t  __attribute__((export_name("TS_ParseError_too_short_data_part"))) TS_ParseError_too_short_data_part() {
39702         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39703         *ret_copy = ParseError_too_short_data_part();
39704         uint32_t ret_ref = (uintptr_t)ret_copy;
39705         return ret_ref;
39706 }
39707
39708 uint32_t  __attribute__((export_name("TS_ParseError_unexpected_end_of_tagged_fields"))) TS_ParseError_unexpected_end_of_tagged_fields() {
39709         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39710         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
39711         uint32_t ret_ref = (uintptr_t)ret_copy;
39712         return ret_ref;
39713 }
39714
39715 uint32_t  __attribute__((export_name("TS_ParseError_description_decode_error"))) TS_ParseError_description_decode_error(int32_t a) {
39716         
39717         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39718         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
39719         uint32_t ret_ref = (uintptr_t)ret_copy;
39720         return ret_ref;
39721 }
39722
39723 uint32_t  __attribute__((export_name("TS_ParseError_padding_error"))) TS_ParseError_padding_error() {
39724         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39725         *ret_copy = ParseError_padding_error();
39726         uint32_t ret_ref = (uintptr_t)ret_copy;
39727         return ret_ref;
39728 }
39729
39730 uint32_t  __attribute__((export_name("TS_ParseError_integer_overflow_error"))) TS_ParseError_integer_overflow_error() {
39731         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39732         *ret_copy = ParseError_integer_overflow_error();
39733         uint32_t ret_ref = (uintptr_t)ret_copy;
39734         return ret_ref;
39735 }
39736
39737 uint32_t  __attribute__((export_name("TS_ParseError_invalid_seg_wit_program_length"))) TS_ParseError_invalid_seg_wit_program_length() {
39738         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39739         *ret_copy = ParseError_invalid_seg_wit_program_length();
39740         uint32_t ret_ref = (uintptr_t)ret_copy;
39741         return ret_ref;
39742 }
39743
39744 uint32_t  __attribute__((export_name("TS_ParseError_invalid_pub_key_hash_length"))) TS_ParseError_invalid_pub_key_hash_length() {
39745         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39746         *ret_copy = ParseError_invalid_pub_key_hash_length();
39747         uint32_t ret_ref = (uintptr_t)ret_copy;
39748         return ret_ref;
39749 }
39750
39751 uint32_t  __attribute__((export_name("TS_ParseError_invalid_script_hash_length"))) TS_ParseError_invalid_script_hash_length() {
39752         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39753         *ret_copy = ParseError_invalid_script_hash_length();
39754         uint32_t ret_ref = (uintptr_t)ret_copy;
39755         return ret_ref;
39756 }
39757
39758 uint32_t  __attribute__((export_name("TS_ParseError_invalid_recovery_id"))) TS_ParseError_invalid_recovery_id() {
39759         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39760         *ret_copy = ParseError_invalid_recovery_id();
39761         uint32_t ret_ref = (uintptr_t)ret_copy;
39762         return ret_ref;
39763 }
39764
39765 uint32_t  __attribute__((export_name("TS_ParseError_invalid_slice_length"))) TS_ParseError_invalid_slice_length(jstring a) {
39766         LDKStr a_conv = str_ref_to_owned_c(a);
39767         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39768         *ret_copy = ParseError_invalid_slice_length(a_conv);
39769         uint32_t ret_ref = (uintptr_t)ret_copy;
39770         return ret_ref;
39771 }
39772
39773 uint32_t  __attribute__((export_name("TS_ParseError_skip"))) TS_ParseError_skip() {
39774         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39775         *ret_copy = ParseError_skip();
39776         uint32_t ret_ref = (uintptr_t)ret_copy;
39777         return ret_ref;
39778 }
39779
39780 void  __attribute__((export_name("TS_ParseOrSemanticError_free"))) TS_ParseOrSemanticError_free(uint32_t this_ptr) {
39781         if ((this_ptr & 1) != 0) return;
39782         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39783         CHECK_ACCESS(this_ptr_ptr);
39784         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
39785         FREE((void*)this_ptr);
39786         ParseOrSemanticError_free(this_ptr_conv);
39787 }
39788
39789 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
39790         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39791         *ret_copy = ParseOrSemanticError_clone(arg);
39792 uint32_t ret_ref = (uintptr_t)ret_copy;
39793         return ret_ref;
39794 }
39795 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone_ptr"))) TS_ParseOrSemanticError_clone_ptr(uint32_t arg) {
39796         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
39797         uint32_t ret_val = ParseOrSemanticError_clone_ptr(arg_conv);
39798         return ret_val;
39799 }
39800
39801 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone"))) TS_ParseOrSemanticError_clone(uint32_t orig) {
39802         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
39803         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39804         *ret_copy = ParseOrSemanticError_clone(orig_conv);
39805         uint32_t ret_ref = (uintptr_t)ret_copy;
39806         return ret_ref;
39807 }
39808
39809 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_parse_error"))) TS_ParseOrSemanticError_parse_error(uint32_t a) {
39810         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
39811         CHECK_ACCESS(a_ptr);
39812         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
39813         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
39814         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39815         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
39816         uint32_t ret_ref = (uintptr_t)ret_copy;
39817         return ret_ref;
39818 }
39819
39820 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_semantic_error"))) TS_ParseOrSemanticError_semantic_error(uint32_t a) {
39821         LDKSemanticError a_conv = LDKSemanticError_from_js(a);
39822         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39823         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
39824         uint32_t ret_ref = (uintptr_t)ret_copy;
39825         return ret_ref;
39826 }
39827
39828 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint32_t this_obj) {
39829         LDKInvoice this_obj_conv;
39830         this_obj_conv.inner = (void*)(this_obj & (~1));
39831         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39833         Invoice_free(this_obj_conv);
39834 }
39835
39836 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
39837         LDKInvoice a_conv;
39838         a_conv.inner = (void*)(a & (~1));
39839         a_conv.is_owned = false;
39840         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39841         LDKInvoice b_conv;
39842         b_conv.inner = (void*)(b & (~1));
39843         b_conv.is_owned = false;
39844         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39845         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
39846         return ret_val;
39847 }
39848
39849 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
39850         LDKInvoice ret_var = Invoice_clone(arg);
39851 uint32_t ret_ref = 0;
39852 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39853 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39854 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39855 ret_ref = (uintptr_t)ret_var.inner;
39856 if (ret_var.is_owned) {
39857         ret_ref |= 1;
39858 }
39859         return ret_ref;
39860 }
39861 uint32_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint32_t arg) {
39862         LDKInvoice arg_conv;
39863         arg_conv.inner = (void*)(arg & (~1));
39864         arg_conv.is_owned = false;
39865         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39866         uint32_t ret_val = Invoice_clone_ptr(&arg_conv);
39867         return ret_val;
39868 }
39869
39870 uint32_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint32_t orig) {
39871         LDKInvoice orig_conv;
39872         orig_conv.inner = (void*)(orig & (~1));
39873         orig_conv.is_owned = false;
39874         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39875         LDKInvoice ret_var = Invoice_clone(&orig_conv);
39876         uint32_t ret_ref = 0;
39877         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39878         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39880         ret_ref = (uintptr_t)ret_var.inner;
39881         if (ret_var.is_owned) {
39882                 ret_ref |= 1;
39883         }
39884         return ret_ref;
39885 }
39886
39887 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
39888         LDKSignedRawInvoice this_obj_conv;
39889         this_obj_conv.inner = (void*)(this_obj & (~1));
39890         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39892         SignedRawInvoice_free(this_obj_conv);
39893 }
39894
39895 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
39896         LDKSignedRawInvoice a_conv;
39897         a_conv.inner = (void*)(a & (~1));
39898         a_conv.is_owned = false;
39899         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39900         LDKSignedRawInvoice b_conv;
39901         b_conv.inner = (void*)(b & (~1));
39902         b_conv.is_owned = false;
39903         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39904         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
39905         return ret_val;
39906 }
39907
39908 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
39909         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
39910 uint32_t ret_ref = 0;
39911 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39912 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39913 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39914 ret_ref = (uintptr_t)ret_var.inner;
39915 if (ret_var.is_owned) {
39916         ret_ref |= 1;
39917 }
39918         return ret_ref;
39919 }
39920 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
39921         LDKSignedRawInvoice arg_conv;
39922         arg_conv.inner = (void*)(arg & (~1));
39923         arg_conv.is_owned = false;
39924         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39925         uint32_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
39926         return ret_val;
39927 }
39928
39929 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint32_t orig) {
39930         LDKSignedRawInvoice orig_conv;
39931         orig_conv.inner = (void*)(orig & (~1));
39932         orig_conv.is_owned = false;
39933         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39934         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
39935         uint32_t ret_ref = 0;
39936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39939         ret_ref = (uintptr_t)ret_var.inner;
39940         if (ret_var.is_owned) {
39941                 ret_ref |= 1;
39942         }
39943         return ret_ref;
39944 }
39945
39946 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint32_t this_obj) {
39947         LDKRawInvoice this_obj_conv;
39948         this_obj_conv.inner = (void*)(this_obj & (~1));
39949         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39951         RawInvoice_free(this_obj_conv);
39952 }
39953
39954 uint32_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
39955         LDKRawInvoice this_ptr_conv;
39956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39957         this_ptr_conv.is_owned = false;
39958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39959         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
39960         uint32_t ret_ref = 0;
39961         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39962         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39964         ret_ref = (uintptr_t)ret_var.inner;
39965         if (ret_var.is_owned) {
39966                 ret_ref |= 1;
39967         }
39968         return ret_ref;
39969 }
39970
39971 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
39972         LDKRawInvoice this_ptr_conv;
39973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39974         this_ptr_conv.is_owned = false;
39975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39976         LDKRawDataPart val_conv;
39977         val_conv.inner = (void*)(val & (~1));
39978         val_conv.is_owned = (val & 1) || (val == 0);
39979         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39980         val_conv = RawDataPart_clone(&val_conv);
39981         RawInvoice_set_data(&this_ptr_conv, val_conv);
39982 }
39983
39984 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
39985         LDKRawInvoice a_conv;
39986         a_conv.inner = (void*)(a & (~1));
39987         a_conv.is_owned = false;
39988         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39989         LDKRawInvoice b_conv;
39990         b_conv.inner = (void*)(b & (~1));
39991         b_conv.is_owned = false;
39992         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39993         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
39994         return ret_val;
39995 }
39996
39997 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
39998         LDKRawInvoice ret_var = RawInvoice_clone(arg);
39999 uint32_t ret_ref = 0;
40000 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40001 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40002 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40003 ret_ref = (uintptr_t)ret_var.inner;
40004 if (ret_var.is_owned) {
40005         ret_ref |= 1;
40006 }
40007         return ret_ref;
40008 }
40009 uint32_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
40010         LDKRawInvoice arg_conv;
40011         arg_conv.inner = (void*)(arg & (~1));
40012         arg_conv.is_owned = false;
40013         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40014         uint32_t ret_val = RawInvoice_clone_ptr(&arg_conv);
40015         return ret_val;
40016 }
40017
40018 uint32_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint32_t orig) {
40019         LDKRawInvoice orig_conv;
40020         orig_conv.inner = (void*)(orig & (~1));
40021         orig_conv.is_owned = false;
40022         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40023         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
40024         uint32_t ret_ref = 0;
40025         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40026         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40028         ret_ref = (uintptr_t)ret_var.inner;
40029         if (ret_var.is_owned) {
40030                 ret_ref |= 1;
40031         }
40032         return ret_ref;
40033 }
40034
40035 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint32_t this_obj) {
40036         LDKRawDataPart this_obj_conv;
40037         this_obj_conv.inner = (void*)(this_obj & (~1));
40038         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40040         RawDataPart_free(this_obj_conv);
40041 }
40042
40043 uint32_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
40044         LDKRawDataPart this_ptr_conv;
40045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40046         this_ptr_conv.is_owned = false;
40047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40048         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
40049         uint32_t ret_ref = 0;
40050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40053         ret_ref = (uintptr_t)ret_var.inner;
40054         if (ret_var.is_owned) {
40055                 ret_ref |= 1;
40056         }
40057         return ret_ref;
40058 }
40059
40060 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
40061         LDKRawDataPart this_ptr_conv;
40062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40063         this_ptr_conv.is_owned = false;
40064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40065         LDKPositiveTimestamp val_conv;
40066         val_conv.inner = (void*)(val & (~1));
40067         val_conv.is_owned = (val & 1) || (val == 0);
40068         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40069         val_conv = PositiveTimestamp_clone(&val_conv);
40070         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
40071 }
40072
40073 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
40074         LDKRawDataPart a_conv;
40075         a_conv.inner = (void*)(a & (~1));
40076         a_conv.is_owned = false;
40077         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40078         LDKRawDataPart b_conv;
40079         b_conv.inner = (void*)(b & (~1));
40080         b_conv.is_owned = false;
40081         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40082         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
40083         return ret_val;
40084 }
40085
40086 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
40087         LDKRawDataPart ret_var = RawDataPart_clone(arg);
40088 uint32_t ret_ref = 0;
40089 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40090 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40091 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40092 ret_ref = (uintptr_t)ret_var.inner;
40093 if (ret_var.is_owned) {
40094         ret_ref |= 1;
40095 }
40096         return ret_ref;
40097 }
40098 uint32_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
40099         LDKRawDataPart arg_conv;
40100         arg_conv.inner = (void*)(arg & (~1));
40101         arg_conv.is_owned = false;
40102         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40103         uint32_t ret_val = RawDataPart_clone_ptr(&arg_conv);
40104         return ret_val;
40105 }
40106
40107 uint32_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint32_t orig) {
40108         LDKRawDataPart orig_conv;
40109         orig_conv.inner = (void*)(orig & (~1));
40110         orig_conv.is_owned = false;
40111         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40112         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
40113         uint32_t ret_ref = 0;
40114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40117         ret_ref = (uintptr_t)ret_var.inner;
40118         if (ret_var.is_owned) {
40119                 ret_ref |= 1;
40120         }
40121         return ret_ref;
40122 }
40123
40124 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
40125         LDKPositiveTimestamp this_obj_conv;
40126         this_obj_conv.inner = (void*)(this_obj & (~1));
40127         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40129         PositiveTimestamp_free(this_obj_conv);
40130 }
40131
40132 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
40133         LDKPositiveTimestamp a_conv;
40134         a_conv.inner = (void*)(a & (~1));
40135         a_conv.is_owned = false;
40136         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40137         LDKPositiveTimestamp b_conv;
40138         b_conv.inner = (void*)(b & (~1));
40139         b_conv.is_owned = false;
40140         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40141         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
40142         return ret_val;
40143 }
40144
40145 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
40146         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
40147 uint32_t ret_ref = 0;
40148 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40149 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40150 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40151 ret_ref = (uintptr_t)ret_var.inner;
40152 if (ret_var.is_owned) {
40153         ret_ref |= 1;
40154 }
40155         return ret_ref;
40156 }
40157 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
40158         LDKPositiveTimestamp arg_conv;
40159         arg_conv.inner = (void*)(arg & (~1));
40160         arg_conv.is_owned = false;
40161         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40162         uint32_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
40163         return ret_val;
40164 }
40165
40166 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint32_t orig) {
40167         LDKPositiveTimestamp orig_conv;
40168         orig_conv.inner = (void*)(orig & (~1));
40169         orig_conv.is_owned = false;
40170         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40171         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
40172         uint32_t ret_ref = 0;
40173         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40174         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40176         ret_ref = (uintptr_t)ret_var.inner;
40177         if (ret_var.is_owned) {
40178                 ret_ref |= 1;
40179         }
40180         return ret_ref;
40181 }
40182
40183 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint32_t orig) {
40184         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
40185         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
40186         return ret_conv;
40187 }
40188
40189 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
40190         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
40191         return ret_conv;
40192 }
40193
40194 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
40195         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
40196         return ret_conv;
40197 }
40198
40199 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
40200         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
40201         return ret_conv;
40202 }
40203
40204 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
40205         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
40206         return ret_conv;
40207 }
40208
40209 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
40210         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
40211         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
40212         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
40213         return ret_val;
40214 }
40215
40216 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
40217         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
40218         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
40219         return ret_val;
40220 }
40221
40222 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint32_t orig) {
40223         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
40224         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
40225         return ret_conv;
40226 }
40227
40228 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
40229         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
40230         return ret_conv;
40231 }
40232
40233 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
40234         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
40235         return ret_conv;
40236 }
40237
40238 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
40239         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
40240         return ret_conv;
40241 }
40242
40243 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
40244         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
40245         return ret_conv;
40246 }
40247
40248 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
40249         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
40250         return ret_conv;
40251 }
40252
40253 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint32_t o) {
40254         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
40255         int64_t ret_val = Currency_hash(o_conv);
40256         return ret_val;
40257 }
40258
40259 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint32_t a, uint32_t b) {
40260         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
40261         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
40262         jboolean ret_val = Currency_eq(a_conv, b_conv);
40263         return ret_val;
40264 }
40265
40266 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint32_t this_obj) {
40267         LDKSha256 this_obj_conv;
40268         this_obj_conv.inner = (void*)(this_obj & (~1));
40269         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40271         Sha256_free(this_obj_conv);
40272 }
40273
40274 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
40275         LDKSha256 ret_var = Sha256_clone(arg);
40276 uint32_t ret_ref = 0;
40277 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40278 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40279 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40280 ret_ref = (uintptr_t)ret_var.inner;
40281 if (ret_var.is_owned) {
40282         ret_ref |= 1;
40283 }
40284         return ret_ref;
40285 }
40286 uint32_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint32_t arg) {
40287         LDKSha256 arg_conv;
40288         arg_conv.inner = (void*)(arg & (~1));
40289         arg_conv.is_owned = false;
40290         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40291         uint32_t ret_val = Sha256_clone_ptr(&arg_conv);
40292         return ret_val;
40293 }
40294
40295 uint32_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint32_t orig) {
40296         LDKSha256 orig_conv;
40297         orig_conv.inner = (void*)(orig & (~1));
40298         orig_conv.is_owned = false;
40299         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40300         LDKSha256 ret_var = Sha256_clone(&orig_conv);
40301         uint32_t ret_ref = 0;
40302         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40303         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40305         ret_ref = (uintptr_t)ret_var.inner;
40306         if (ret_var.is_owned) {
40307                 ret_ref |= 1;
40308         }
40309         return ret_ref;
40310 }
40311
40312 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint32_t o) {
40313         LDKSha256 o_conv;
40314         o_conv.inner = (void*)(o & (~1));
40315         o_conv.is_owned = false;
40316         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40317         int64_t ret_val = Sha256_hash(&o_conv);
40318         return ret_val;
40319 }
40320
40321 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
40322         LDKSha256 a_conv;
40323         a_conv.inner = (void*)(a & (~1));
40324         a_conv.is_owned = false;
40325         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40326         LDKSha256 b_conv;
40327         b_conv.inner = (void*)(b & (~1));
40328         b_conv.is_owned = false;
40329         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40330         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
40331         return ret_val;
40332 }
40333
40334 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint32_t this_obj) {
40335         LDKDescription this_obj_conv;
40336         this_obj_conv.inner = (void*)(this_obj & (~1));
40337         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40339         Description_free(this_obj_conv);
40340 }
40341
40342 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
40343         LDKDescription ret_var = Description_clone(arg);
40344 uint32_t ret_ref = 0;
40345 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40346 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40347 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40348 ret_ref = (uintptr_t)ret_var.inner;
40349 if (ret_var.is_owned) {
40350         ret_ref |= 1;
40351 }
40352         return ret_ref;
40353 }
40354 uint32_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint32_t arg) {
40355         LDKDescription arg_conv;
40356         arg_conv.inner = (void*)(arg & (~1));
40357         arg_conv.is_owned = false;
40358         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40359         uint32_t ret_val = Description_clone_ptr(&arg_conv);
40360         return ret_val;
40361 }
40362
40363 uint32_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint32_t orig) {
40364         LDKDescription orig_conv;
40365         orig_conv.inner = (void*)(orig & (~1));
40366         orig_conv.is_owned = false;
40367         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40368         LDKDescription ret_var = Description_clone(&orig_conv);
40369         uint32_t ret_ref = 0;
40370         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40371         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40373         ret_ref = (uintptr_t)ret_var.inner;
40374         if (ret_var.is_owned) {
40375                 ret_ref |= 1;
40376         }
40377         return ret_ref;
40378 }
40379
40380 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint32_t o) {
40381         LDKDescription o_conv;
40382         o_conv.inner = (void*)(o & (~1));
40383         o_conv.is_owned = false;
40384         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40385         int64_t ret_val = Description_hash(&o_conv);
40386         return ret_val;
40387 }
40388
40389 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint32_t a, uint32_t b) {
40390         LDKDescription a_conv;
40391         a_conv.inner = (void*)(a & (~1));
40392         a_conv.is_owned = false;
40393         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40394         LDKDescription b_conv;
40395         b_conv.inner = (void*)(b & (~1));
40396         b_conv.is_owned = false;
40397         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40398         jboolean ret_val = Description_eq(&a_conv, &b_conv);
40399         return ret_val;
40400 }
40401
40402 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint32_t this_obj) {
40403         LDKPayeePubKey this_obj_conv;
40404         this_obj_conv.inner = (void*)(this_obj & (~1));
40405         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40407         PayeePubKey_free(this_obj_conv);
40408 }
40409
40410 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
40411         LDKPayeePubKey this_ptr_conv;
40412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40413         this_ptr_conv.is_owned = false;
40414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40415         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40416         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
40417         return ret_arr;
40418 }
40419
40420 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
40421         LDKPayeePubKey this_ptr_conv;
40422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40423         this_ptr_conv.is_owned = false;
40424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40425         LDKPublicKey val_ref;
40426         CHECK(val->arr_len == 33);
40427         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
40428         PayeePubKey_set_a(&this_ptr_conv, val_ref);
40429 }
40430
40431 uint32_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
40432         LDKPublicKey a_arg_ref;
40433         CHECK(a_arg->arr_len == 33);
40434         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
40435         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
40436         uint32_t ret_ref = 0;
40437         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40438         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40440         ret_ref = (uintptr_t)ret_var.inner;
40441         if (ret_var.is_owned) {
40442                 ret_ref |= 1;
40443         }
40444         return ret_ref;
40445 }
40446
40447 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
40448         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
40449 uint32_t ret_ref = 0;
40450 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40451 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40452 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40453 ret_ref = (uintptr_t)ret_var.inner;
40454 if (ret_var.is_owned) {
40455         ret_ref |= 1;
40456 }
40457         return ret_ref;
40458 }
40459 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
40460         LDKPayeePubKey arg_conv;
40461         arg_conv.inner = (void*)(arg & (~1));
40462         arg_conv.is_owned = false;
40463         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40464         uint32_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
40465         return ret_val;
40466 }
40467
40468 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint32_t orig) {
40469         LDKPayeePubKey orig_conv;
40470         orig_conv.inner = (void*)(orig & (~1));
40471         orig_conv.is_owned = false;
40472         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40473         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
40474         uint32_t ret_ref = 0;
40475         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40476         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40478         ret_ref = (uintptr_t)ret_var.inner;
40479         if (ret_var.is_owned) {
40480                 ret_ref |= 1;
40481         }
40482         return ret_ref;
40483 }
40484
40485 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint32_t o) {
40486         LDKPayeePubKey o_conv;
40487         o_conv.inner = (void*)(o & (~1));
40488         o_conv.is_owned = false;
40489         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40490         int64_t ret_val = PayeePubKey_hash(&o_conv);
40491         return ret_val;
40492 }
40493
40494 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
40495         LDKPayeePubKey a_conv;
40496         a_conv.inner = (void*)(a & (~1));
40497         a_conv.is_owned = false;
40498         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40499         LDKPayeePubKey b_conv;
40500         b_conv.inner = (void*)(b & (~1));
40501         b_conv.is_owned = false;
40502         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40503         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
40504         return ret_val;
40505 }
40506
40507 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint32_t this_obj) {
40508         LDKExpiryTime this_obj_conv;
40509         this_obj_conv.inner = (void*)(this_obj & (~1));
40510         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40512         ExpiryTime_free(this_obj_conv);
40513 }
40514
40515 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
40516         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
40517 uint32_t ret_ref = 0;
40518 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40519 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40520 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40521 ret_ref = (uintptr_t)ret_var.inner;
40522 if (ret_var.is_owned) {
40523         ret_ref |= 1;
40524 }
40525         return ret_ref;
40526 }
40527 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
40528         LDKExpiryTime arg_conv;
40529         arg_conv.inner = (void*)(arg & (~1));
40530         arg_conv.is_owned = false;
40531         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40532         uint32_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
40533         return ret_val;
40534 }
40535
40536 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint32_t orig) {
40537         LDKExpiryTime orig_conv;
40538         orig_conv.inner = (void*)(orig & (~1));
40539         orig_conv.is_owned = false;
40540         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40541         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
40542         uint32_t ret_ref = 0;
40543         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40544         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40546         ret_ref = (uintptr_t)ret_var.inner;
40547         if (ret_var.is_owned) {
40548                 ret_ref |= 1;
40549         }
40550         return ret_ref;
40551 }
40552
40553 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint32_t o) {
40554         LDKExpiryTime o_conv;
40555         o_conv.inner = (void*)(o & (~1));
40556         o_conv.is_owned = false;
40557         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40558         int64_t ret_val = ExpiryTime_hash(&o_conv);
40559         return ret_val;
40560 }
40561
40562 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
40563         LDKExpiryTime a_conv;
40564         a_conv.inner = (void*)(a & (~1));
40565         a_conv.is_owned = false;
40566         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40567         LDKExpiryTime b_conv;
40568         b_conv.inner = (void*)(b & (~1));
40569         b_conv.is_owned = false;
40570         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40571         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
40572         return ret_val;
40573 }
40574
40575 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
40576         LDKMinFinalCltvExpiry this_obj_conv;
40577         this_obj_conv.inner = (void*)(this_obj & (~1));
40578         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40580         MinFinalCltvExpiry_free(this_obj_conv);
40581 }
40582
40583 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
40584         LDKMinFinalCltvExpiry this_ptr_conv;
40585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40586         this_ptr_conv.is_owned = false;
40587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40588         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
40589         return ret_val;
40590 }
40591
40592 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
40593         LDKMinFinalCltvExpiry this_ptr_conv;
40594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40595         this_ptr_conv.is_owned = false;
40596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40597         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
40598 }
40599
40600 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
40601         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
40602         uint32_t ret_ref = 0;
40603         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40604         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40605         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40606         ret_ref = (uintptr_t)ret_var.inner;
40607         if (ret_var.is_owned) {
40608                 ret_ref |= 1;
40609         }
40610         return ret_ref;
40611 }
40612
40613 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
40614         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
40615 uint32_t ret_ref = 0;
40616 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40617 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40618 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40619 ret_ref = (uintptr_t)ret_var.inner;
40620 if (ret_var.is_owned) {
40621         ret_ref |= 1;
40622 }
40623         return ret_ref;
40624 }
40625 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
40626         LDKMinFinalCltvExpiry arg_conv;
40627         arg_conv.inner = (void*)(arg & (~1));
40628         arg_conv.is_owned = false;
40629         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40630         uint32_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
40631         return ret_val;
40632 }
40633
40634 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
40635         LDKMinFinalCltvExpiry orig_conv;
40636         orig_conv.inner = (void*)(orig & (~1));
40637         orig_conv.is_owned = false;
40638         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40639         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
40640         uint32_t ret_ref = 0;
40641         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40642         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40644         ret_ref = (uintptr_t)ret_var.inner;
40645         if (ret_var.is_owned) {
40646                 ret_ref |= 1;
40647         }
40648         return ret_ref;
40649 }
40650
40651 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
40652         LDKMinFinalCltvExpiry o_conv;
40653         o_conv.inner = (void*)(o & (~1));
40654         o_conv.is_owned = false;
40655         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40656         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
40657         return ret_val;
40658 }
40659
40660 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
40661         LDKMinFinalCltvExpiry a_conv;
40662         a_conv.inner = (void*)(a & (~1));
40663         a_conv.is_owned = false;
40664         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40665         LDKMinFinalCltvExpiry b_conv;
40666         b_conv.inner = (void*)(b & (~1));
40667         b_conv.is_owned = false;
40668         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40669         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
40670         return ret_val;
40671 }
40672
40673 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint32_t this_ptr) {
40674         if ((this_ptr & 1) != 0) return;
40675         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40676         CHECK_ACCESS(this_ptr_ptr);
40677         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
40678         FREE((void*)this_ptr);
40679         Fallback_free(this_ptr_conv);
40680 }
40681
40682 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
40683         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40684         *ret_copy = Fallback_clone(arg);
40685 uint32_t ret_ref = (uintptr_t)ret_copy;
40686         return ret_ref;
40687 }
40688 uint32_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint32_t arg) {
40689         LDKFallback* arg_conv = (LDKFallback*)arg;
40690         uint32_t ret_val = Fallback_clone_ptr(arg_conv);
40691         return ret_val;
40692 }
40693
40694 uint32_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint32_t orig) {
40695         LDKFallback* orig_conv = (LDKFallback*)orig;
40696         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40697         *ret_copy = Fallback_clone(orig_conv);
40698         uint32_t ret_ref = (uintptr_t)ret_copy;
40699         return ret_ref;
40700 }
40701
40702 uint32_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
40703         
40704         LDKCVec_u8Z program_ref;
40705         program_ref.datalen = program->arr_len;
40706         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
40707         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
40708         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40709         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
40710         uint32_t ret_ref = (uintptr_t)ret_copy;
40711         return ret_ref;
40712 }
40713
40714 uint32_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
40715         LDKTwentyBytes a_ref;
40716         CHECK(a->arr_len == 20);
40717         memcpy(a_ref.data, a->elems, 20); FREE(a);
40718         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40719         *ret_copy = Fallback_pub_key_hash(a_ref);
40720         uint32_t ret_ref = (uintptr_t)ret_copy;
40721         return ret_ref;
40722 }
40723
40724 uint32_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
40725         LDKTwentyBytes a_ref;
40726         CHECK(a->arr_len == 20);
40727         memcpy(a_ref.data, a->elems, 20); FREE(a);
40728         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40729         *ret_copy = Fallback_script_hash(a_ref);
40730         uint32_t ret_ref = (uintptr_t)ret_copy;
40731         return ret_ref;
40732 }
40733
40734 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint32_t o) {
40735         LDKFallback* o_conv = (LDKFallback*)o;
40736         int64_t ret_val = Fallback_hash(o_conv);
40737         return ret_val;
40738 }
40739
40740 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
40741         LDKFallback* a_conv = (LDKFallback*)a;
40742         LDKFallback* b_conv = (LDKFallback*)b;
40743         jboolean ret_val = Fallback_eq(a_conv, b_conv);
40744         return ret_val;
40745 }
40746
40747 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint32_t this_obj) {
40748         LDKInvoiceSignature this_obj_conv;
40749         this_obj_conv.inner = (void*)(this_obj & (~1));
40750         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40752         InvoiceSignature_free(this_obj_conv);
40753 }
40754
40755 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
40756         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
40757 uint32_t ret_ref = 0;
40758 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40759 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40760 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40761 ret_ref = (uintptr_t)ret_var.inner;
40762 if (ret_var.is_owned) {
40763         ret_ref |= 1;
40764 }
40765         return ret_ref;
40766 }
40767 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
40768         LDKInvoiceSignature arg_conv;
40769         arg_conv.inner = (void*)(arg & (~1));
40770         arg_conv.is_owned = false;
40771         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40772         uint32_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
40773         return ret_val;
40774 }
40775
40776 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint32_t orig) {
40777         LDKInvoiceSignature orig_conv;
40778         orig_conv.inner = (void*)(orig & (~1));
40779         orig_conv.is_owned = false;
40780         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40781         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
40782         uint32_t ret_ref = 0;
40783         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40784         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40786         ret_ref = (uintptr_t)ret_var.inner;
40787         if (ret_var.is_owned) {
40788                 ret_ref |= 1;
40789         }
40790         return ret_ref;
40791 }
40792
40793 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
40794         LDKInvoiceSignature a_conv;
40795         a_conv.inner = (void*)(a & (~1));
40796         a_conv.is_owned = false;
40797         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40798         LDKInvoiceSignature b_conv;
40799         b_conv.inner = (void*)(b & (~1));
40800         b_conv.is_owned = false;
40801         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40802         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
40803         return ret_val;
40804 }
40805
40806 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint32_t this_obj) {
40807         LDKPrivateRoute this_obj_conv;
40808         this_obj_conv.inner = (void*)(this_obj & (~1));
40809         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40811         PrivateRoute_free(this_obj_conv);
40812 }
40813
40814 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
40815         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
40816 uint32_t ret_ref = 0;
40817 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40818 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40819 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40820 ret_ref = (uintptr_t)ret_var.inner;
40821 if (ret_var.is_owned) {
40822         ret_ref |= 1;
40823 }
40824         return ret_ref;
40825 }
40826 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
40827         LDKPrivateRoute arg_conv;
40828         arg_conv.inner = (void*)(arg & (~1));
40829         arg_conv.is_owned = false;
40830         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40831         uint32_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
40832         return ret_val;
40833 }
40834
40835 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint32_t orig) {
40836         LDKPrivateRoute orig_conv;
40837         orig_conv.inner = (void*)(orig & (~1));
40838         orig_conv.is_owned = false;
40839         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40840         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
40841         uint32_t ret_ref = 0;
40842         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40843         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40845         ret_ref = (uintptr_t)ret_var.inner;
40846         if (ret_var.is_owned) {
40847                 ret_ref |= 1;
40848         }
40849         return ret_ref;
40850 }
40851
40852 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint32_t o) {
40853         LDKPrivateRoute o_conv;
40854         o_conv.inner = (void*)(o & (~1));
40855         o_conv.is_owned = false;
40856         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40857         int64_t ret_val = PrivateRoute_hash(&o_conv);
40858         return ret_val;
40859 }
40860
40861 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
40862         LDKPrivateRoute a_conv;
40863         a_conv.inner = (void*)(a & (~1));
40864         a_conv.is_owned = false;
40865         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40866         LDKPrivateRoute b_conv;
40867         b_conv.inner = (void*)(b & (~1));
40868         b_conv.is_owned = false;
40869         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40870         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
40871         return ret_val;
40872 }
40873
40874 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
40875         LDKSignedRawInvoice this_arg_conv;
40876         this_arg_conv.inner = (void*)(this_arg & (~1));
40877         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40879         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
40880         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
40881         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
40882         return ((uint32_t)ret_conv);
40883 }
40884
40885 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
40886         LDKSignedRawInvoice this_arg_conv;
40887         this_arg_conv.inner = (void*)(this_arg & (~1));
40888         this_arg_conv.is_owned = false;
40889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40890         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
40891         uint32_t ret_ref = 0;
40892         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40893         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40895         ret_ref = (uintptr_t)ret_var.inner;
40896         if (ret_var.is_owned) {
40897                 ret_ref |= 1;
40898         }
40899         return ret_ref;
40900 }
40901
40902 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
40903         LDKSignedRawInvoice this_arg_conv;
40904         this_arg_conv.inner = (void*)(this_arg & (~1));
40905         this_arg_conv.is_owned = false;
40906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40907         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40908         memcpy(ret_arr->elems, *SignedRawInvoice_hash(&this_arg_conv), 32);
40909         return ret_arr;
40910 }
40911
40912 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
40913         LDKSignedRawInvoice this_arg_conv;
40914         this_arg_conv.inner = (void*)(this_arg & (~1));
40915         this_arg_conv.is_owned = false;
40916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40917         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
40918         uint32_t ret_ref = 0;
40919         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40920         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40922         ret_ref = (uintptr_t)ret_var.inner;
40923         if (ret_var.is_owned) {
40924                 ret_ref |= 1;
40925         }
40926         return ret_ref;
40927 }
40928
40929 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
40930         LDKSignedRawInvoice this_arg_conv;
40931         this_arg_conv.inner = (void*)(this_arg & (~1));
40932         this_arg_conv.is_owned = false;
40933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40934         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
40935         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
40936         return (uint32_t)ret_conv;
40937 }
40938
40939 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
40940         LDKSignedRawInvoice this_arg_conv;
40941         this_arg_conv.inner = (void*)(this_arg & (~1));
40942         this_arg_conv.is_owned = false;
40943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40944         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
40945         return ret_val;
40946 }
40947
40948 int8_tArray  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint32_t this_arg) {
40949         LDKRawInvoice 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         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40954         memcpy(ret_arr->elems, RawInvoice_hash(&this_arg_conv).data, 32);
40955         return ret_arr;
40956 }
40957
40958 uint32_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
40959         LDKRawInvoice this_arg_conv;
40960         this_arg_conv.inner = (void*)(this_arg & (~1));
40961         this_arg_conv.is_owned = false;
40962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40963         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
40964         uint32_t ret_ref = 0;
40965         if ((uintptr_t)ret_var.inner > 4096) {
40966                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40967                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40969                 ret_ref = (uintptr_t)ret_var.inner;
40970                 if (ret_var.is_owned) {
40971                         ret_ref |= 1;
40972                 }
40973         }
40974         return ret_ref;
40975 }
40976
40977 uint32_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint32_t this_arg) {
40978         LDKRawInvoice this_arg_conv;
40979         this_arg_conv.inner = (void*)(this_arg & (~1));
40980         this_arg_conv.is_owned = false;
40981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40982         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
40983         uint32_t ret_ref = 0;
40984         if ((uintptr_t)ret_var.inner > 4096) {
40985                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40986                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40988                 ret_ref = (uintptr_t)ret_var.inner;
40989                 if (ret_var.is_owned) {
40990                         ret_ref |= 1;
40991                 }
40992         }
40993         return ret_ref;
40994 }
40995
40996 uint32_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
40997         LDKRawInvoice this_arg_conv;
40998         this_arg_conv.inner = (void*)(this_arg & (~1));
40999         this_arg_conv.is_owned = false;
41000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41001         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
41002         uint32_t ret_ref = 0;
41003         if ((uintptr_t)ret_var.inner > 4096) {
41004                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41005                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41007                 ret_ref = (uintptr_t)ret_var.inner;
41008                 if (ret_var.is_owned) {
41009                         ret_ref |= 1;
41010                 }
41011         }
41012         return ret_ref;
41013 }
41014
41015 uint32_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
41016         LDKRawInvoice this_arg_conv;
41017         this_arg_conv.inner = (void*)(this_arg & (~1));
41018         this_arg_conv.is_owned = false;
41019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41020         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
41021         uint32_t ret_ref = 0;
41022         if ((uintptr_t)ret_var.inner > 4096) {
41023                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41024                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41026                 ret_ref = (uintptr_t)ret_var.inner;
41027                 if (ret_var.is_owned) {
41028                         ret_ref |= 1;
41029                 }
41030         }
41031         return ret_ref;
41032 }
41033
41034 uint32_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
41035         LDKRawInvoice this_arg_conv;
41036         this_arg_conv.inner = (void*)(this_arg & (~1));
41037         this_arg_conv.is_owned = false;
41038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41039         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
41040         uint32_t ret_ref = 0;
41041         if ((uintptr_t)ret_var.inner > 4096) {
41042                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41043                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41045                 ret_ref = (uintptr_t)ret_var.inner;
41046                 if (ret_var.is_owned) {
41047                         ret_ref |= 1;
41048                 }
41049         }
41050         return ret_ref;
41051 }
41052
41053 uint32_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
41054         LDKRawInvoice this_arg_conv;
41055         this_arg_conv.inner = (void*)(this_arg & (~1));
41056         this_arg_conv.is_owned = false;
41057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41058         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
41059         uint32_t ret_ref = 0;
41060         if ((uintptr_t)ret_var.inner > 4096) {
41061                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41062                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41064                 ret_ref = (uintptr_t)ret_var.inner;
41065                 if (ret_var.is_owned) {
41066                         ret_ref |= 1;
41067                 }
41068         }
41069         return ret_ref;
41070 }
41071
41072 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
41073         LDKRawInvoice this_arg_conv;
41074         this_arg_conv.inner = (void*)(this_arg & (~1));
41075         this_arg_conv.is_owned = false;
41076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41077         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41078         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
41079         return ret_arr;
41080 }
41081
41082 uint32_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint32_t this_arg) {
41083         LDKRawInvoice this_arg_conv;
41084         this_arg_conv.inner = (void*)(this_arg & (~1));
41085         this_arg_conv.is_owned = false;
41086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41087         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
41088         uint32_t ret_ref = 0;
41089         if ((uintptr_t)ret_var.inner > 4096) {
41090                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41091                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41093                 ret_ref = (uintptr_t)ret_var.inner;
41094                 if (ret_var.is_owned) {
41095                         ret_ref |= 1;
41096                 }
41097         }
41098         return ret_ref;
41099 }
41100
41101 uint32_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
41102         LDKRawInvoice this_arg_conv;
41103         this_arg_conv.inner = (void*)(this_arg & (~1));
41104         this_arg_conv.is_owned = false;
41105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41106         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
41107         uint32_tArray ret_arr = NULL;
41108         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41109         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41110         for (size_t o = 0; o < ret_var.datalen; o++) {
41111                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
41112                 uint32_t ret_conv_14_ref = 0;
41113                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41114                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41115                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
41116                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
41117                 if (ret_conv_14_var.is_owned) {
41118                         ret_conv_14_ref |= 1;
41119                 }
41120                 ret_arr_ptr[o] = ret_conv_14_ref;
41121         }
41122         
41123         FREE(ret_var.data);
41124         return ret_arr;
41125 }
41126
41127 uint32_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
41128         LDKRawInvoice this_arg_conv;
41129         this_arg_conv.inner = (void*)(this_arg & (~1));
41130         this_arg_conv.is_owned = false;
41131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41132         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41133         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
41134         uint32_t ret_ref = (uintptr_t)ret_copy;
41135         return ret_ref;
41136 }
41137
41138 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint32_t this_arg) {
41139         LDKRawInvoice this_arg_conv;
41140         this_arg_conv.inner = (void*)(this_arg & (~1));
41141         this_arg_conv.is_owned = false;
41142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41143         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
41144         return ret_conv;
41145 }
41146
41147 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
41148         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
41149         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
41150         return (uint32_t)ret_conv;
41151 }
41152
41153 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
41154         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
41155         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
41156         return (uint32_t)ret_conv;
41157 }
41158
41159 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
41160         LDKPositiveTimestamp this_arg_conv;
41161         this_arg_conv.inner = (void*)(this_arg & (~1));
41162         this_arg_conv.is_owned = false;
41163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41164         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
41165         return ret_val;
41166 }
41167
41168 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint32_t this_arg) {
41169         LDKPositiveTimestamp this_arg_conv;
41170         this_arg_conv.inner = (void*)(this_arg & (~1));
41171         this_arg_conv.is_owned = false;
41172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41173         int64_t ret_val = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
41174         return ret_val;
41175 }
41176
41177 uint32_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
41178         LDKInvoice this_arg_conv;
41179         this_arg_conv.inner = (void*)(this_arg & (~1));
41180         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41182         this_arg_conv = Invoice_clone(&this_arg_conv);
41183         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
41184         uint32_t ret_ref = 0;
41185         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41186         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41188         ret_ref = (uintptr_t)ret_var.inner;
41189         if (ret_var.is_owned) {
41190                 ret_ref |= 1;
41191         }
41192         return ret_ref;
41193 }
41194
41195 uint32_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint32_t this_arg) {
41196         LDKInvoice this_arg_conv;
41197         this_arg_conv.inner = (void*)(this_arg & (~1));
41198         this_arg_conv.is_owned = false;
41199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41200         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
41201         *ret_conv = Invoice_check_signature(&this_arg_conv);
41202         return (uint32_t)ret_conv;
41203 }
41204
41205 uint32_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
41206         LDKSignedRawInvoice signed_invoice_conv;
41207         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
41208         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
41209         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
41210         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
41211         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
41212         *ret_conv = Invoice_from_signed(signed_invoice_conv);
41213         return (uint32_t)ret_conv;
41214 }
41215
41216 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint32_t this_arg) {
41217         LDKInvoice this_arg_conv;
41218         this_arg_conv.inner = (void*)(this_arg & (~1));
41219         this_arg_conv.is_owned = false;
41220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41221         int64_t ret_val = Invoice_duration_since_epoch(&this_arg_conv);
41222         return ret_val;
41223 }
41224
41225 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint32_t this_arg) {
41226         LDKInvoice this_arg_conv;
41227         this_arg_conv.inner = (void*)(this_arg & (~1));
41228         this_arg_conv.is_owned = false;
41229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41230         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41231         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
41232         return ret_arr;
41233 }
41234
41235 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
41236         LDKInvoice this_arg_conv;
41237         this_arg_conv.inner = (void*)(this_arg & (~1));
41238         this_arg_conv.is_owned = false;
41239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41240         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41241         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
41242         return ret_arr;
41243 }
41244
41245 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint32_t this_arg) {
41246         LDKInvoice this_arg_conv;
41247         this_arg_conv.inner = (void*)(this_arg & (~1));
41248         this_arg_conv.is_owned = false;
41249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41250         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41251         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
41252         return ret_arr;
41253 }
41254
41255 uint32_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint32_t this_arg) {
41256         LDKInvoice this_arg_conv;
41257         this_arg_conv.inner = (void*)(this_arg & (~1));
41258         this_arg_conv.is_owned = false;
41259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41260         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
41261         uint32_t ret_ref = 0;
41262         if ((uintptr_t)ret_var.inner > 4096) {
41263                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41264                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41266                 ret_ref = (uintptr_t)ret_var.inner;
41267                 if (ret_var.is_owned) {
41268                         ret_ref |= 1;
41269                 }
41270         }
41271         return ret_ref;
41272 }
41273
41274 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
41275         LDKInvoice this_arg_conv;
41276         this_arg_conv.inner = (void*)(this_arg & (~1));
41277         this_arg_conv.is_owned = false;
41278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41279         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41280         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
41281         return ret_arr;
41282 }
41283
41284 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint32_t this_arg) {
41285         LDKInvoice this_arg_conv;
41286         this_arg_conv.inner = (void*)(this_arg & (~1));
41287         this_arg_conv.is_owned = false;
41288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41289         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
41290         return ret_val;
41291 }
41292
41293 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint32_t this_arg, int64_t at_time) {
41294         LDKInvoice this_arg_conv;
41295         this_arg_conv.inner = (void*)(this_arg & (~1));
41296         this_arg_conv.is_owned = false;
41297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41298         jboolean ret_val = Invoice_would_expire(&this_arg_conv, at_time);
41299         return ret_val;
41300 }
41301
41302 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
41303         LDKInvoice this_arg_conv;
41304         this_arg_conv.inner = (void*)(this_arg & (~1));
41305         this_arg_conv.is_owned = false;
41306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41307         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
41308         return ret_val;
41309 }
41310
41311 uint32_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint32_t this_arg) {
41312         LDKInvoice this_arg_conv;
41313         this_arg_conv.inner = (void*)(this_arg & (~1));
41314         this_arg_conv.is_owned = false;
41315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41316         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
41317         uint32_tArray ret_arr = NULL;
41318         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41319         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41320         for (size_t o = 0; o < ret_var.datalen; o++) {
41321                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
41322                 uint32_t ret_conv_14_ref = 0;
41323                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41324                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41325                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
41326                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
41327                 if (ret_conv_14_var.is_owned) {
41328                         ret_conv_14_ref |= 1;
41329                 }
41330                 ret_arr_ptr[o] = ret_conv_14_ref;
41331         }
41332         
41333         FREE(ret_var.data);
41334         return ret_arr;
41335 }
41336
41337 uint32_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(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         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
41343         uint32_tArray ret_arr = NULL;
41344         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41345         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41346         for (size_t l = 0; l < ret_var.datalen; l++) {
41347                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
41348                 uint32_t ret_conv_11_ref = 0;
41349                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41350                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41351                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
41352                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
41353                 if (ret_conv_11_var.is_owned) {
41354                         ret_conv_11_ref |= 1;
41355                 }
41356                 ret_arr_ptr[l] = ret_conv_11_ref;
41357         }
41358         
41359         FREE(ret_var.data);
41360         return ret_arr;
41361 }
41362
41363 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint32_t this_arg) {
41364         LDKInvoice this_arg_conv;
41365         this_arg_conv.inner = (void*)(this_arg & (~1));
41366         this_arg_conv.is_owned = false;
41367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41368         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
41369         return ret_conv;
41370 }
41371
41372 uint32_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
41373         LDKInvoice this_arg_conv;
41374         this_arg_conv.inner = (void*)(this_arg & (~1));
41375         this_arg_conv.is_owned = false;
41376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41377         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41378         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
41379         uint32_t ret_ref = (uintptr_t)ret_copy;
41380         return ret_ref;
41381 }
41382
41383 uint32_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
41384         LDKStr description_conv = str_ref_to_owned_c(description);
41385         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
41386         *ret_conv = Description_new(description_conv);
41387         return (uint32_t)ret_conv;
41388 }
41389
41390 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint32_t this_arg) {
41391         LDKDescription this_arg_conv;
41392         this_arg_conv.inner = (void*)(this_arg & (~1));
41393         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41395         this_arg_conv = Description_clone(&this_arg_conv);
41396         LDKStr ret_str = Description_into_inner(this_arg_conv);
41397         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41398         Str_free(ret_str);
41399         return ret_conv;
41400 }
41401
41402 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
41403         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
41404         uint32_t ret_ref = 0;
41405         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41406         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41408         ret_ref = (uintptr_t)ret_var.inner;
41409         if (ret_var.is_owned) {
41410                 ret_ref |= 1;
41411         }
41412         return ret_ref;
41413 }
41414
41415 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
41416         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
41417         uint32_t ret_ref = 0;
41418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41421         ret_ref = (uintptr_t)ret_var.inner;
41422         if (ret_var.is_owned) {
41423                 ret_ref |= 1;
41424         }
41425         return ret_ref;
41426 }
41427
41428 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
41429         LDKExpiryTime this_arg_conv;
41430         this_arg_conv.inner = (void*)(this_arg & (~1));
41431         this_arg_conv.is_owned = false;
41432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41433         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
41434         return ret_val;
41435 }
41436
41437 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
41438         LDKExpiryTime this_arg_conv;
41439         this_arg_conv.inner = (void*)(this_arg & (~1));
41440         this_arg_conv.is_owned = false;
41441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41442         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
41443         return ret_val;
41444 }
41445
41446 uint32_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint32_t hops) {
41447         LDKRouteHint hops_conv;
41448         hops_conv.inner = (void*)(hops & (~1));
41449         hops_conv.is_owned = (hops & 1) || (hops == 0);
41450         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
41451         hops_conv = RouteHint_clone(&hops_conv);
41452         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
41453         *ret_conv = PrivateRoute_new(hops_conv);
41454         return (uint32_t)ret_conv;
41455 }
41456
41457 uint32_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
41458         LDKPrivateRoute this_arg_conv;
41459         this_arg_conv.inner = (void*)(this_arg & (~1));
41460         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41462         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
41463         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
41464         uint32_t ret_ref = 0;
41465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41468         ret_ref = (uintptr_t)ret_var.inner;
41469         if (ret_var.is_owned) {
41470                 ret_ref |= 1;
41471         }
41472         return ret_ref;
41473 }
41474
41475 uint32_t  __attribute__((export_name("TS_CreationError_clone"))) TS_CreationError_clone(uint32_t orig) {
41476         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
41477         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
41478         return ret_conv;
41479 }
41480
41481 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
41482         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
41483         return ret_conv;
41484 }
41485
41486 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
41487         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
41488         return ret_conv;
41489 }
41490
41491 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
41492         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
41493         return ret_conv;
41494 }
41495
41496 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
41497         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
41498         return ret_conv;
41499 }
41500
41501 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
41502         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
41503         return ret_conv;
41504 }
41505
41506 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
41507         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
41508         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
41509         jboolean ret_val = CreationError_eq(a_conv, b_conv);
41510         return ret_val;
41511 }
41512
41513 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint32_t o) {
41514         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
41515         LDKStr ret_str = CreationError_to_str(o_conv);
41516         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41517         Str_free(ret_str);
41518         return ret_conv;
41519 }
41520
41521 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint32_t orig) {
41522         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
41523         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
41524         return ret_conv;
41525 }
41526
41527 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
41528         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
41529         return ret_conv;
41530 }
41531
41532 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
41533         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
41534         return ret_conv;
41535 }
41536
41537 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
41538         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
41539         return ret_conv;
41540 }
41541
41542 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
41543         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
41544         return ret_conv;
41545 }
41546
41547 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
41548         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
41549         return ret_conv;
41550 }
41551
41552 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
41553         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
41554         return ret_conv;
41555 }
41556
41557 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
41558         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
41559         return ret_conv;
41560 }
41561
41562 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
41563         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
41564         return ret_conv;
41565 }
41566
41567 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
41568         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
41569         return ret_conv;
41570 }
41571
41572 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
41573         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
41574         return ret_conv;
41575 }
41576
41577 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
41578         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
41579         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
41580         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
41581         return ret_val;
41582 }
41583
41584 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint32_t o) {
41585         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
41586         LDKStr ret_str = SemanticError_to_str(o_conv);
41587         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41588         Str_free(ret_str);
41589         return ret_conv;
41590 }
41591
41592 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
41593         if ((this_ptr & 1) != 0) return;
41594         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41595         CHECK_ACCESS(this_ptr_ptr);
41596         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
41597         FREE((void*)this_ptr);
41598         SignOrCreationError_free(this_ptr_conv);
41599 }
41600
41601 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
41602         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41603         *ret_copy = SignOrCreationError_clone(arg);
41604 uint32_t ret_ref = (uintptr_t)ret_copy;
41605         return ret_ref;
41606 }
41607 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
41608         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
41609         uint32_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
41610         return ret_val;
41611 }
41612
41613 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint32_t orig) {
41614         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
41615         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41616         *ret_copy = SignOrCreationError_clone(orig_conv);
41617         uint32_t ret_ref = (uintptr_t)ret_copy;
41618         return ret_ref;
41619 }
41620
41621 uint32_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
41622         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41623         *ret_copy = SignOrCreationError_sign_error();
41624         uint32_t ret_ref = (uintptr_t)ret_copy;
41625         return ret_ref;
41626 }
41627
41628 uint32_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
41629         LDKCreationError a_conv = LDKCreationError_from_js(a);
41630         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41631         *ret_copy = SignOrCreationError_creation_error(a_conv);
41632         uint32_t ret_ref = (uintptr_t)ret_copy;
41633         return ret_ref;
41634 }
41635
41636 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
41637         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
41638         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
41639         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
41640         return ret_val;
41641 }
41642
41643 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint32_t o) {
41644         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
41645         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
41646         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41647         Str_free(ret_str);
41648         return ret_conv;
41649 }
41650
41651 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint32_t this_obj) {
41652         LDKInvoicePayer this_obj_conv;
41653         this_obj_conv.inner = (void*)(this_obj & (~1));
41654         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41656         InvoicePayer_free(this_obj_conv);
41657 }
41658
41659 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint32_t this_ptr) {
41660         if ((this_ptr & 1) != 0) return;
41661         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41662         CHECK_ACCESS(this_ptr_ptr);
41663         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
41664         FREE((void*)this_ptr);
41665         Payer_free(this_ptr_conv);
41666 }
41667
41668 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint32_t this_ptr) {
41669         if ((this_ptr & 1) != 0) return;
41670         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41671         CHECK_ACCESS(this_ptr_ptr);
41672         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
41673         FREE((void*)this_ptr);
41674         Router_free(this_ptr_conv);
41675 }
41676
41677 void  __attribute__((export_name("TS_RetryAttempts_free"))) TS_RetryAttempts_free(uint32_t this_obj) {
41678         LDKRetryAttempts this_obj_conv;
41679         this_obj_conv.inner = (void*)(this_obj & (~1));
41680         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41682         RetryAttempts_free(this_obj_conv);
41683 }
41684
41685 uint32_t  __attribute__((export_name("TS_RetryAttempts_get_a"))) TS_RetryAttempts_get_a(uint32_t this_ptr) {
41686         LDKRetryAttempts this_ptr_conv;
41687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41688         this_ptr_conv.is_owned = false;
41689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41690         uint32_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
41691         return ret_val;
41692 }
41693
41694 void  __attribute__((export_name("TS_RetryAttempts_set_a"))) TS_RetryAttempts_set_a(uint32_t this_ptr, uint32_t val) {
41695         LDKRetryAttempts this_ptr_conv;
41696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41697         this_ptr_conv.is_owned = false;
41698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41699         RetryAttempts_set_a(&this_ptr_conv, val);
41700 }
41701
41702 uint32_t  __attribute__((export_name("TS_RetryAttempts_new"))) TS_RetryAttempts_new(uint32_t a_arg) {
41703         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
41704         uint32_t ret_ref = 0;
41705         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41706         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41708         ret_ref = (uintptr_t)ret_var.inner;
41709         if (ret_var.is_owned) {
41710                 ret_ref |= 1;
41711         }
41712         return ret_ref;
41713 }
41714
41715 static inline uintptr_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
41716         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
41717 uint32_t ret_ref = 0;
41718 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41719 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41720 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41721 ret_ref = (uintptr_t)ret_var.inner;
41722 if (ret_var.is_owned) {
41723         ret_ref |= 1;
41724 }
41725         return ret_ref;
41726 }
41727 uint32_t  __attribute__((export_name("TS_RetryAttempts_clone_ptr"))) TS_RetryAttempts_clone_ptr(uint32_t arg) {
41728         LDKRetryAttempts arg_conv;
41729         arg_conv.inner = (void*)(arg & (~1));
41730         arg_conv.is_owned = false;
41731         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41732         uint32_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
41733         return ret_val;
41734 }
41735
41736 uint32_t  __attribute__((export_name("TS_RetryAttempts_clone"))) TS_RetryAttempts_clone(uint32_t orig) {
41737         LDKRetryAttempts orig_conv;
41738         orig_conv.inner = (void*)(orig & (~1));
41739         orig_conv.is_owned = false;
41740         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41741         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
41742         uint32_t ret_ref = 0;
41743         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41744         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41746         ret_ref = (uintptr_t)ret_var.inner;
41747         if (ret_var.is_owned) {
41748                 ret_ref |= 1;
41749         }
41750         return ret_ref;
41751 }
41752
41753 jboolean  __attribute__((export_name("TS_RetryAttempts_eq"))) TS_RetryAttempts_eq(uint32_t a, uint32_t b) {
41754         LDKRetryAttempts a_conv;
41755         a_conv.inner = (void*)(a & (~1));
41756         a_conv.is_owned = false;
41757         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41758         LDKRetryAttempts b_conv;
41759         b_conv.inner = (void*)(b & (~1));
41760         b_conv.is_owned = false;
41761         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41762         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
41763         return ret_val;
41764 }
41765
41766 int64_t  __attribute__((export_name("TS_RetryAttempts_hash"))) TS_RetryAttempts_hash(uint32_t o) {
41767         LDKRetryAttempts o_conv;
41768         o_conv.inner = (void*)(o & (~1));
41769         o_conv.is_owned = false;
41770         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41771         int64_t ret_val = RetryAttempts_hash(&o_conv);
41772         return ret_val;
41773 }
41774
41775 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint32_t this_ptr) {
41776         if ((this_ptr & 1) != 0) return;
41777         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41778         CHECK_ACCESS(this_ptr_ptr);
41779         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
41780         FREE((void*)this_ptr);
41781         PaymentError_free(this_ptr_conv);
41782 }
41783
41784 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
41785         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41786         *ret_copy = PaymentError_clone(arg);
41787 uint32_t ret_ref = (uintptr_t)ret_copy;
41788         return ret_ref;
41789 }
41790 uint32_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint32_t arg) {
41791         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
41792         uint32_t ret_val = PaymentError_clone_ptr(arg_conv);
41793         return ret_val;
41794 }
41795
41796 uint32_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint32_t orig) {
41797         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
41798         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41799         *ret_copy = PaymentError_clone(orig_conv);
41800         uint32_t ret_ref = (uintptr_t)ret_copy;
41801         return ret_ref;
41802 }
41803
41804 uint32_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
41805         LDKStr a_conv = str_ref_to_owned_c(a);
41806         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41807         *ret_copy = PaymentError_invoice(a_conv);
41808         uint32_t ret_ref = (uintptr_t)ret_copy;
41809         return ret_ref;
41810 }
41811
41812 uint32_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint32_t a) {
41813         LDKLightningError a_conv;
41814         a_conv.inner = (void*)(a & (~1));
41815         a_conv.is_owned = (a & 1) || (a == 0);
41816         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41817         a_conv = LightningError_clone(&a_conv);
41818         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41819         *ret_copy = PaymentError_routing(a_conv);
41820         uint32_t ret_ref = (uintptr_t)ret_copy;
41821         return ret_ref;
41822 }
41823
41824 uint32_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint32_t a) {
41825         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
41826         CHECK_ACCESS(a_ptr);
41827         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
41828         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
41829         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41830         *ret_copy = PaymentError_sending(a_conv);
41831         uint32_t ret_ref = (uintptr_t)ret_copy;
41832         return ret_ref;
41833 }
41834
41835 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) {
41836         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
41837         CHECK_ACCESS(payer_ptr);
41838         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
41839         if (payer_conv.free == LDKPayer_JCalls_free) {
41840                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41841                 LDKPayer_JCalls_cloned(&payer_conv);
41842         }
41843         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
41844         CHECK_ACCESS(router_ptr);
41845         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
41846         if (router_conv.free == LDKRouter_JCalls_free) {
41847                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41848                 LDKRouter_JCalls_cloned(&router_conv);
41849         }
41850         LDKMultiThreadedLockableScore scorer_conv;
41851         scorer_conv.inner = (void*)(scorer & (~1));
41852         scorer_conv.is_owned = false;
41853         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
41854         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41855         CHECK_ACCESS(logger_ptr);
41856         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41857         if (logger_conv.free == LDKLogger_JCalls_free) {
41858                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41859                 LDKLogger_JCalls_cloned(&logger_conv);
41860         }
41861         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
41862         CHECK_ACCESS(event_handler_ptr);
41863         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
41864         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
41865                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41866                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
41867         }
41868         LDKRetryAttempts retry_attempts_conv;
41869         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
41870         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
41871         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
41872         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
41873         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
41874         uint32_t ret_ref = 0;
41875         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41876         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41878         ret_ref = (uintptr_t)ret_var.inner;
41879         if (ret_var.is_owned) {
41880                 ret_ref |= 1;
41881         }
41882         return ret_ref;
41883 }
41884
41885 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
41886         LDKInvoicePayer this_arg_conv;
41887         this_arg_conv.inner = (void*)(this_arg & (~1));
41888         this_arg_conv.is_owned = false;
41889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41890         LDKInvoice invoice_conv;
41891         invoice_conv.inner = (void*)(invoice & (~1));
41892         invoice_conv.is_owned = false;
41893         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
41894         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41895         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
41896         return (uint32_t)ret_conv;
41897 }
41898
41899 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) {
41900         LDKInvoicePayer this_arg_conv;
41901         this_arg_conv.inner = (void*)(this_arg & (~1));
41902         this_arg_conv.is_owned = false;
41903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41904         LDKInvoice invoice_conv;
41905         invoice_conv.inner = (void*)(invoice & (~1));
41906         invoice_conv.is_owned = false;
41907         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
41908         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41909         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
41910         return (uint32_t)ret_conv;
41911 }
41912
41913 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) {
41914         LDKInvoicePayer this_arg_conv;
41915         this_arg_conv.inner = (void*)(this_arg & (~1));
41916         this_arg_conv.is_owned = false;
41917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41918         LDKPublicKey pubkey_ref;
41919         CHECK(pubkey->arr_len == 33);
41920         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
41921         LDKThirtyTwoBytes payment_preimage_ref;
41922         CHECK(payment_preimage->arr_len == 32);
41923         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
41924         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41925         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
41926         return (uint32_t)ret_conv;
41927 }
41928
41929 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
41930         LDKInvoicePayer this_arg_conv;
41931         this_arg_conv.inner = (void*)(this_arg & (~1));
41932         this_arg_conv.is_owned = false;
41933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41934         unsigned char payment_hash_arr[32];
41935         CHECK(payment_hash->arr_len == 32);
41936         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
41937         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
41938         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
41939 }
41940
41941 uint32_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
41942         LDKInvoicePayer this_arg_conv;
41943         this_arg_conv.inner = (void*)(this_arg & (~1));
41944         this_arg_conv.is_owned = false;
41945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41946         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
41947         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
41948         return (uint32_t)ret_ret;
41949 }
41950
41951 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) {
41952         LDKChannelManager channelmanager_conv;
41953         channelmanager_conv.inner = (void*)(channelmanager & (~1));
41954         channelmanager_conv.is_owned = false;
41955         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
41956         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
41957         CHECK_ACCESS(keys_manager_ptr);
41958         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
41959         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
41960                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41961                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
41962         }
41963         LDKCurrency network_conv = LDKCurrency_from_js(network);
41964         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
41965         CHECK_ACCESS(amt_msat_ptr);
41966         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
41967         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
41968         LDKSha256 description_hash_conv;
41969         description_hash_conv.inner = (void*)(description_hash & (~1));
41970         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
41971         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
41972         description_hash_conv = Sha256_clone(&description_hash_conv);
41973         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
41974         *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);
41975         return (uint32_t)ret_conv;
41976 }
41977
41978 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) {
41979         LDKChannelManager channelmanager_conv;
41980         channelmanager_conv.inner = (void*)(channelmanager & (~1));
41981         channelmanager_conv.is_owned = false;
41982         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
41983         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
41984         CHECK_ACCESS(keys_manager_ptr);
41985         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
41986         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
41987                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41988                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
41989         }
41990         LDKCurrency network_conv = LDKCurrency_from_js(network);
41991         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
41992         CHECK_ACCESS(amt_msat_ptr);
41993         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
41994         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
41995         LDKStr description_conv = str_ref_to_owned_c(description);
41996         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
41997         *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);
41998         return (uint32_t)ret_conv;
41999 }
42000
42001 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint32_t this_obj) {
42002         LDKDefaultRouter this_obj_conv;
42003         this_obj_conv.inner = (void*)(this_obj & (~1));
42004         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42006         DefaultRouter_free(this_obj_conv);
42007 }
42008
42009 uint32_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger, int8_tArray random_seed_bytes) {
42010         LDKNetworkGraph network_graph_conv;
42011         network_graph_conv.inner = (void*)(network_graph & (~1));
42012         network_graph_conv.is_owned = false;
42013         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42014         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42015         CHECK_ACCESS(logger_ptr);
42016         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42017         if (logger_conv.free == LDKLogger_JCalls_free) {
42018                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42019                 LDKLogger_JCalls_cloned(&logger_conv);
42020         }
42021         LDKThirtyTwoBytes random_seed_bytes_ref;
42022         CHECK(random_seed_bytes->arr_len == 32);
42023         memcpy(random_seed_bytes_ref.data, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
42024         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
42025         uint32_t ret_ref = 0;
42026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42029         ret_ref = (uintptr_t)ret_var.inner;
42030         if (ret_var.is_owned) {
42031                 ret_ref |= 1;
42032         }
42033         return ret_ref;
42034 }
42035
42036 uint32_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
42037         LDKDefaultRouter this_arg_conv;
42038         this_arg_conv.inner = (void*)(this_arg & (~1));
42039         this_arg_conv.is_owned = false;
42040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42041         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
42042         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
42043         return (uint32_t)ret_ret;
42044 }
42045
42046 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
42047         LDKChannelManager this_arg_conv;
42048         this_arg_conv.inner = (void*)(this_arg & (~1));
42049         this_arg_conv.is_owned = false;
42050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42051         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
42052         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
42053         return (uint32_t)ret_ret;
42054 }
42055
42056 uint32_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
42057         LDKStr s_conv = str_ref_to_owned_c(s);
42058         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
42059         *ret_conv = SiPrefix_from_str(s_conv);
42060         return (uint32_t)ret_conv;
42061 }
42062
42063 uint32_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
42064         LDKStr s_conv = str_ref_to_owned_c(s);
42065         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
42066         *ret_conv = Invoice_from_str(s_conv);
42067         return (uint32_t)ret_conv;
42068 }
42069
42070 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
42071         LDKStr s_conv = str_ref_to_owned_c(s);
42072         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
42073         *ret_conv = SignedRawInvoice_from_str(s_conv);
42074         return (uint32_t)ret_conv;
42075 }
42076
42077 jstring  __attribute__((export_name("TS_ParseError_to_str"))) TS_ParseError_to_str(uint32_t o) {
42078         LDKParseError* o_conv = (LDKParseError*)o;
42079         LDKStr ret_str = ParseError_to_str(o_conv);
42080         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42081         Str_free(ret_str);
42082         return ret_conv;
42083 }
42084
42085 jstring  __attribute__((export_name("TS_ParseOrSemanticError_to_str"))) TS_ParseOrSemanticError_to_str(uint32_t o) {
42086         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
42087         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
42088         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42089         Str_free(ret_str);
42090         return ret_conv;
42091 }
42092
42093 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint32_t o) {
42094         LDKInvoice o_conv;
42095         o_conv.inner = (void*)(o & (~1));
42096         o_conv.is_owned = false;
42097         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42098         LDKStr ret_str = Invoice_to_str(&o_conv);
42099         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42100         Str_free(ret_str);
42101         return ret_conv;
42102 }
42103
42104 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint32_t o) {
42105         LDKSignedRawInvoice o_conv;
42106         o_conv.inner = (void*)(o & (~1));
42107         o_conv.is_owned = false;
42108         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42109         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
42110         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42111         Str_free(ret_str);
42112         return ret_conv;
42113 }
42114
42115 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint32_t o) {
42116         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
42117         LDKStr ret_str = Currency_to_str(o_conv);
42118         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42119         Str_free(ret_str);
42120         return ret_conv;
42121 }
42122
42123 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint32_t o) {
42124         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
42125         LDKStr ret_str = SiPrefix_to_str(o_conv);
42126         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42127         Str_free(ret_str);
42128         return ret_conv;
42129 }
42130