Update CI references to 0.0.122
[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 LDKLevel LDKLevel_from_js(int32_t ord) {
154         switch (ord) {
155                 case 0: return LDKLevel_Gossip;
156                 case 1: return LDKLevel_Trace;
157                 case 2: return LDKLevel_Debug;
158                 case 3: return LDKLevel_Info;
159                 case 4: return LDKLevel_Warn;
160                 case 5: return LDKLevel_Error;
161         }
162         abort();
163 }
164 static inline int32_t LDKLevel_to_js(LDKLevel val) {
165         switch (val) {
166                 case LDKLevel_Gossip: return 0;
167                 case LDKLevel_Trace: return 1;
168                 case LDKLevel_Debug: return 2;
169                 case LDKLevel_Info: return 3;
170                 case LDKLevel_Warn: return 4;
171                 case LDKLevel_Error: return 5;
172                 default: abort();
173         }
174 }
175 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
176         switch (ord) {
177                 case 0: return LDKNetwork_Bitcoin;
178                 case 1: return LDKNetwork_Testnet;
179                 case 2: return LDKNetwork_Regtest;
180                 case 3: return LDKNetwork_Signet;
181         }
182         abort();
183 }
184 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
185         switch (val) {
186                 case LDKNetwork_Bitcoin: return 0;
187                 case LDKNetwork_Testnet: return 1;
188                 case LDKNetwork_Regtest: return 2;
189                 case LDKNetwork_Signet: return 3;
190                 default: abort();
191         }
192 }
193 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
194         switch (ord) {
195                 case 0: return LDKSecp256k1Error_IncorrectSignature;
196                 case 1: return LDKSecp256k1Error_InvalidMessage;
197                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
198                 case 3: return LDKSecp256k1Error_InvalidSignature;
199                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
200                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
201                 case 6: return LDKSecp256k1Error_InvalidTweak;
202                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
203                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
204         }
205         abort();
206 }
207 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
208         switch (val) {
209                 case LDKSecp256k1Error_IncorrectSignature: return 0;
210                 case LDKSecp256k1Error_InvalidMessage: return 1;
211                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
212                 case LDKSecp256k1Error_InvalidSignature: return 3;
213                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
214                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
215                 case LDKSecp256k1Error_InvalidTweak: return 6;
216                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
217                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
218                 default: abort();
219         }
220 }
221 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
222         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
223         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
224         return ret;
225 }
226 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) {
227         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
228         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
229         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
230         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
231         CVec_u8Z_free(ret_var);
232         return ret_arr;
233 }
234
235 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) {
236         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
237         int64_t ret_val = TxOut_get_value(thing_conv);
238         return ret_val;
239 }
240
241 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
242 CHECK(owner->result_ok);
243         return ChannelConfig_clone(&*owner->contents.result);
244 }
245 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
246         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
247         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
248         uintptr_t ret_ref = 0;
249         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
250         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
252         ret_ref = (uintptr_t)ret_var.inner;
253         if (ret_var.is_owned) {
254                 ret_ref |= 1;
255         }
256         return ret_ref;
257 }
258
259 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
260 CHECK(!owner->result_ok);
261         return DecodeError_clone(&*owner->contents.err);
262 }
263 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
264         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
265         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
266         uintptr_t ret_ref = 0;
267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
270         ret_ref = (uintptr_t)ret_var.inner;
271         if (ret_var.is_owned) {
272                 ret_ref |= 1;
273         }
274         return ret_ref;
275 }
276
277 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
278 CHECK(owner->result_ok);
279         return OutPoint_clone(&*owner->contents.result);
280 }
281 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
282         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
283         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
284         uintptr_t ret_ref = 0;
285         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
286         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
288         ret_ref = (uintptr_t)ret_var.inner;
289         if (ret_var.is_owned) {
290                 ret_ref |= 1;
291         }
292         return ret_ref;
293 }
294
295 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
296 CHECK(!owner->result_ok);
297         return DecodeError_clone(&*owner->contents.err);
298 }
299 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
300         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
301         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
302         uintptr_t ret_ref = 0;
303         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
304         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
306         ret_ref = (uintptr_t)ret_var.inner;
307         if (ret_var.is_owned) {
308                 ret_ref |= 1;
309         }
310         return ret_ref;
311 }
312
313 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
314 CHECK(owner->result_ok);
315         return *owner->contents.result;
316 }
317 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
318         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
319         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
320         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
321         return ret_arr;
322 }
323
324 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
325 CHECK(!owner->result_ok);
326         return *owner->contents.err;
327 }
328 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
329         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
330         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
331         return ret_conv;
332 }
333
334 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
335 CHECK(owner->result_ok);
336         return *owner->contents.result;
337 }
338 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
339         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
340         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
341         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
342         return ret_arr;
343 }
344
345 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
346 CHECK(!owner->result_ok);
347         return *owner->contents.err;
348 }
349 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
350         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
351         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
352         return ret_conv;
353 }
354
355 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
356 CHECK(owner->result_ok);
357         return TxCreationKeys_clone(&*owner->contents.result);
358 }
359 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
360         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
361         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
362         uintptr_t ret_ref = 0;
363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
366         ret_ref = (uintptr_t)ret_var.inner;
367         if (ret_var.is_owned) {
368                 ret_ref |= 1;
369         }
370         return ret_ref;
371 }
372
373 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
374 CHECK(!owner->result_ok);
375         return DecodeError_clone(&*owner->contents.err);
376 }
377 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
378         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
379         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
380         uintptr_t ret_ref = 0;
381         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
382         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
384         ret_ref = (uintptr_t)ret_var.inner;
385         if (ret_var.is_owned) {
386                 ret_ref |= 1;
387         }
388         return ret_ref;
389 }
390
391 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
392 CHECK(owner->result_ok);
393         return ChannelPublicKeys_clone(&*owner->contents.result);
394 }
395 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
396         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
397         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
398         uintptr_t ret_ref = 0;
399         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
400         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
402         ret_ref = (uintptr_t)ret_var.inner;
403         if (ret_var.is_owned) {
404                 ret_ref |= 1;
405         }
406         return ret_ref;
407 }
408
409 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
410 CHECK(!owner->result_ok);
411         return DecodeError_clone(&*owner->contents.err);
412 }
413 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
414         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
415         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
416         uintptr_t ret_ref = 0;
417         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
418         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
420         ret_ref = (uintptr_t)ret_var.inner;
421         if (ret_var.is_owned) {
422                 ret_ref |= 1;
423         }
424         return ret_ref;
425 }
426
427 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
428 CHECK(owner->result_ok);
429         return TxCreationKeys_clone(&*owner->contents.result);
430 }
431 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
432         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
433         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
434         uintptr_t ret_ref = 0;
435         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
436         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
438         ret_ref = (uintptr_t)ret_var.inner;
439         if (ret_var.is_owned) {
440                 ret_ref |= 1;
441         }
442         return ret_ref;
443 }
444
445 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
446 CHECK(!owner->result_ok);
447         return *owner->contents.err;
448 }
449 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
450         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
451         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
452         return ret_conv;
453 }
454
455 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
456         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
457         switch(obj->tag) {
458                 case LDKCOption_u32Z_Some: return 0;
459                 case LDKCOption_u32Z_None: return 1;
460                 default: abort();
461         }
462 }
463 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
464         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
465         assert(obj->tag == LDKCOption_u32Z_Some);
466         return obj->some;
467 }
468 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
469 CHECK(owner->result_ok);
470         return HTLCOutputInCommitment_clone(&*owner->contents.result);
471 }
472 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
473         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
474         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
475         uintptr_t ret_ref = 0;
476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
479         ret_ref = (uintptr_t)ret_var.inner;
480         if (ret_var.is_owned) {
481                 ret_ref |= 1;
482         }
483         return ret_ref;
484 }
485
486 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
487 CHECK(!owner->result_ok);
488         return DecodeError_clone(&*owner->contents.err);
489 }
490 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
491         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
492         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
493         uintptr_t ret_ref = 0;
494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
497         ret_ref = (uintptr_t)ret_var.inner;
498         if (ret_var.is_owned) {
499                 ret_ref |= 1;
500         }
501         return ret_ref;
502 }
503
504 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
505 CHECK(owner->result_ok);
506         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
507 }
508 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
509         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
510         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
511         uintptr_t ret_ref = 0;
512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
515         ret_ref = (uintptr_t)ret_var.inner;
516         if (ret_var.is_owned) {
517                 ret_ref |= 1;
518         }
519         return ret_ref;
520 }
521
522 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
523 CHECK(!owner->result_ok);
524         return DecodeError_clone(&*owner->contents.err);
525 }
526 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
527         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
528         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
529         uintptr_t ret_ref = 0;
530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
533         ret_ref = (uintptr_t)ret_var.inner;
534         if (ret_var.is_owned) {
535                 ret_ref |= 1;
536         }
537         return ret_ref;
538 }
539
540 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
541 CHECK(owner->result_ok);
542         return ChannelTransactionParameters_clone(&*owner->contents.result);
543 }
544 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
545         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
546         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
547         uintptr_t ret_ref = 0;
548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
551         ret_ref = (uintptr_t)ret_var.inner;
552         if (ret_var.is_owned) {
553                 ret_ref |= 1;
554         }
555         return ret_ref;
556 }
557
558 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
559 CHECK(!owner->result_ok);
560         return DecodeError_clone(&*owner->contents.err);
561 }
562 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
563         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
564         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
565         uintptr_t ret_ref = 0;
566         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
567         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
569         ret_ref = (uintptr_t)ret_var.inner;
570         if (ret_var.is_owned) {
571                 ret_ref |= 1;
572         }
573         return ret_ref;
574 }
575
576 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
577 CHECK(owner->result_ok);
578         return HolderCommitmentTransaction_clone(&*owner->contents.result);
579 }
580 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
581         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
582         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
583         uintptr_t ret_ref = 0;
584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
587         ret_ref = (uintptr_t)ret_var.inner;
588         if (ret_var.is_owned) {
589                 ret_ref |= 1;
590         }
591         return ret_ref;
592 }
593
594 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
595 CHECK(!owner->result_ok);
596         return DecodeError_clone(&*owner->contents.err);
597 }
598 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
599         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
600         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
601         uintptr_t ret_ref = 0;
602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
605         ret_ref = (uintptr_t)ret_var.inner;
606         if (ret_var.is_owned) {
607                 ret_ref |= 1;
608         }
609         return ret_ref;
610 }
611
612 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
613 CHECK(owner->result_ok);
614         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
615 }
616 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
617         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
618         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
619         uintptr_t ret_ref = 0;
620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
623         ret_ref = (uintptr_t)ret_var.inner;
624         if (ret_var.is_owned) {
625                 ret_ref |= 1;
626         }
627         return ret_ref;
628 }
629
630 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
631 CHECK(!owner->result_ok);
632         return DecodeError_clone(&*owner->contents.err);
633 }
634 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
635         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
636         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
637         uintptr_t ret_ref = 0;
638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
641         ret_ref = (uintptr_t)ret_var.inner;
642         if (ret_var.is_owned) {
643                 ret_ref |= 1;
644         }
645         return ret_ref;
646 }
647
648 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
649 CHECK(owner->result_ok);
650         return &*owner->contents.result;
651 }
652 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
653         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
654         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
655         uintptr_t ret_ref = 0;
656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
659         ret_ref = (uintptr_t)ret_var.inner & ~1;
660         return ret_ref;
661 }
662
663 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
664 CHECK(!owner->result_ok);
665         return *owner->contents.err;
666 }
667 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
668         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
669         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
670 }
671
672 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
673 CHECK(owner->result_ok);
674         return CommitmentTransaction_clone(&*owner->contents.result);
675 }
676 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
677         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
678         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
679         uintptr_t ret_ref = 0;
680         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
681         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
683         ret_ref = (uintptr_t)ret_var.inner;
684         if (ret_var.is_owned) {
685                 ret_ref |= 1;
686         }
687         return ret_ref;
688 }
689
690 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
691 CHECK(!owner->result_ok);
692         return DecodeError_clone(&*owner->contents.err);
693 }
694 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
695         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
696         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
697         uintptr_t ret_ref = 0;
698         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
699         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
701         ret_ref = (uintptr_t)ret_var.inner;
702         if (ret_var.is_owned) {
703                 ret_ref |= 1;
704         }
705         return ret_ref;
706 }
707
708 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
709 CHECK(owner->result_ok);
710         return &*owner->contents.result;
711 }
712 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
713         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
714         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
715         uintptr_t ret_ref = 0;
716         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
717         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
719         ret_ref = (uintptr_t)ret_var.inner & ~1;
720         return ret_ref;
721 }
722
723 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
724 CHECK(!owner->result_ok);
725         return *owner->contents.err;
726 }
727 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
728         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
729         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
730 }
731
732 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
733 CHECK(owner->result_ok);
734         return *owner->contents.result;
735 }
736 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
737         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
738         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
739         ptrArray ret_arr = NULL;
740         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
741         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
742         for (size_t m = 0; m < ret_var.datalen; m++) {
743                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
744                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
745                 ret_arr_ptr[m] = ret_conv_12_arr;
746         }
747         
748         return ret_arr;
749 }
750
751 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
752 CHECK(!owner->result_ok);
753         return *owner->contents.err;
754 }
755 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
756         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
757         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
758 }
759
760 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
761 CHECK(owner->result_ok);
762         return ShutdownScript_clone(&*owner->contents.result);
763 }
764 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
765         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
766         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
767         uintptr_t ret_ref = 0;
768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
771         ret_ref = (uintptr_t)ret_var.inner;
772         if (ret_var.is_owned) {
773                 ret_ref |= 1;
774         }
775         return ret_ref;
776 }
777
778 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
779 CHECK(!owner->result_ok);
780         return DecodeError_clone(&*owner->contents.err);
781 }
782 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
783         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
784         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
785         uintptr_t ret_ref = 0;
786         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
787         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
788         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
789         ret_ref = (uintptr_t)ret_var.inner;
790         if (ret_var.is_owned) {
791                 ret_ref |= 1;
792         }
793         return ret_ref;
794 }
795
796 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
797 CHECK(owner->result_ok);
798         return ShutdownScript_clone(&*owner->contents.result);
799 }
800 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
801         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
802         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
803         uintptr_t ret_ref = 0;
804         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
805         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
807         ret_ref = (uintptr_t)ret_var.inner;
808         if (ret_var.is_owned) {
809                 ret_ref |= 1;
810         }
811         return ret_ref;
812 }
813
814 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
815 CHECK(!owner->result_ok);
816         return InvalidShutdownScript_clone(&*owner->contents.err);
817 }
818 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
819         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
820         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
821         uintptr_t ret_ref = 0;
822         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
823         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
825         ret_ref = (uintptr_t)ret_var.inner;
826         if (ret_var.is_owned) {
827                 ret_ref |= 1;
828         }
829         return ret_ref;
830 }
831
832 typedef struct LDKType_JCalls {
833         atomic_size_t refcnt;
834         uint32_t instance_ptr;
835 } LDKType_JCalls;
836 static void LDKType_JCalls_free(void* this_arg) {
837         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
838         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
839                 FREE(j_calls);
840         }
841 }
842 uint16_t type_id_LDKType_jcall(const void* this_arg) {
843         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
844         return js_invoke_function_0(j_calls->instance_ptr, 0);
845 }
846 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
847         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
848         jstring ret = (jstring)js_invoke_function_0(j_calls->instance_ptr, 1);
849         LDKStr ret_conv = str_ref_to_owned_c(ret);
850         return ret_conv;
851 }
852 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
853         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
854         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 2);
855         LDKCVec_u8Z ret_ref;
856         ret_ref.datalen = ret->arr_len;
857         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
858         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
859         return ret_ref;
860 }
861 static void LDKType_JCalls_cloned(LDKType* new_obj) {
862         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
863         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
864 }
865 static inline LDKType LDKType_init (JSValue o) {
866         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
867         atomic_init(&calls->refcnt, 1);
868         calls->instance_ptr = o;
869
870         LDKType ret = {
871                 .this_arg = (void*) calls,
872                 .type_id = type_id_LDKType_jcall,
873                 .debug_str = debug_str_LDKType_jcall,
874                 .write = write_LDKType_jcall,
875                 .cloned = LDKType_JCalls_cloned,
876                 .free = LDKType_JCalls_free,
877         };
878         return ret;
879 }
880 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
881         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
882         *res_ptr = LDKType_init(o);
883         return (long)res_ptr;
884 }
885 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
886         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
887         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
888         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
889         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
890         return ret_val;
891 }
892
893 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
894         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
895         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
896         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
897         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
898         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
899         Str_free(ret_str);
900         return ret_conv;
901 }
902
903 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
904         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
905         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
906         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
907         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
908         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
909         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
910         CVec_u8Z_free(ret_var);
911         return ret_arr;
912 }
913
914 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
915         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
916         switch(obj->tag) {
917                 case LDKCOption_TypeZ_Some: return 0;
918                 case LDKCOption_TypeZ_None: return 1;
919                 default: abort();
920         }
921 }
922 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
923         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
924         assert(obj->tag == LDKCOption_TypeZ_Some);
925                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
926                         *some_ret = Type_clone(&obj->some);
927         return (uintptr_t)some_ret;
928 }
929 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
930 CHECK(owner->result_ok);
931         return COption_TypeZ_clone(&*owner->contents.result);
932 }
933 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
934         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
935         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
936         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
937         uintptr_t ret_ref = (uintptr_t)ret_copy;
938         return ret_ref;
939 }
940
941 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
942 CHECK(!owner->result_ok);
943         return DecodeError_clone(&*owner->contents.err);
944 }
945 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
946         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
947         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
948         uintptr_t ret_ref = 0;
949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
952         ret_ref = (uintptr_t)ret_var.inner;
953         if (ret_var.is_owned) {
954                 ret_ref |= 1;
955         }
956         return ret_ref;
957 }
958
959 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
960 CHECK(owner->result_ok);
961         return *owner->contents.result;
962 }
963 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
964         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
965         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
966         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
967         return ret_conv;
968 }
969
970 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
971 CHECK(!owner->result_ok);
972         return *owner->contents.err;
973 }
974 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
975         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
976         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
977         return ret_conv;
978 }
979
980 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
981 CHECK(owner->result_ok);
982         return ChannelMonitorUpdate_clone(&*owner->contents.result);
983 }
984 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
985         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
986         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
987         uintptr_t ret_ref = 0;
988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
991         ret_ref = (uintptr_t)ret_var.inner;
992         if (ret_var.is_owned) {
993                 ret_ref |= 1;
994         }
995         return ret_ref;
996 }
997
998 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
999 CHECK(!owner->result_ok);
1000         return DecodeError_clone(&*owner->contents.err);
1001 }
1002 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
1003         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
1004         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
1005         uintptr_t ret_ref = 0;
1006         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1007         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1009         ret_ref = (uintptr_t)ret_var.inner;
1010         if (ret_var.is_owned) {
1011                 ret_ref |= 1;
1012         }
1013         return ret_ref;
1014 }
1015
1016 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
1017         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1018         switch(obj->tag) {
1019                 case LDKMonitorEvent_HTLCEvent: return 0;
1020                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
1021                 case LDKMonitorEvent_UpdateCompleted: return 2;
1022                 case LDKMonitorEvent_UpdateFailed: return 3;
1023                 default: abort();
1024         }
1025 }
1026 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
1027         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1028         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
1029                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1030                         uintptr_t htlc_event_ref = 0;
1031                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1032                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1033                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1034                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
1035         return htlc_event_ref;
1036 }
1037 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
1038         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1039         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
1040                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1041                         uintptr_t commitment_tx_confirmed_ref = 0;
1042                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1043                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1044                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1045                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
1046         return commitment_tx_confirmed_ref;
1047 }
1048 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
1049         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1050         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1051                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1052                         uintptr_t funding_txo_ref = 0;
1053                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1054                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1055                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1056                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
1057         return funding_txo_ref;
1058 }
1059 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
1060         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1061         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1062         return obj->update_completed.monitor_update_id;
1063 }
1064 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
1065         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1066         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
1067                         LDKOutPoint update_failed_var = obj->update_failed;
1068                         uintptr_t update_failed_ref = 0;
1069                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1070                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1071                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1072                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
1073         return update_failed_ref;
1074 }
1075 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
1076         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
1077         switch(obj->tag) {
1078                 case LDKCOption_MonitorEventZ_Some: return 0;
1079                 case LDKCOption_MonitorEventZ_None: return 1;
1080                 default: abort();
1081         }
1082 }
1083 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
1084         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
1085         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
1086                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
1087         return some_ref;
1088 }
1089 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
1090 CHECK(owner->result_ok);
1091         return COption_MonitorEventZ_clone(&*owner->contents.result);
1092 }
1093 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
1094         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
1095         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
1096         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
1097         uintptr_t ret_ref = (uintptr_t)ret_copy;
1098         return ret_ref;
1099 }
1100
1101 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
1102 CHECK(!owner->result_ok);
1103         return DecodeError_clone(&*owner->contents.err);
1104 }
1105 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
1106         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
1107         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
1108         uintptr_t ret_ref = 0;
1109         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1110         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1112         ret_ref = (uintptr_t)ret_var.inner;
1113         if (ret_var.is_owned) {
1114                 ret_ref |= 1;
1115         }
1116         return ret_ref;
1117 }
1118
1119 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
1120 CHECK(owner->result_ok);
1121         return HTLCUpdate_clone(&*owner->contents.result);
1122 }
1123 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
1124         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
1125         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
1126         uintptr_t ret_ref = 0;
1127         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1128         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1130         ret_ref = (uintptr_t)ret_var.inner;
1131         if (ret_var.is_owned) {
1132                 ret_ref |= 1;
1133         }
1134         return ret_ref;
1135 }
1136
1137 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
1138 CHECK(!owner->result_ok);
1139         return DecodeError_clone(&*owner->contents.err);
1140 }
1141 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
1142         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
1143         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
1144         uintptr_t ret_ref = 0;
1145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1148         ret_ref = (uintptr_t)ret_var.inner;
1149         if (ret_var.is_owned) {
1150                 ret_ref |= 1;
1151         }
1152         return ret_ref;
1153 }
1154
1155 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1156 CHECK(owner->result_ok);
1157         return *owner->contents.result;
1158 }
1159 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
1160         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
1161         CResult_NoneNoneZ_get_ok(owner_conv);
1162 }
1163
1164 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1165 CHECK(!owner->result_ok);
1166         return *owner->contents.err;
1167 }
1168 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
1169         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
1170         CResult_NoneNoneZ_get_err(owner_conv);
1171 }
1172
1173 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
1174         return OutPoint_clone(&owner->a);
1175 }
1176 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
1177         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
1178         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
1179         uintptr_t ret_ref = 0;
1180         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1181         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1183         ret_ref = (uintptr_t)ret_var.inner;
1184         if (ret_var.is_owned) {
1185                 ret_ref |= 1;
1186         }
1187         return ret_ref;
1188 }
1189
1190 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
1191         return CVec_u8Z_clone(&owner->b);
1192 }
1193 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
1194         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
1195         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
1196         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1197         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1198         CVec_u8Z_free(ret_var);
1199         return ret_arr;
1200 }
1201
1202 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
1203         return owner->a;
1204 }
1205 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
1206         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
1207         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
1208         return ret_val;
1209 }
1210
1211 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
1212         return CVec_u8Z_clone(&owner->b);
1213 }
1214 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
1215         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
1216         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
1217         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1218         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1219         CVec_u8Z_free(ret_var);
1220         return ret_arr;
1221 }
1222
1223 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
1224         return ThirtyTwoBytes_clone(&owner->a);
1225 }
1226 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
1227         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
1228         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
1229         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
1230         return ret_arr;
1231 }
1232
1233 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
1234         return owner->b;
1235 }
1236 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
1237         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
1238         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
1239         uint32_tArray ret_arr = NULL;
1240         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
1241         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
1242         for (size_t v = 0; v < ret_var.datalen; v++) {
1243                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = &ret_var.data[v];
1244                 // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_u32ScriptZ
1245                 ret_arr_ptr[v] = ((uintptr_t)ret_conv_21_conv) | 1;
1246         }
1247         
1248         return ret_arr;
1249 }
1250
1251 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1252         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1253         for (size_t i = 0; i < ret.datalen; i++) {
1254                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1255         }
1256         return ret;
1257 }
1258 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1259         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1260         switch(obj->tag) {
1261                 case LDKPaymentPurpose_InvoicePayment: return 0;
1262                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1263                 default: abort();
1264         }
1265 }
1266 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1267         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1268         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1269                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1270                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1271         return payment_preimage_arr;
1272 }
1273 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1274         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1275         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1276                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1277                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1278         return payment_secret_arr;
1279 }
1280 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1281         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1282         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1283                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1284                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1285         return spontaneous_payment_arr;
1286 }
1287 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1288         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1289         switch(obj->tag) {
1290                 case LDKCOption_u64Z_Some: return 0;
1291                 case LDKCOption_u64Z_None: return 1;
1292                 default: abort();
1293         }
1294 }
1295 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1296         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1297         assert(obj->tag == LDKCOption_u64Z_Some);
1298         return obj->some;
1299 }
1300 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1301         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1302         switch(obj->tag) {
1303                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1304                 case LDKNetworkUpdate_ChannelClosed: return 1;
1305                 case LDKNetworkUpdate_NodeFailure: return 2;
1306                 default: abort();
1307         }
1308 }
1309 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1310         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1311         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1312                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1313                         uintptr_t msg_ref = 0;
1314                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1315                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1316                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1317                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1318         return msg_ref;
1319 }
1320 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id(uint32_t ptr) {
1321         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1322         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1323         return obj->channel_closed.short_channel_id;
1324 }
1325 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent(uint32_t ptr) {
1326         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1327         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1328         return obj->channel_closed.is_permanent;
1329 }
1330 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1331         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1332         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1333                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1334                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1335         return node_id_arr;
1336 }
1337 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1338         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1339         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1340         return obj->node_failure.is_permanent;
1341 }
1342 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1343         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1344         switch(obj->tag) {
1345                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1346                 case LDKCOption_NetworkUpdateZ_None: return 1;
1347                 default: abort();
1348         }
1349 }
1350 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1351         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1352         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1353                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
1354         return some_ref;
1355 }
1356 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1357         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1358         for (size_t i = 0; i < ret.datalen; i++) {
1359                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1360         }
1361         return ret;
1362 }
1363 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1364         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1365         switch(obj->tag) {
1366                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1367                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1368                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1369                 default: abort();
1370         }
1371 }
1372 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1373         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1374         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1375                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1376                         uintptr_t outpoint_ref = 0;
1377                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1378                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1379                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1380                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1381         return outpoint_ref;
1382 }
1383 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1384         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1385         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1386                         uintptr_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1387         return (uintptr_t)output_ref;
1388 }
1389 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1390         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1391         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1392                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1393                         uintptr_t delayed_payment_output_ref = 0;
1394                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1395                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1396                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1397                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1398         return delayed_payment_output_ref;
1399 }
1400 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1401         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1402         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1403                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1404                         uintptr_t static_payment_output_ref = 0;
1405                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1406                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1407                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1408                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1409         return static_payment_output_ref;
1410 }
1411 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1412         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1413         for (size_t i = 0; i < ret.datalen; i++) {
1414                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1415         }
1416         return ret;
1417 }
1418 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1419         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1420         switch(obj->tag) {
1421                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1422                 case LDKClosureReason_HolderForceClosed: return 1;
1423                 case LDKClosureReason_CooperativeClosure: return 2;
1424                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1425                 case LDKClosureReason_FundingTimedOut: return 4;
1426                 case LDKClosureReason_ProcessingError: return 5;
1427                 case LDKClosureReason_DisconnectedPeer: return 6;
1428                 case LDKClosureReason_OutdatedChannelManager: return 7;
1429                 default: abort();
1430         }
1431 }
1432 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1433         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1434         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1435                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1436                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1437         return peer_msg_conv;
1438 }
1439 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1440         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1441         assert(obj->tag == LDKClosureReason_ProcessingError);
1442                         LDKStr err_str = obj->processing_error.err;
1443                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1444         return err_conv;
1445 }
1446 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1447         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1448         switch(obj->tag) {
1449                 case LDKEvent_FundingGenerationReady: return 0;
1450                 case LDKEvent_PaymentReceived: return 1;
1451                 case LDKEvent_PaymentSent: return 2;
1452                 case LDKEvent_PaymentPathFailed: return 3;
1453                 case LDKEvent_PaymentFailed: return 4;
1454                 case LDKEvent_PendingHTLCsForwardable: return 5;
1455                 case LDKEvent_SpendableOutputs: return 6;
1456                 case LDKEvent_PaymentForwarded: return 7;
1457                 case LDKEvent_ChannelClosed: return 8;
1458                 case LDKEvent_DiscardFunding: return 9;
1459                 case LDKEvent_PaymentPathSuccessful: return 10;
1460                 default: abort();
1461         }
1462 }
1463 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1464         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1465         assert(obj->tag == LDKEvent_FundingGenerationReady);
1466                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1467                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1468         return temporary_channel_id_arr;
1469 }
1470 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1471         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1472         assert(obj->tag == LDKEvent_FundingGenerationReady);
1473         return obj->funding_generation_ready.channel_value_satoshis;
1474 }
1475 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1476         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1477         assert(obj->tag == LDKEvent_FundingGenerationReady);
1478                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1479                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1480                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1481         return output_script_arr;
1482 }
1483 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1484         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1485         assert(obj->tag == LDKEvent_FundingGenerationReady);
1486         return obj->funding_generation_ready.user_channel_id;
1487 }
1488 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1489         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1490         assert(obj->tag == LDKEvent_PaymentReceived);
1491                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1492                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1493         return payment_hash_arr;
1494 }
1495 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amt"))) TS_LDKEvent_PaymentReceived_get_amt(uint32_t ptr) {
1496         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1497         assert(obj->tag == LDKEvent_PaymentReceived);
1498         return obj->payment_received.amt;
1499 }
1500 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1501         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1502         assert(obj->tag == LDKEvent_PaymentReceived);
1503                         uintptr_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1504         return purpose_ref;
1505 }
1506 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1507         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1508         assert(obj->tag == LDKEvent_PaymentSent);
1509                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1510                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1511         return payment_id_arr;
1512 }
1513 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1514         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1515         assert(obj->tag == LDKEvent_PaymentSent);
1516                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1517                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1518         return payment_preimage_arr;
1519 }
1520 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1521         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1522         assert(obj->tag == LDKEvent_PaymentSent);
1523                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1524                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1525         return payment_hash_arr;
1526 }
1527 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1528         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1529         assert(obj->tag == LDKEvent_PaymentSent);
1530                         uintptr_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1531         return fee_paid_msat_ref;
1532 }
1533 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1534         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1535         assert(obj->tag == LDKEvent_PaymentPathFailed);
1536                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1537                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1538         return payment_id_arr;
1539 }
1540 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1541         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1542         assert(obj->tag == LDKEvent_PaymentPathFailed);
1543                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1544                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1545         return payment_hash_arr;
1546 }
1547 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1548         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1549         assert(obj->tag == LDKEvent_PaymentPathFailed);
1550         return obj->payment_path_failed.rejected_by_dest;
1551 }
1552 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1553         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1554         assert(obj->tag == LDKEvent_PaymentPathFailed);
1555                         uintptr_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1556         return network_update_ref;
1557 }
1558 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1559         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1560         assert(obj->tag == LDKEvent_PaymentPathFailed);
1561         return obj->payment_path_failed.all_paths_failed;
1562 }
1563 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1564         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1565         assert(obj->tag == LDKEvent_PaymentPathFailed);
1566                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1567                         uint32_tArray path_arr = NULL;
1568                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1569                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1570                         for (size_t k = 0; k < path_var.datalen; k++) {
1571                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1572                                 uintptr_t path_conv_10_ref = 0;
1573                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1574                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1575                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1576                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1577                                 path_arr_ptr[k] = path_conv_10_ref;
1578                         }
1579                         
1580         return path_arr;
1581 }
1582 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1583         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1584         assert(obj->tag == LDKEvent_PaymentPathFailed);
1585                         uintptr_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1586         return short_channel_id_ref;
1587 }
1588 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1589         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1590         assert(obj->tag == LDKEvent_PaymentPathFailed);
1591                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1592                         uintptr_t retry_ref = 0;
1593                         if ((uintptr_t)retry_var.inner > 4096) {
1594                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1595                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1596                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1597                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1598                         }
1599         return retry_ref;
1600 }
1601 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1602         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1603         assert(obj->tag == LDKEvent_PaymentFailed);
1604                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1605                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1606         return payment_id_arr;
1607 }
1608 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1609         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1610         assert(obj->tag == LDKEvent_PaymentFailed);
1611                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1612                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1613         return payment_hash_arr;
1614 }
1615 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1616         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1617         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1618         return obj->pending_htl_cs_forwardable.time_forwardable;
1619 }
1620 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1621         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1622         assert(obj->tag == LDKEvent_SpendableOutputs);
1623                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1624                         uint32_tArray outputs_arr = NULL;
1625                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1626                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 4);
1627                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1628                                 uintptr_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1629                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1630                         }
1631                         
1632         return outputs_arr;
1633 }
1634 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1635         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1636         assert(obj->tag == LDKEvent_PaymentForwarded);
1637                         uintptr_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1638         return fee_earned_msat_ref;
1639 }
1640 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1641         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1642         assert(obj->tag == LDKEvent_PaymentForwarded);
1643         return obj->payment_forwarded.claim_from_onchain_tx;
1644 }
1645 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1646         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1647         assert(obj->tag == LDKEvent_ChannelClosed);
1648                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1649                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1650         return channel_id_arr;
1651 }
1652 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1653         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1654         assert(obj->tag == LDKEvent_ChannelClosed);
1655         return obj->channel_closed.user_channel_id;
1656 }
1657 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1658         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1659         assert(obj->tag == LDKEvent_ChannelClosed);
1660                         uintptr_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1661         return reason_ref;
1662 }
1663 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1664         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1665         assert(obj->tag == LDKEvent_DiscardFunding);
1666                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1667                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
1668         return channel_id_arr;
1669 }
1670 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
1671         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1672         assert(obj->tag == LDKEvent_DiscardFunding);
1673                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1674                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
1675                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
1676         return transaction_arr;
1677 }
1678 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1679         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1680         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1681                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1682                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1683         return payment_id_arr;
1684 }
1685 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1686         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1687         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1688                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1689                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1690         return payment_hash_arr;
1691 }
1692 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1693         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1694         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1695                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1696                         uint32_tArray path_arr = NULL;
1697                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1698                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1699                         for (size_t k = 0; k < path_var.datalen; k++) {
1700                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1701                                 uintptr_t path_conv_10_ref = 0;
1702                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1703                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1704                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1705                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1706                                 path_arr_ptr[k] = path_conv_10_ref;
1707                         }
1708                         
1709         return path_arr;
1710 }
1711 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
1712         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
1713         for (size_t i = 0; i < ret.datalen; i++) {
1714                 ret.data[i] = Event_clone(&orig->data[i]);
1715         }
1716         return ret;
1717 }
1718 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1719         return owner->a;
1720 }
1721 intptr_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
1722         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1723         intptr_t ret_val = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1724         return ret_val;
1725 }
1726
1727 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1728         return owner->b;
1729 }
1730 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
1731         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1732         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1733         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1734         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1735         return ret_arr;
1736 }
1737
1738 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1739         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1740         for (size_t i = 0; i < ret.datalen; i++) {
1741                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1742         }
1743         return ret;
1744 }
1745 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
1746         return owner->a;
1747 }
1748 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
1749         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
1750         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
1751         return ret_val;
1752 }
1753
1754 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
1755         return TxOut_clone(&owner->b);
1756 }
1757 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
1758         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
1759         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1760         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
1761         return (uintptr_t)ret_ref;
1762 }
1763
1764 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
1765         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
1766         for (size_t i = 0; i < ret.datalen; i++) {
1767                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
1768         }
1769         return ret;
1770 }
1771 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
1772         return ThirtyTwoBytes_clone(&owner->a);
1773 }
1774 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
1775         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
1776         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
1777         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
1778         return ret_arr;
1779 }
1780
1781 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
1782         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
1783 }
1784 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
1785         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
1786         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
1787         uint32_tArray ret_arr = NULL;
1788         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
1789         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
1790         for (size_t u = 0; u < ret_var.datalen; u++) {
1791                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
1792                 *ret_conv_20_conv = ret_var.data[u];
1793                 ret_arr_ptr[u] = ((uintptr_t)ret_conv_20_conv);
1794         }
1795         
1796         FREE(ret_var.data);
1797         return ret_arr;
1798 }
1799
1800 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
1801         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 };
1802         for (size_t i = 0; i < ret.datalen; i++) {
1803                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
1804         }
1805         return ret;
1806 }
1807 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1808         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1809         for (size_t i = 0; i < ret.datalen; i++) {
1810                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1811         }
1812         return ret;
1813 }
1814 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
1815         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1816         switch(obj->tag) {
1817                 case LDKBalance_ClaimableOnChannelClose: return 0;
1818                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
1819                 case LDKBalance_ContentiousClaimable: return 2;
1820                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
1821                 default: abort();
1822         }
1823 }
1824 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
1825         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1826         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
1827         return obj->claimable_on_channel_close.claimable_amount_satoshis;
1828 }
1829 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
1830         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1831         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
1832         return obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
1833 }
1834 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
1835         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1836         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
1837         return obj->claimable_awaiting_confirmations.confirmation_height;
1838 }
1839 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
1840         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1841         assert(obj->tag == LDKBalance_ContentiousClaimable);
1842         return obj->contentious_claimable.claimable_amount_satoshis;
1843 }
1844 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
1845         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1846         assert(obj->tag == LDKBalance_ContentiousClaimable);
1847         return obj->contentious_claimable.timeout_height;
1848 }
1849 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
1850         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1851         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
1852         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
1853 }
1854 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
1855         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1856         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
1857         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
1858 }
1859 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
1860         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
1861         for (size_t i = 0; i < ret.datalen; i++) {
1862                 ret.data[i] = Balance_clone(&orig->data[i]);
1863         }
1864         return ret;
1865 }
1866 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
1867         return owner->a;
1868 }
1869 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
1870         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
1871         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
1872         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
1873         return ret_arr;
1874 }
1875
1876 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
1877         return owner->b;
1878 }
1879 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
1880         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
1881         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
1882         ptrArray ret_arr = NULL;
1883         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
1884         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
1885         for (size_t m = 0; m < ret_var.datalen; m++) {
1886                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
1887                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
1888                 ret_arr_ptr[m] = ret_conv_12_arr;
1889         }
1890         
1891         return ret_arr;
1892 }
1893
1894 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
1895 CHECK(owner->result_ok);
1896         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
1897 }
1898 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
1899         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
1900         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1901         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
1902         return ((uintptr_t)ret_conv);
1903 }
1904
1905 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
1906 CHECK(!owner->result_ok);
1907         return *owner->contents.err;
1908 }
1909 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
1910         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
1911         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
1912 }
1913
1914 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
1915 CHECK(owner->result_ok);
1916         return *owner->contents.result;
1917 }
1918 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
1919         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
1920         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
1921         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
1922         return ret_arr;
1923 }
1924
1925 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
1926 CHECK(!owner->result_ok);
1927         return *owner->contents.err;
1928 }
1929 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
1930         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
1931         CResult_SignatureNoneZ_get_err(owner_conv);
1932 }
1933
1934 typedef struct LDKBaseSign_JCalls {
1935         atomic_size_t refcnt;
1936         uint32_t instance_ptr;
1937 } LDKBaseSign_JCalls;
1938 static void LDKBaseSign_JCalls_free(void* this_arg) {
1939         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1940         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1941                 FREE(j_calls);
1942         }
1943 }
1944 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1945         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1946         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 3, (uint32_t)idx);
1947         LDKPublicKey ret_ref;
1948         CHECK(ret->arr_len == 33);
1949         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
1950         return ret_ref;
1951 }
1952 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1953         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1954         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 4, (uint32_t)idx);
1955         LDKThirtyTwoBytes ret_ref;
1956         CHECK(ret->arr_len == 32);
1957         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
1958         return ret_ref;
1959 }
1960 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
1961         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1962         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
1963         uintptr_t holder_tx_ref = 0;
1964         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
1965         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1966         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1967         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
1968         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
1969         if (holder_tx_var.is_owned) {
1970                 holder_tx_ref |= 1;
1971         }
1972         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 5, (uint32_t)holder_tx_ref);
1973         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
1974         CHECK_ACCESS(ret_ptr);
1975         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
1976         FREE((void*)ret);
1977         return ret_conv;
1978 }
1979 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1980         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1981         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 6);
1982         LDKThirtyTwoBytes ret_ref;
1983         CHECK(ret->arr_len == 32);
1984         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
1985         return ret_ref;
1986 }
1987 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1988         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1989         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1990         uintptr_t commitment_tx_ref = 0;
1991         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1992         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1993         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1994         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
1995         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
1996         if (commitment_tx_var.is_owned) {
1997                 commitment_tx_ref |= 1;
1998         }
1999         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 7, (uint32_t)commitment_tx_ref);
2000         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2001         CHECK_ACCESS(ret_ptr);
2002         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2003         FREE((void*)ret);
2004         return ret_conv;
2005 }
2006 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
2007         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2008         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
2009         memcpy(secret_arr->elems, *secret, 32);
2010         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 8, (uint32_t)idx, (uint32_t)secret_arr);
2011         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2012         CHECK_ACCESS(ret_ptr);
2013         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2014         FREE((void*)ret);
2015         return ret_conv;
2016 }
2017 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2018         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2019         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2020         uintptr_t commitment_tx_ref = 0;
2021         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2022         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2023         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2024         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
2025         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
2026         if (commitment_tx_var.is_owned) {
2027                 commitment_tx_ref |= 1;
2028         }
2029         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 9, (uint32_t)commitment_tx_ref);
2030         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2031         CHECK_ACCESS(ret_ptr);
2032         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2033         FREE((void*)ret);
2034         return ret_conv;
2035 }
2036 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]) {
2037         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2038         LDKTransaction justice_tx_var = justice_tx;
2039         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
2040         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
2041         Transaction_free(justice_tx_var);
2042         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
2043         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
2044         uint32_t ret = js_invoke_function_4(j_calls->instance_ptr, 10, (uint32_t)justice_tx_arr, (uint32_t)input, (uint32_t)amount, (uint32_t)per_commitment_key_arr);
2045         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2046         CHECK_ACCESS(ret_ptr);
2047         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2048         FREE((void*)ret);
2049         return ret_conv;
2050 }
2051 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) {
2052         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2053         LDKTransaction justice_tx_var = justice_tx;
2054         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
2055         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
2056         Transaction_free(justice_tx_var);
2057         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
2058         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
2059         LDKHTLCOutputInCommitment htlc_var = *htlc;
2060         uintptr_t htlc_ref = 0;
2061         htlc_var = HTLCOutputInCommitment_clone(htlc);
2062         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2063         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2064         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
2065         htlc_ref = (uintptr_t)htlc_var.inner;
2066         if (htlc_var.is_owned) {
2067                 htlc_ref |= 1;
2068         }
2069         uint32_t ret = js_invoke_function_5(j_calls->instance_ptr, 11, (uint32_t)justice_tx_arr, (uint32_t)input, (uint32_t)amount, (uint32_t)per_commitment_key_arr, (uint32_t)htlc_ref);
2070         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2071         CHECK_ACCESS(ret_ptr);
2072         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2073         FREE((void*)ret);
2074         return ret_conv;
2075 }
2076 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) {
2077         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2078         LDKTransaction htlc_tx_var = htlc_tx;
2079         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
2080         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
2081         Transaction_free(htlc_tx_var);
2082         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
2083         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
2084         LDKHTLCOutputInCommitment htlc_var = *htlc;
2085         uintptr_t htlc_ref = 0;
2086         htlc_var = HTLCOutputInCommitment_clone(htlc);
2087         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2088         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2089         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
2090         htlc_ref = (uintptr_t)htlc_var.inner;
2091         if (htlc_var.is_owned) {
2092                 htlc_ref |= 1;
2093         }
2094         uint32_t ret = js_invoke_function_5(j_calls->instance_ptr, 12, (uint32_t)htlc_tx_arr, (uint32_t)input, (uint32_t)amount, (uint32_t)per_commitment_point_arr, (uint32_t)htlc_ref);
2095         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2096         CHECK_ACCESS(ret_ptr);
2097         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2098         FREE((void*)ret);
2099         return ret_conv;
2100 }
2101 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
2102         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2103         LDKClosingTransaction closing_tx_var = *closing_tx;
2104         uintptr_t closing_tx_ref = 0;
2105         closing_tx_var = ClosingTransaction_clone(closing_tx);
2106         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2107         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2108         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
2109         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
2110         if (closing_tx_var.is_owned) {
2111                 closing_tx_ref |= 1;
2112         }
2113         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 13, (uint32_t)closing_tx_ref);
2114         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2115         CHECK_ACCESS(ret_ptr);
2116         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2117         FREE((void*)ret);
2118         return ret_conv;
2119 }
2120 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2121         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2122         LDKUnsignedChannelAnnouncement msg_var = *msg;
2123         uintptr_t msg_ref = 0;
2124         msg_var = UnsignedChannelAnnouncement_clone(msg);
2125         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2126         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2127         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2128         msg_ref = (uintptr_t)msg_var.inner;
2129         if (msg_var.is_owned) {
2130                 msg_ref |= 1;
2131         }
2132         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 14, (uint32_t)msg_ref);
2133         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2134         CHECK_ACCESS(ret_ptr);
2135         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2136         FREE((void*)ret);
2137         return ret_conv;
2138 }
2139 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2140         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2141         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2142         uintptr_t channel_parameters_ref = 0;
2143         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2144         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2145         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2146         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
2147         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
2148         if (channel_parameters_var.is_owned) {
2149                 channel_parameters_ref |= 1;
2150         }
2151         js_invoke_function_1(j_calls->instance_ptr, 15, (uint32_t)channel_parameters_ref);
2152 }
2153 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
2154         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
2155         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2156 }
2157 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
2158         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2159         atomic_init(&calls->refcnt, 1);
2160         calls->instance_ptr = o;
2161
2162         LDKChannelPublicKeys pubkeys_conv;
2163         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2164         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2165         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2166
2167         LDKBaseSign ret = {
2168                 .this_arg = (void*) calls,
2169                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2170                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2171                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
2172                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2173                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2174                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
2175                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2176                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2177                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2178                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2179                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2180                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2181                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2182                 .free = LDKBaseSign_JCalls_free,
2183                 .pubkeys = pubkeys_conv,
2184                 .set_pubkeys = NULL,
2185         };
2186         return ret;
2187 }
2188 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
2189         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2190         *res_ptr = LDKBaseSign_init(o, pubkeys);
2191         return (long)res_ptr;
2192 }
2193 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
2194         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2195         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2196         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2197         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
2198         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
2199         return ret_arr;
2200 }
2201
2202 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
2203         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2204         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2205         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2206         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
2207         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
2208         return ret_arr;
2209 }
2210
2211 uint32_t  __attribute__((export_name("TS_BaseSign_validate_holder_commitment"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx) {
2212         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2213         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2214         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2215         LDKHolderCommitmentTransaction holder_tx_conv;
2216         holder_tx_conv.inner = (void*)(holder_tx & (~1));
2217         holder_tx_conv.is_owned = false;
2218         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
2219         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2220         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
2221         return (uintptr_t)ret_conv;
2222 }
2223
2224 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
2225         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2226         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2227         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2228         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
2229         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
2230         return ret_arr;
2231 }
2232
2233 uint32_t  __attribute__((export_name("TS_BaseSign_sign_counterparty_commitment"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
2234         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2235         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2236         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2237         LDKCommitmentTransaction commitment_tx_conv;
2238         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2239         commitment_tx_conv.is_owned = false;
2240         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2241         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2242         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2243         return (uintptr_t)ret_conv;
2244 }
2245
2246 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) {
2247         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2248         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2249         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2250         unsigned char secret_arr[32];
2251         CHECK(secret->arr_len == 32);
2252         memcpy(secret_arr, secret->elems, 32); FREE(secret);
2253         unsigned char (*secret_ref)[32] = &secret_arr;
2254         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2255         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
2256         return (uintptr_t)ret_conv;
2257 }
2258
2259 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) {
2260         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2261         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2262         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2263         LDKHolderCommitmentTransaction commitment_tx_conv;
2264         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2265         commitment_tx_conv.is_owned = false;
2266         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2267         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2268         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2269         return (uintptr_t)ret_conv;
2270 }
2271
2272 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, intptr_t input, int64_t amount, int8_tArray per_commitment_key) {
2273         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2274         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2275         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2276         LDKTransaction justice_tx_ref;
2277         justice_tx_ref.datalen = justice_tx->arr_len;
2278         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2279         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
2280         justice_tx_ref.data_is_owned = true;
2281         unsigned char per_commitment_key_arr[32];
2282         CHECK(per_commitment_key->arr_len == 32);
2283         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
2284         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2285         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2286         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2287         return (uintptr_t)ret_conv;
2288 }
2289
2290 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, intptr_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
2291         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2292         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2293         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2294         LDKTransaction justice_tx_ref;
2295         justice_tx_ref.datalen = justice_tx->arr_len;
2296         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2297         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
2298         justice_tx_ref.data_is_owned = true;
2299         unsigned char per_commitment_key_arr[32];
2300         CHECK(per_commitment_key->arr_len == 32);
2301         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
2302         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2303         LDKHTLCOutputInCommitment htlc_conv;
2304         htlc_conv.inner = (void*)(htlc & (~1));
2305         htlc_conv.is_owned = false;
2306         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2307         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2308         *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);
2309         return (uintptr_t)ret_conv;
2310 }
2311
2312 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, intptr_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
2313         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2314         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2315         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2316         LDKTransaction htlc_tx_ref;
2317         htlc_tx_ref.datalen = htlc_tx->arr_len;
2318         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2319         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
2320         htlc_tx_ref.data_is_owned = true;
2321         LDKPublicKey per_commitment_point_ref;
2322         CHECK(per_commitment_point->arr_len == 33);
2323         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
2324         LDKHTLCOutputInCommitment htlc_conv;
2325         htlc_conv.inner = (void*)(htlc & (~1));
2326         htlc_conv.is_owned = false;
2327         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2328         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2329         *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);
2330         return (uintptr_t)ret_conv;
2331 }
2332
2333 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
2334         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2335         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2336         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2337         LDKClosingTransaction closing_tx_conv;
2338         closing_tx_conv.inner = (void*)(closing_tx & (~1));
2339         closing_tx_conv.is_owned = false;
2340         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
2341         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2342         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
2343         return (uintptr_t)ret_conv;
2344 }
2345
2346 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
2347         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2348         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2349         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2350         LDKUnsignedChannelAnnouncement msg_conv;
2351         msg_conv.inner = (void*)(msg & (~1));
2352         msg_conv.is_owned = false;
2353         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
2354         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2355         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2356         return (uintptr_t)ret_conv;
2357 }
2358
2359 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
2360         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2361         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2362         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2363         LDKChannelTransactionParameters channel_parameters_conv;
2364         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2365         channel_parameters_conv.is_owned = false;
2366         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
2367         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2368 }
2369
2370 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2371         if (this_arg->set_pubkeys != NULL)
2372                 this_arg->set_pubkeys(this_arg);
2373         return this_arg->pubkeys;
2374 }
2375 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
2376         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2377         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2378         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2379         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2380         uintptr_t ret_ref = 0;
2381         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2382         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2384         ret_ref = (uintptr_t)ret_var.inner;
2385         if (ret_var.is_owned) {
2386                 ret_ref |= 1;
2387         }
2388         return ret_ref;
2389 }
2390
2391 typedef struct LDKSign_JCalls {
2392         atomic_size_t refcnt;
2393         uint32_t instance_ptr;
2394         LDKBaseSign_JCalls* BaseSign;
2395 } LDKSign_JCalls;
2396 static void LDKSign_JCalls_free(void* this_arg) {
2397         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2398         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2399                 FREE(j_calls);
2400         }
2401 }
2402 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2403         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2404         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 16);
2405         LDKCVec_u8Z ret_ref;
2406         ret_ref.datalen = ret->arr_len;
2407         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2408         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
2409         return ret_ref;
2410 }
2411 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2412         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2413         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2414         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2415 }
2416 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
2417         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2418         atomic_init(&calls->refcnt, 1);
2419         calls->instance_ptr = o;
2420
2421         LDKChannelPublicKeys pubkeys_conv;
2422         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2423         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2424         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2425
2426         LDKSign ret = {
2427                 .this_arg = (void*) calls,
2428                 .write = write_LDKSign_jcall,
2429                 .cloned = LDKSign_JCalls_cloned,
2430                 .free = LDKSign_JCalls_free,
2431                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
2432         };
2433         calls->BaseSign = ret.BaseSign.this_arg;
2434         return ret;
2435 }
2436 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
2437         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2438         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
2439         return (long)res_ptr;
2440 }
2441 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
2442         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2443         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2444         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
2445         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2446         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2447         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2448         CVec_u8Z_free(ret_var);
2449         return ret_arr;
2450 }
2451
2452 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
2453         return ThirtyTwoBytes_clone(&owner->a);
2454 }
2455 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
2456         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
2457         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
2458         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
2459         return ret_arr;
2460 }
2461
2462 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
2463         return ChannelMonitor_clone(&owner->b);
2464 }
2465 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
2466         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
2467         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
2468         uintptr_t ret_ref = 0;
2469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2472         ret_ref = (uintptr_t)ret_var.inner;
2473         if (ret_var.is_owned) {
2474                 ret_ref |= 1;
2475         }
2476         return ret_ref;
2477 }
2478
2479 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
2480 CHECK(owner->result_ok);
2481         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
2482 }
2483 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
2484         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
2485         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2486         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
2487         return ((uintptr_t)ret_conv);
2488 }
2489
2490 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
2491 CHECK(!owner->result_ok);
2492         return DecodeError_clone(&*owner->contents.err);
2493 }
2494 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
2495         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
2496         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
2497         uintptr_t ret_ref = 0;
2498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2501         ret_ref = (uintptr_t)ret_var.inner;
2502         if (ret_var.is_owned) {
2503                 ret_ref |= 1;
2504         }
2505         return ret_ref;
2506 }
2507
2508 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2509 CHECK(owner->result_ok);
2510         return RouteHop_clone(&*owner->contents.result);
2511 }
2512 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
2513         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
2514         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
2515         uintptr_t ret_ref = 0;
2516         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2517         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2519         ret_ref = (uintptr_t)ret_var.inner;
2520         if (ret_var.is_owned) {
2521                 ret_ref |= 1;
2522         }
2523         return ret_ref;
2524 }
2525
2526 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2527 CHECK(!owner->result_ok);
2528         return DecodeError_clone(&*owner->contents.err);
2529 }
2530 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
2531         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
2532         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
2533         uintptr_t ret_ref = 0;
2534         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2535         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2537         ret_ref = (uintptr_t)ret_var.inner;
2538         if (ret_var.is_owned) {
2539                 ret_ref |= 1;
2540         }
2541         return ret_ref;
2542 }
2543
2544 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2545         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2546         for (size_t i = 0; i < ret.datalen; i++) {
2547                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2548         }
2549         return ret;
2550 }
2551 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2552 CHECK(owner->result_ok);
2553         return Route_clone(&*owner->contents.result);
2554 }
2555 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
2556         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
2557         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
2558         uintptr_t ret_ref = 0;
2559         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2560         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2562         ret_ref = (uintptr_t)ret_var.inner;
2563         if (ret_var.is_owned) {
2564                 ret_ref |= 1;
2565         }
2566         return ret_ref;
2567 }
2568
2569 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2570 CHECK(!owner->result_ok);
2571         return DecodeError_clone(&*owner->contents.err);
2572 }
2573 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
2574         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
2575         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
2576         uintptr_t ret_ref = 0;
2577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2580         ret_ref = (uintptr_t)ret_var.inner;
2581         if (ret_var.is_owned) {
2582                 ret_ref |= 1;
2583         }
2584         return ret_ref;
2585 }
2586
2587 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2588 CHECK(owner->result_ok);
2589         return RouteParameters_clone(&*owner->contents.result);
2590 }
2591 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
2592         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
2593         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
2594         uintptr_t ret_ref = 0;
2595         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2596         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2598         ret_ref = (uintptr_t)ret_var.inner;
2599         if (ret_var.is_owned) {
2600                 ret_ref |= 1;
2601         }
2602         return ret_ref;
2603 }
2604
2605 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2606 CHECK(!owner->result_ok);
2607         return DecodeError_clone(&*owner->contents.err);
2608 }
2609 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
2610         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
2611         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
2612         uintptr_t ret_ref = 0;
2613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2616         ret_ref = (uintptr_t)ret_var.inner;
2617         if (ret_var.is_owned) {
2618                 ret_ref |= 1;
2619         }
2620         return ret_ref;
2621 }
2622
2623 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2624         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2625         for (size_t i = 0; i < ret.datalen; i++) {
2626                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2627         }
2628         return ret;
2629 }
2630 static inline struct LDKPayee CResult_PayeeDecodeErrorZ_get_ok(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR owner){
2631 CHECK(owner->result_ok);
2632         return Payee_clone(&*owner->contents.result);
2633 }
2634 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_get_ok"))) TS_CResult_PayeeDecodeErrorZ_get_ok(uint32_t owner) {
2635         LDKCResult_PayeeDecodeErrorZ* owner_conv = (LDKCResult_PayeeDecodeErrorZ*)(owner & ~1);
2636         LDKPayee ret_var = CResult_PayeeDecodeErrorZ_get_ok(owner_conv);
2637         uintptr_t ret_ref = 0;
2638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2641         ret_ref = (uintptr_t)ret_var.inner;
2642         if (ret_var.is_owned) {
2643                 ret_ref |= 1;
2644         }
2645         return ret_ref;
2646 }
2647
2648 static inline struct LDKDecodeError CResult_PayeeDecodeErrorZ_get_err(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR owner){
2649 CHECK(!owner->result_ok);
2650         return DecodeError_clone(&*owner->contents.err);
2651 }
2652 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_get_err"))) TS_CResult_PayeeDecodeErrorZ_get_err(uint32_t owner) {
2653         LDKCResult_PayeeDecodeErrorZ* owner_conv = (LDKCResult_PayeeDecodeErrorZ*)(owner & ~1);
2654         LDKDecodeError ret_var = CResult_PayeeDecodeErrorZ_get_err(owner_conv);
2655         uintptr_t ret_ref = 0;
2656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2659         ret_ref = (uintptr_t)ret_var.inner;
2660         if (ret_var.is_owned) {
2661                 ret_ref |= 1;
2662         }
2663         return ret_ref;
2664 }
2665
2666 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
2667         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
2668         for (size_t i = 0; i < ret.datalen; i++) {
2669                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
2670         }
2671         return ret;
2672 }
2673 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2674 CHECK(owner->result_ok);
2675         return RouteHint_clone(&*owner->contents.result);
2676 }
2677 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
2678         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
2679         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
2680         uintptr_t ret_ref = 0;
2681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2684         ret_ref = (uintptr_t)ret_var.inner;
2685         if (ret_var.is_owned) {
2686                 ret_ref |= 1;
2687         }
2688         return ret_ref;
2689 }
2690
2691 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2692 CHECK(!owner->result_ok);
2693         return DecodeError_clone(&*owner->contents.err);
2694 }
2695 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
2696         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
2697         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
2698         uintptr_t ret_ref = 0;
2699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2702         ret_ref = (uintptr_t)ret_var.inner;
2703         if (ret_var.is_owned) {
2704                 ret_ref |= 1;
2705         }
2706         return ret_ref;
2707 }
2708
2709 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2710 CHECK(owner->result_ok);
2711         return RouteHintHop_clone(&*owner->contents.result);
2712 }
2713 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
2714         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
2715         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
2716         uintptr_t ret_ref = 0;
2717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2720         ret_ref = (uintptr_t)ret_var.inner;
2721         if (ret_var.is_owned) {
2722                 ret_ref |= 1;
2723         }
2724         return ret_ref;
2725 }
2726
2727 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2728 CHECK(!owner->result_ok);
2729         return DecodeError_clone(&*owner->contents.err);
2730 }
2731 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
2732         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
2733         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
2734         uintptr_t ret_ref = 0;
2735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2738         ret_ref = (uintptr_t)ret_var.inner;
2739         if (ret_var.is_owned) {
2740                 ret_ref |= 1;
2741         }
2742         return ret_ref;
2743 }
2744
2745 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2746         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2747         for (size_t i = 0; i < ret.datalen; i++) {
2748                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2749         }
2750         return ret;
2751 }
2752 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2753 CHECK(owner->result_ok);
2754         return Route_clone(&*owner->contents.result);
2755 }
2756 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
2757         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
2758         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
2759         uintptr_t ret_ref = 0;
2760         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2761         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2763         ret_ref = (uintptr_t)ret_var.inner;
2764         if (ret_var.is_owned) {
2765                 ret_ref |= 1;
2766         }
2767         return ret_ref;
2768 }
2769
2770 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2771 CHECK(!owner->result_ok);
2772         return LightningError_clone(&*owner->contents.err);
2773 }
2774 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
2775         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
2776         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
2777         uintptr_t ret_ref = 0;
2778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2781         ret_ref = (uintptr_t)ret_var.inner;
2782         if (ret_var.is_owned) {
2783                 ret_ref |= 1;
2784         }
2785         return ret_ref;
2786 }
2787
2788 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
2789 CHECK(owner->result_ok);
2790         return *owner->contents.result;
2791 }
2792 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
2793         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
2794         CResult_NoneLightningErrorZ_get_ok(owner_conv);
2795 }
2796
2797 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
2798 CHECK(!owner->result_ok);
2799         return LightningError_clone(&*owner->contents.err);
2800 }
2801 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
2802         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
2803         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
2804         uintptr_t ret_ref = 0;
2805         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2806         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2808         ret_ref = (uintptr_t)ret_var.inner;
2809         if (ret_var.is_owned) {
2810                 ret_ref |= 1;
2811         }
2812         return ret_ref;
2813 }
2814
2815 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
2816         return owner->a;
2817 }
2818 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
2819         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
2820         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
2821         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
2822         return ret_arr;
2823 }
2824
2825 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
2826         return Type_clone(&owner->b);
2827 }
2828 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
2829         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
2830         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
2831         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
2832         return (uintptr_t)ret_ret;
2833 }
2834
2835 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
2836         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
2837         for (size_t i = 0; i < ret.datalen; i++) {
2838                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
2839         }
2840         return ret;
2841 }
2842 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
2843         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2844         switch(obj->tag) {
2845                 case LDKErrorAction_DisconnectPeer: return 0;
2846                 case LDKErrorAction_IgnoreError: return 1;
2847                 case LDKErrorAction_IgnoreAndLog: return 2;
2848                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
2849                 case LDKErrorAction_SendErrorMessage: return 4;
2850                 default: abort();
2851         }
2852 }
2853 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
2854         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2855         assert(obj->tag == LDKErrorAction_DisconnectPeer);
2856                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2857                         uintptr_t msg_ref = 0;
2858                         if ((uintptr_t)msg_var.inner > 4096) {
2859                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2860                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2861                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2862                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2863                         }
2864         return msg_ref;
2865 }
2866 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
2867         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2868         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
2869                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
2870         return ignore_and_log_conv;
2871 }
2872 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
2873         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2874         assert(obj->tag == LDKErrorAction_SendErrorMessage);
2875                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2876                         uintptr_t msg_ref = 0;
2877                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2878                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2879                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2880                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2881         return msg_ref;
2882 }
2883 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
2884         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2885         switch(obj->tag) {
2886                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
2887                 case LDKMessageSendEvent_SendOpenChannel: return 1;
2888                 case LDKMessageSendEvent_SendFundingCreated: return 2;
2889                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2890                 case LDKMessageSendEvent_SendFundingLocked: return 4;
2891                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2892                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2893                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2894                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2895                 case LDKMessageSendEvent_SendShutdown: return 9;
2896                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2897                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
2898                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
2899                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2900                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2901                 case LDKMessageSendEvent_HandleError: return 15;
2902                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2903                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2904                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2905                 default: abort();
2906         }
2907 }
2908 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2909         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2910         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2911                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2912                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2913         return node_id_arr;
2914 }
2915 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2916         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2917         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2918                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2919                         uintptr_t msg_ref = 0;
2920                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2921                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2922                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2923                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2924         return msg_ref;
2925 }
2926 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2927         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2928         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2929                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2930                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2931         return node_id_arr;
2932 }
2933 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2934         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2935         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2936                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2937                         uintptr_t msg_ref = 0;
2938                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2939                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2940                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2941                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2942         return msg_ref;
2943 }
2944 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2945         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2946         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2947                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2948                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2949         return node_id_arr;
2950 }
2951 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2952         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2953         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2954                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2955                         uintptr_t msg_ref = 0;
2956                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2957                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2958                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2959                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2960         return msg_ref;
2961 }
2962 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2963         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2964         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2965                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2966                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2967         return node_id_arr;
2968 }
2969 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2970         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2971         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2972                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2973                         uintptr_t msg_ref = 0;
2974                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2975                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2976                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2977                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2978         return msg_ref;
2979 }
2980 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_node_id"))) TS_LDKMessageSendEvent_SendFundingLocked_get_node_id(uint32_t ptr) {
2981         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2982         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2983                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2984                         memcpy(node_id_arr->elems, obj->send_funding_locked.node_id.compressed_form, 33);
2985         return node_id_arr;
2986 }
2987 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_msg"))) TS_LDKMessageSendEvent_SendFundingLocked_get_msg(uint32_t ptr) {
2988         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2989         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2990                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2991                         uintptr_t msg_ref = 0;
2992                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2993                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2994                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2995                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2996         return msg_ref;
2997 }
2998 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2999         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3000         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
3001                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3002                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
3003         return node_id_arr;
3004 }
3005 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
3006         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3007         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
3008                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
3009                         uintptr_t msg_ref = 0;
3010                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3011                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3012                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3013                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3014         return msg_ref;
3015 }
3016 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
3017         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3018         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
3019                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3020                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
3021         return node_id_arr;
3022 }
3023 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
3024         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3025         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
3026                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
3027                         uintptr_t updates_ref = 0;
3028                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3029                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3030                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
3031                         updates_ref = (uintptr_t)updates_var.inner & ~1;
3032         return updates_ref;
3033 }
3034 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
3035         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3036         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
3037                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3038                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
3039         return node_id_arr;
3040 }
3041 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
3042         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3043         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
3044                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
3045                         uintptr_t msg_ref = 0;
3046                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3047                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3048                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3049                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3050         return msg_ref;
3051 }
3052 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
3053         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3054         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
3055                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3056                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
3057         return node_id_arr;
3058 }
3059 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
3060         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3061         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
3062                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
3063                         uintptr_t msg_ref = 0;
3064                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3065                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3066                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3067                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3068         return msg_ref;
3069 }
3070 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
3071         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3072         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
3073                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3074                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
3075         return node_id_arr;
3076 }
3077 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
3078         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3079         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
3080                         LDKShutdown msg_var = obj->send_shutdown.msg;
3081                         uintptr_t msg_ref = 0;
3082                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3083                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3084                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3085                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3086         return msg_ref;
3087 }
3088 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
3089         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3090         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
3091                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3092                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
3093         return node_id_arr;
3094 }
3095 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
3096         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3097         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
3098                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3099                         uintptr_t msg_ref = 0;
3100                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3101                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3102                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3103                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3104         return msg_ref;
3105 }
3106 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
3107         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3108         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
3109                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
3110                         uintptr_t msg_ref = 0;
3111                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3112                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3113                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3114                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3115         return msg_ref;
3116 }
3117 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
3118         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3119         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
3120                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3121                         uintptr_t update_msg_ref = 0;
3122                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3123                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3124                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3125                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
3126         return update_msg_ref;
3127 }
3128 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
3129         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3130         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
3131                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
3132                         uintptr_t msg_ref = 0;
3133                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3134                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3135                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3136                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3137         return msg_ref;
3138 }
3139 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
3140         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3141         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
3142                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3143                         uintptr_t msg_ref = 0;
3144                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3145                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3146                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3147                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3148         return msg_ref;
3149 }
3150 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
3151         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3152         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
3153                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3154                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
3155         return node_id_arr;
3156 }
3157 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
3158         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3159         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
3160                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3161                         uintptr_t msg_ref = 0;
3162                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3163                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3164                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3165                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3166         return msg_ref;
3167 }
3168 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
3169         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3170         assert(obj->tag == LDKMessageSendEvent_HandleError);
3171                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3172                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
3173         return node_id_arr;
3174 }
3175 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
3176         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3177         assert(obj->tag == LDKMessageSendEvent_HandleError);
3178                         uintptr_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
3179         return action_ref;
3180 }
3181 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
3182         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3183         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
3184                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3185                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
3186         return node_id_arr;
3187 }
3188 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
3189         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3190         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
3191                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3192                         uintptr_t msg_ref = 0;
3193                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3194                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3195                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3196                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3197         return msg_ref;
3198 }
3199 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
3200         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3201         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
3202                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3203                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
3204         return node_id_arr;
3205 }
3206 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
3207         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3208         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
3209                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3210                         uintptr_t msg_ref = 0;
3211                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3212                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3213                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3214                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3215         return msg_ref;
3216 }
3217 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
3218         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3219         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
3220                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3221                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
3222         return node_id_arr;
3223 }
3224 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
3225         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3226         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
3227                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3228                         uintptr_t msg_ref = 0;
3229                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3230                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3231                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3232                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3233         return msg_ref;
3234 }
3235 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3236         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3237         for (size_t i = 0; i < ret.datalen; i++) {
3238                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3239         }
3240         return ret;
3241 }
3242 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3243 CHECK(owner->result_ok);
3244         return *owner->contents.result;
3245 }
3246 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
3247         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3248         jboolean ret_val = CResult_boolLightningErrorZ_get_ok(owner_conv);
3249         return ret_val;
3250 }
3251
3252 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3253 CHECK(!owner->result_ok);
3254         return LightningError_clone(&*owner->contents.err);
3255 }
3256 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
3257         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3258         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3259         uintptr_t ret_ref = 0;
3260         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3261         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3263         ret_ref = (uintptr_t)ret_var.inner;
3264         if (ret_var.is_owned) {
3265                 ret_ref |= 1;
3266         }
3267         return ret_ref;
3268 }
3269
3270 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3271         return ChannelAnnouncement_clone(&owner->a);
3272 }
3273 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
3274         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3275         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3276         uintptr_t ret_ref = 0;
3277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3280         ret_ref = (uintptr_t)ret_var.inner;
3281         if (ret_var.is_owned) {
3282                 ret_ref |= 1;
3283         }
3284         return ret_ref;
3285 }
3286
3287 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3288         return ChannelUpdate_clone(&owner->b);
3289 }
3290 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
3291         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3292         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3293         uintptr_t ret_ref = 0;
3294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3297         ret_ref = (uintptr_t)ret_var.inner;
3298         if (ret_var.is_owned) {
3299                 ret_ref |= 1;
3300         }
3301         return ret_ref;
3302 }
3303
3304 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3305         return ChannelUpdate_clone(&owner->c);
3306 }
3307 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
3308         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3309         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3310         uintptr_t ret_ref = 0;
3311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3314         ret_ref = (uintptr_t)ret_var.inner;
3315         if (ret_var.is_owned) {
3316                 ret_ref |= 1;
3317         }
3318         return ret_ref;
3319 }
3320
3321 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3322         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3323         for (size_t i = 0; i < ret.datalen; i++) {
3324                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3325         }
3326         return ret;
3327 }
3328 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3329         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3330         for (size_t i = 0; i < ret.datalen; i++) {
3331                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3332         }
3333         return ret;
3334 }
3335 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
3336 CHECK(owner->result_ok);
3337         return CVec_u8Z_clone(&*owner->contents.result);
3338 }
3339 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
3340         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
3341         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
3342         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3343         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3344         CVec_u8Z_free(ret_var);
3345         return ret_arr;
3346 }
3347
3348 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
3349 CHECK(!owner->result_ok);
3350         return PeerHandleError_clone(&*owner->contents.err);
3351 }
3352 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
3353         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
3354         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
3355         uintptr_t ret_ref = 0;
3356         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3357         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3359         ret_ref = (uintptr_t)ret_var.inner;
3360         if (ret_var.is_owned) {
3361                 ret_ref |= 1;
3362         }
3363         return ret_ref;
3364 }
3365
3366 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
3367 CHECK(owner->result_ok);
3368         return *owner->contents.result;
3369 }
3370 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
3371         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
3372         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
3373 }
3374
3375 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
3376 CHECK(!owner->result_ok);
3377         return PeerHandleError_clone(&*owner->contents.err);
3378 }
3379 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
3380         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
3381         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
3382         uintptr_t ret_ref = 0;
3383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3386         ret_ref = (uintptr_t)ret_var.inner;
3387         if (ret_var.is_owned) {
3388                 ret_ref |= 1;
3389         }
3390         return ret_ref;
3391 }
3392
3393 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
3394 CHECK(owner->result_ok);
3395         return *owner->contents.result;
3396 }
3397 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
3398         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
3399         jboolean ret_val = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
3400         return ret_val;
3401 }
3402
3403 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
3404 CHECK(!owner->result_ok);
3405         return PeerHandleError_clone(&*owner->contents.err);
3406 }
3407 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
3408         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
3409         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
3410         uintptr_t ret_ref = 0;
3411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3414         ret_ref = (uintptr_t)ret_var.inner;
3415         if (ret_var.is_owned) {
3416                 ret_ref |= 1;
3417         }
3418         return ret_ref;
3419 }
3420
3421 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3422 CHECK(owner->result_ok);
3423         return TxOut_clone(&*owner->contents.result);
3424 }
3425 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
3426         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3427         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3428         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3429         return (uintptr_t)ret_ref;
3430 }
3431
3432 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3433 CHECK(!owner->result_ok);
3434         return AccessError_clone(&*owner->contents.err);
3435 }
3436 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
3437         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3438         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
3439         return ret_conv;
3440 }
3441
3442 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3443 CHECK(owner->result_ok);
3444         return *owner->contents.result;
3445 }
3446 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
3447         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3448         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
3449 }
3450
3451 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3452 CHECK(!owner->result_ok);
3453         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
3454 }
3455 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
3456         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3457         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
3458         return ret_conv;
3459 }
3460
3461 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
3462         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
3463         switch(obj->tag) {
3464                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
3465                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
3466                 default: abort();
3467         }
3468 }
3469 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
3470         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
3471         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
3472                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
3473                         *some_conv = obj->some;
3474                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
3475         return ((uintptr_t)some_conv);
3476 }
3477 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
3478         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
3479         switch(obj->tag) {
3480                 case LDKCOption_ClosureReasonZ_Some: return 0;
3481                 case LDKCOption_ClosureReasonZ_None: return 1;
3482                 default: abort();
3483         }
3484 }
3485 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
3486         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
3487         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
3488                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
3489         return some_ref;
3490 }
3491 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
3492 CHECK(owner->result_ok);
3493         return COption_ClosureReasonZ_clone(&*owner->contents.result);
3494 }
3495 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
3496         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
3497         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
3498         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
3499         uintptr_t ret_ref = (uintptr_t)ret_copy;
3500         return ret_ref;
3501 }
3502
3503 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
3504 CHECK(!owner->result_ok);
3505         return DecodeError_clone(&*owner->contents.err);
3506 }
3507 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
3508         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
3509         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
3510         uintptr_t ret_ref = 0;
3511         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3512         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3514         ret_ref = (uintptr_t)ret_var.inner;
3515         if (ret_var.is_owned) {
3516                 ret_ref |= 1;
3517         }
3518         return ret_ref;
3519 }
3520
3521 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
3522         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
3523         switch(obj->tag) {
3524                 case LDKCOption_EventZ_Some: return 0;
3525                 case LDKCOption_EventZ_None: return 1;
3526                 default: abort();
3527         }
3528 }
3529 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
3530         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
3531         assert(obj->tag == LDKCOption_EventZ_Some);
3532                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
3533         return some_ref;
3534 }
3535 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3536 CHECK(owner->result_ok);
3537         return COption_EventZ_clone(&*owner->contents.result);
3538 }
3539 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
3540         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
3541         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
3542         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
3543         uintptr_t ret_ref = (uintptr_t)ret_copy;
3544         return ret_ref;
3545 }
3546
3547 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3548 CHECK(!owner->result_ok);
3549         return DecodeError_clone(&*owner->contents.err);
3550 }
3551 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
3552         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
3553         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
3554         uintptr_t ret_ref = 0;
3555         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3556         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3558         ret_ref = (uintptr_t)ret_var.inner;
3559         if (ret_var.is_owned) {
3560                 ret_ref |= 1;
3561         }
3562         return ret_ref;
3563 }
3564
3565 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3566 CHECK(owner->result_ok);
3567         return NodeId_clone(&*owner->contents.result);
3568 }
3569 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
3570         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3571         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3572         uintptr_t ret_ref = 0;
3573         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3574         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3576         ret_ref = (uintptr_t)ret_var.inner;
3577         if (ret_var.is_owned) {
3578                 ret_ref |= 1;
3579         }
3580         return ret_ref;
3581 }
3582
3583 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3584 CHECK(!owner->result_ok);
3585         return DecodeError_clone(&*owner->contents.err);
3586 }
3587 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
3588         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3589         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3590         uintptr_t ret_ref = 0;
3591         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3592         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3594         ret_ref = (uintptr_t)ret_var.inner;
3595         if (ret_var.is_owned) {
3596                 ret_ref |= 1;
3597         }
3598         return ret_ref;
3599 }
3600
3601 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3602 CHECK(owner->result_ok);
3603         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3604 }
3605 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
3606         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3607         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3608         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3609         uintptr_t ret_ref = (uintptr_t)ret_copy;
3610         return ret_ref;
3611 }
3612
3613 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3614 CHECK(!owner->result_ok);
3615         return DecodeError_clone(&*owner->contents.err);
3616 }
3617 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
3618         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3619         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3620         uintptr_t ret_ref = 0;
3621         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3622         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3624         ret_ref = (uintptr_t)ret_var.inner;
3625         if (ret_var.is_owned) {
3626                 ret_ref |= 1;
3627         }
3628         return ret_ref;
3629 }
3630
3631 typedef struct LDKAccess_JCalls {
3632         atomic_size_t refcnt;
3633         uint32_t instance_ptr;
3634 } LDKAccess_JCalls;
3635 static void LDKAccess_JCalls_free(void* this_arg) {
3636         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3637         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3638                 FREE(j_calls);
3639         }
3640 }
3641 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3642         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3643         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
3644         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
3645         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 17, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id);
3646         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3647         CHECK_ACCESS(ret_ptr);
3648         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3649         FREE((void*)ret);
3650         return ret_conv;
3651 }
3652 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3653         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3654         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3655 }
3656 static inline LDKAccess LDKAccess_init (JSValue o) {
3657         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3658         atomic_init(&calls->refcnt, 1);
3659         calls->instance_ptr = o;
3660
3661         LDKAccess ret = {
3662                 .this_arg = (void*) calls,
3663                 .get_utxo = get_utxo_LDKAccess_jcall,
3664                 .free = LDKAccess_JCalls_free,
3665         };
3666         return ret;
3667 }
3668 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
3669         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3670         *res_ptr = LDKAccess_init(o);
3671         return (long)res_ptr;
3672 }
3673 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) {
3674         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3675         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3676         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3677         unsigned char genesis_hash_arr[32];
3678         CHECK(genesis_hash->arr_len == 32);
3679         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
3680         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3681         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3682         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3683         return (uintptr_t)ret_conv;
3684 }
3685
3686 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
3687         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3688         switch(obj->tag) {
3689                 case LDKCOption_AccessZ_Some: return 0;
3690                 case LDKCOption_AccessZ_None: return 1;
3691                 default: abort();
3692         }
3693 }
3694 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
3695         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3696         assert(obj->tag == LDKCOption_AccessZ_Some);
3697                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3698                         *some_ret = obj->some;
3699                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
3700         return (uintptr_t)some_ret;
3701 }
3702 static inline struct LDKDirectionalChannelInfo CResult_DirectionalChannelInfoDecodeErrorZ_get_ok(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3703 CHECK(owner->result_ok);
3704         return DirectionalChannelInfo_clone(&*owner->contents.result);
3705 }
3706 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
3707         LDKCResult_DirectionalChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(owner & ~1);
3708         LDKDirectionalChannelInfo ret_var = CResult_DirectionalChannelInfoDecodeErrorZ_get_ok(owner_conv);
3709         uintptr_t ret_ref = 0;
3710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3713         ret_ref = (uintptr_t)ret_var.inner;
3714         if (ret_var.is_owned) {
3715                 ret_ref |= 1;
3716         }
3717         return ret_ref;
3718 }
3719
3720 static inline struct LDKDecodeError CResult_DirectionalChannelInfoDecodeErrorZ_get_err(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3721 CHECK(!owner->result_ok);
3722         return DecodeError_clone(&*owner->contents.err);
3723 }
3724 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_get_err"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
3725         LDKCResult_DirectionalChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(owner & ~1);
3726         LDKDecodeError ret_var = CResult_DirectionalChannelInfoDecodeErrorZ_get_err(owner_conv);
3727         uintptr_t ret_ref = 0;
3728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3731         ret_ref = (uintptr_t)ret_var.inner;
3732         if (ret_var.is_owned) {
3733                 ret_ref |= 1;
3734         }
3735         return ret_ref;
3736 }
3737
3738 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3739 CHECK(owner->result_ok);
3740         return ChannelInfo_clone(&*owner->contents.result);
3741 }
3742 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
3743         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3744         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
3745         uintptr_t ret_ref = 0;
3746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3749         ret_ref = (uintptr_t)ret_var.inner;
3750         if (ret_var.is_owned) {
3751                 ret_ref |= 1;
3752         }
3753         return ret_ref;
3754 }
3755
3756 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3757 CHECK(!owner->result_ok);
3758         return DecodeError_clone(&*owner->contents.err);
3759 }
3760 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
3761         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3762         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
3763         uintptr_t ret_ref = 0;
3764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3767         ret_ref = (uintptr_t)ret_var.inner;
3768         if (ret_var.is_owned) {
3769                 ret_ref |= 1;
3770         }
3771         return ret_ref;
3772 }
3773
3774 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3775 CHECK(owner->result_ok);
3776         return RoutingFees_clone(&*owner->contents.result);
3777 }
3778 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
3779         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3780         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
3781         uintptr_t ret_ref = 0;
3782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3785         ret_ref = (uintptr_t)ret_var.inner;
3786         if (ret_var.is_owned) {
3787                 ret_ref |= 1;
3788         }
3789         return ret_ref;
3790 }
3791
3792 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3793 CHECK(!owner->result_ok);
3794         return DecodeError_clone(&*owner->contents.err);
3795 }
3796 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
3797         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3798         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
3799         uintptr_t ret_ref = 0;
3800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3803         ret_ref = (uintptr_t)ret_var.inner;
3804         if (ret_var.is_owned) {
3805                 ret_ref |= 1;
3806         }
3807         return ret_ref;
3808 }
3809
3810 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3811         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3812         switch(obj->tag) {
3813                 case LDKNetAddress_IPv4: return 0;
3814                 case LDKNetAddress_IPv6: return 1;
3815                 case LDKNetAddress_OnionV2: return 2;
3816                 case LDKNetAddress_OnionV3: return 3;
3817                 default: abort();
3818         }
3819 }
3820 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3821         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3822         assert(obj->tag == LDKNetAddress_IPv4);
3823                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3824                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3825         return addr_arr;
3826 }
3827 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3828         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3829         assert(obj->tag == LDKNetAddress_IPv4);
3830         return obj->i_pv4.port;
3831 }
3832 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3833         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3834         assert(obj->tag == LDKNetAddress_IPv6);
3835                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
3836                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3837         return addr_arr;
3838 }
3839 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
3840         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3841         assert(obj->tag == LDKNetAddress_IPv6);
3842         return obj->i_pv6.port;
3843 }
3844 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
3845         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3846         assert(obj->tag == LDKNetAddress_OnionV2);
3847                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
3848                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
3849         return onion_v2_arr;
3850 }
3851 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
3852         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3853         assert(obj->tag == LDKNetAddress_OnionV3);
3854                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
3855                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
3856         return ed25519_pubkey_arr;
3857 }
3858 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
3859         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3860         assert(obj->tag == LDKNetAddress_OnionV3);
3861         return obj->onion_v3.checksum;
3862 }
3863 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
3864         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3865         assert(obj->tag == LDKNetAddress_OnionV3);
3866         return obj->onion_v3.version;
3867 }
3868 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
3869         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3870         assert(obj->tag == LDKNetAddress_OnionV3);
3871         return obj->onion_v3.port;
3872 }
3873 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3874         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3875         for (size_t i = 0; i < ret.datalen; i++) {
3876                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3877         }
3878         return ret;
3879 }
3880 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3881 CHECK(owner->result_ok);
3882         return NodeAnnouncementInfo_clone(&*owner->contents.result);
3883 }
3884 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
3885         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3886         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
3887         uintptr_t ret_ref = 0;
3888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3891         ret_ref = (uintptr_t)ret_var.inner;
3892         if (ret_var.is_owned) {
3893                 ret_ref |= 1;
3894         }
3895         return ret_ref;
3896 }
3897
3898 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3899 CHECK(!owner->result_ok);
3900         return DecodeError_clone(&*owner->contents.err);
3901 }
3902 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
3903         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3904         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
3905         uintptr_t ret_ref = 0;
3906         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3907         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3909         ret_ref = (uintptr_t)ret_var.inner;
3910         if (ret_var.is_owned) {
3911                 ret_ref |= 1;
3912         }
3913         return ret_ref;
3914 }
3915
3916 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3917         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3918         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3919         return ret;
3920 }
3921 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3922 CHECK(owner->result_ok);
3923         return NodeInfo_clone(&*owner->contents.result);
3924 }
3925 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
3926         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3927         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
3928         uintptr_t ret_ref = 0;
3929         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3930         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3932         ret_ref = (uintptr_t)ret_var.inner;
3933         if (ret_var.is_owned) {
3934                 ret_ref |= 1;
3935         }
3936         return ret_ref;
3937 }
3938
3939 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3940 CHECK(!owner->result_ok);
3941         return DecodeError_clone(&*owner->contents.err);
3942 }
3943 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
3944         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3945         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
3946         uintptr_t ret_ref = 0;
3947         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3948         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3949         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3950         ret_ref = (uintptr_t)ret_var.inner;
3951         if (ret_var.is_owned) {
3952                 ret_ref |= 1;
3953         }
3954         return ret_ref;
3955 }
3956
3957 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3958 CHECK(owner->result_ok);
3959         return NetworkGraph_clone(&*owner->contents.result);
3960 }
3961 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
3962         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3963         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
3964         uintptr_t ret_ref = 0;
3965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3968         ret_ref = (uintptr_t)ret_var.inner;
3969         if (ret_var.is_owned) {
3970                 ret_ref |= 1;
3971         }
3972         return ret_ref;
3973 }
3974
3975 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3976 CHECK(!owner->result_ok);
3977         return DecodeError_clone(&*owner->contents.err);
3978 }
3979 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
3980         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3981         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
3982         uintptr_t ret_ref = 0;
3983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3986         ret_ref = (uintptr_t)ret_var.inner;
3987         if (ret_var.is_owned) {
3988                 ret_ref |= 1;
3989         }
3990         return ret_ref;
3991 }
3992
3993 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
3994         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3995         switch(obj->tag) {
3996                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
3997                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
3998                 default: abort();
3999         }
4000 }
4001 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
4002         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
4003         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
4004                         LDKCVec_NetAddressZ some_var = obj->some;
4005                         uint32_tArray some_arr = NULL;
4006                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
4007                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
4008                         for (size_t m = 0; m < some_var.datalen; m++) {
4009                                 uintptr_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
4010                                 some_arr_ptr[m] = some_conv_12_ref;
4011                         }
4012                         
4013         return some_arr;
4014 }
4015 static inline struct LDKScoringParameters *CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
4016 CHECK(owner->result_ok);
4017         return &*owner->contents.result;
4018 }
4019 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t owner) {
4020         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
4021         LDKScoringParameters ret_var = *CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
4022         uintptr_t ret_ref = 0;
4023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4026         ret_ref = (uintptr_t)ret_var.inner & ~1;
4027         return ret_ref;
4028 }
4029
4030 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
4031 CHECK(!owner->result_ok);
4032         return DecodeError_clone(&*owner->contents.err);
4033 }
4034 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_err"))) TS_CResult_ScoringParametersDecodeErrorZ_get_err(uint32_t owner) {
4035         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
4036         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
4037         uintptr_t ret_ref = 0;
4038         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4039         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4041         ret_ref = (uintptr_t)ret_var.inner;
4042         if (ret_var.is_owned) {
4043                 ret_ref |= 1;
4044         }
4045         return ret_ref;
4046 }
4047
4048 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4049 CHECK(owner->result_ok);
4050         return InitFeatures_clone(&*owner->contents.result);
4051 }
4052 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4053         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
4054         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
4055         uintptr_t ret_ref = 0;
4056         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4057         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4059         ret_ref = (uintptr_t)ret_var.inner;
4060         if (ret_var.is_owned) {
4061                 ret_ref |= 1;
4062         }
4063         return ret_ref;
4064 }
4065
4066 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4067 CHECK(!owner->result_ok);
4068         return DecodeError_clone(&*owner->contents.err);
4069 }
4070 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4071         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
4072         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
4073         uintptr_t ret_ref = 0;
4074         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4075         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4077         ret_ref = (uintptr_t)ret_var.inner;
4078         if (ret_var.is_owned) {
4079                 ret_ref |= 1;
4080         }
4081         return ret_ref;
4082 }
4083
4084 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4085 CHECK(owner->result_ok);
4086         return ChannelFeatures_clone(&*owner->contents.result);
4087 }
4088 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4089         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
4090         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
4091         uintptr_t ret_ref = 0;
4092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4095         ret_ref = (uintptr_t)ret_var.inner;
4096         if (ret_var.is_owned) {
4097                 ret_ref |= 1;
4098         }
4099         return ret_ref;
4100 }
4101
4102 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4103 CHECK(!owner->result_ok);
4104         return DecodeError_clone(&*owner->contents.err);
4105 }
4106 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4107         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
4108         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
4109         uintptr_t ret_ref = 0;
4110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4113         ret_ref = (uintptr_t)ret_var.inner;
4114         if (ret_var.is_owned) {
4115                 ret_ref |= 1;
4116         }
4117         return ret_ref;
4118 }
4119
4120 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4121 CHECK(owner->result_ok);
4122         return NodeFeatures_clone(&*owner->contents.result);
4123 }
4124 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4125         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
4126         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
4127         uintptr_t ret_ref = 0;
4128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4131         ret_ref = (uintptr_t)ret_var.inner;
4132         if (ret_var.is_owned) {
4133                 ret_ref |= 1;
4134         }
4135         return ret_ref;
4136 }
4137
4138 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4139 CHECK(!owner->result_ok);
4140         return DecodeError_clone(&*owner->contents.err);
4141 }
4142 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4143         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
4144         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
4145         uintptr_t ret_ref = 0;
4146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4149         ret_ref = (uintptr_t)ret_var.inner;
4150         if (ret_var.is_owned) {
4151                 ret_ref |= 1;
4152         }
4153         return ret_ref;
4154 }
4155
4156 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4157 CHECK(owner->result_ok);
4158         return InvoiceFeatures_clone(&*owner->contents.result);
4159 }
4160 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4161         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
4162         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
4163         uintptr_t ret_ref = 0;
4164         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4165         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4167         ret_ref = (uintptr_t)ret_var.inner;
4168         if (ret_var.is_owned) {
4169                 ret_ref |= 1;
4170         }
4171         return ret_ref;
4172 }
4173
4174 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4175 CHECK(!owner->result_ok);
4176         return DecodeError_clone(&*owner->contents.err);
4177 }
4178 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4179         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
4180         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
4181         uintptr_t ret_ref = 0;
4182         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4183         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4185         ret_ref = (uintptr_t)ret_var.inner;
4186         if (ret_var.is_owned) {
4187                 ret_ref |= 1;
4188         }
4189         return ret_ref;
4190 }
4191
4192 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4193 CHECK(owner->result_ok);
4194         return ChannelTypeFeatures_clone(&*owner->contents.result);
4195 }
4196 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4197         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
4198         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
4199         uintptr_t ret_ref = 0;
4200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4203         ret_ref = (uintptr_t)ret_var.inner;
4204         if (ret_var.is_owned) {
4205                 ret_ref |= 1;
4206         }
4207         return ret_ref;
4208 }
4209
4210 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4211 CHECK(!owner->result_ok);
4212         return DecodeError_clone(&*owner->contents.err);
4213 }
4214 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4215         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
4216         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
4217         uintptr_t ret_ref = 0;
4218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4221         ret_ref = (uintptr_t)ret_var.inner;
4222         if (ret_var.is_owned) {
4223                 ret_ref |= 1;
4224         }
4225         return ret_ref;
4226 }
4227
4228 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
4229 CHECK(owner->result_ok);
4230         return NetAddress_clone(&*owner->contents.result);
4231 }
4232 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
4233         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
4234         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
4235         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
4236         uintptr_t ret_ref = (uintptr_t)ret_copy;
4237         return ret_ref;
4238 }
4239
4240 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
4241 CHECK(!owner->result_ok);
4242         return DecodeError_clone(&*owner->contents.err);
4243 }
4244 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
4245         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
4246         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
4247         uintptr_t ret_ref = 0;
4248         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4249         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4251         ret_ref = (uintptr_t)ret_var.inner;
4252         if (ret_var.is_owned) {
4253                 ret_ref |= 1;
4254         }
4255         return ret_ref;
4256 }
4257
4258 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
4259         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
4260         for (size_t i = 0; i < ret.datalen; i++) {
4261                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
4262         }
4263         return ret;
4264 }
4265 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
4266         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
4267         for (size_t i = 0; i < ret.datalen; i++) {
4268                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
4269         }
4270         return ret;
4271 }
4272 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
4273         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
4274         for (size_t i = 0; i < ret.datalen; i++) {
4275                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
4276         }
4277         return ret;
4278 }
4279 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
4280         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
4281         for (size_t i = 0; i < ret.datalen; i++) {
4282                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
4283         }
4284         return ret;
4285 }
4286 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
4287 CHECK(owner->result_ok);
4288         return AcceptChannel_clone(&*owner->contents.result);
4289 }
4290 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
4291         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
4292         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
4293         uintptr_t ret_ref = 0;
4294         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4295         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4297         ret_ref = (uintptr_t)ret_var.inner;
4298         if (ret_var.is_owned) {
4299                 ret_ref |= 1;
4300         }
4301         return ret_ref;
4302 }
4303
4304 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
4305 CHECK(!owner->result_ok);
4306         return DecodeError_clone(&*owner->contents.err);
4307 }
4308 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
4309         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
4310         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
4311         uintptr_t ret_ref = 0;
4312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4315         ret_ref = (uintptr_t)ret_var.inner;
4316         if (ret_var.is_owned) {
4317                 ret_ref |= 1;
4318         }
4319         return ret_ref;
4320 }
4321
4322 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
4323 CHECK(owner->result_ok);
4324         return AnnouncementSignatures_clone(&*owner->contents.result);
4325 }
4326 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
4327         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
4328         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
4329         uintptr_t ret_ref = 0;
4330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4333         ret_ref = (uintptr_t)ret_var.inner;
4334         if (ret_var.is_owned) {
4335                 ret_ref |= 1;
4336         }
4337         return ret_ref;
4338 }
4339
4340 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
4341 CHECK(!owner->result_ok);
4342         return DecodeError_clone(&*owner->contents.err);
4343 }
4344 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
4345         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
4346         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
4347         uintptr_t ret_ref = 0;
4348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4351         ret_ref = (uintptr_t)ret_var.inner;
4352         if (ret_var.is_owned) {
4353                 ret_ref |= 1;
4354         }
4355         return ret_ref;
4356 }
4357
4358 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
4359 CHECK(owner->result_ok);
4360         return ChannelReestablish_clone(&*owner->contents.result);
4361 }
4362 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
4363         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
4364         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
4365         uintptr_t ret_ref = 0;
4366         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4367         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4369         ret_ref = (uintptr_t)ret_var.inner;
4370         if (ret_var.is_owned) {
4371                 ret_ref |= 1;
4372         }
4373         return ret_ref;
4374 }
4375
4376 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
4377 CHECK(!owner->result_ok);
4378         return DecodeError_clone(&*owner->contents.err);
4379 }
4380 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
4381         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
4382         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
4383         uintptr_t ret_ref = 0;
4384         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4385         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4387         ret_ref = (uintptr_t)ret_var.inner;
4388         if (ret_var.is_owned) {
4389                 ret_ref |= 1;
4390         }
4391         return ret_ref;
4392 }
4393
4394 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
4395 CHECK(owner->result_ok);
4396         return ClosingSigned_clone(&*owner->contents.result);
4397 }
4398 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
4399         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
4400         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
4401         uintptr_t ret_ref = 0;
4402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4405         ret_ref = (uintptr_t)ret_var.inner;
4406         if (ret_var.is_owned) {
4407                 ret_ref |= 1;
4408         }
4409         return ret_ref;
4410 }
4411
4412 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
4413 CHECK(!owner->result_ok);
4414         return DecodeError_clone(&*owner->contents.err);
4415 }
4416 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
4417         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
4418         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
4419         uintptr_t ret_ref = 0;
4420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4423         ret_ref = (uintptr_t)ret_var.inner;
4424         if (ret_var.is_owned) {
4425                 ret_ref |= 1;
4426         }
4427         return ret_ref;
4428 }
4429
4430 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
4431 CHECK(owner->result_ok);
4432         return ClosingSignedFeeRange_clone(&*owner->contents.result);
4433 }
4434 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
4435         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
4436         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
4437         uintptr_t ret_ref = 0;
4438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4441         ret_ref = (uintptr_t)ret_var.inner;
4442         if (ret_var.is_owned) {
4443                 ret_ref |= 1;
4444         }
4445         return ret_ref;
4446 }
4447
4448 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
4449 CHECK(!owner->result_ok);
4450         return DecodeError_clone(&*owner->contents.err);
4451 }
4452 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
4453         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
4454         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
4455         uintptr_t ret_ref = 0;
4456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4459         ret_ref = (uintptr_t)ret_var.inner;
4460         if (ret_var.is_owned) {
4461                 ret_ref |= 1;
4462         }
4463         return ret_ref;
4464 }
4465
4466 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
4467 CHECK(owner->result_ok);
4468         return CommitmentSigned_clone(&*owner->contents.result);
4469 }
4470 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
4471         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
4472         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
4473         uintptr_t ret_ref = 0;
4474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4477         ret_ref = (uintptr_t)ret_var.inner;
4478         if (ret_var.is_owned) {
4479                 ret_ref |= 1;
4480         }
4481         return ret_ref;
4482 }
4483
4484 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
4485 CHECK(!owner->result_ok);
4486         return DecodeError_clone(&*owner->contents.err);
4487 }
4488 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
4489         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
4490         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
4491         uintptr_t ret_ref = 0;
4492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4495         ret_ref = (uintptr_t)ret_var.inner;
4496         if (ret_var.is_owned) {
4497                 ret_ref |= 1;
4498         }
4499         return ret_ref;
4500 }
4501
4502 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
4503 CHECK(owner->result_ok);
4504         return FundingCreated_clone(&*owner->contents.result);
4505 }
4506 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
4507         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
4508         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
4509         uintptr_t ret_ref = 0;
4510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4513         ret_ref = (uintptr_t)ret_var.inner;
4514         if (ret_var.is_owned) {
4515                 ret_ref |= 1;
4516         }
4517         return ret_ref;
4518 }
4519
4520 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
4521 CHECK(!owner->result_ok);
4522         return DecodeError_clone(&*owner->contents.err);
4523 }
4524 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
4525         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
4526         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
4527         uintptr_t ret_ref = 0;
4528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4531         ret_ref = (uintptr_t)ret_var.inner;
4532         if (ret_var.is_owned) {
4533                 ret_ref |= 1;
4534         }
4535         return ret_ref;
4536 }
4537
4538 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
4539 CHECK(owner->result_ok);
4540         return FundingSigned_clone(&*owner->contents.result);
4541 }
4542 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
4543         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
4544         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
4545         uintptr_t ret_ref = 0;
4546         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4547         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4549         ret_ref = (uintptr_t)ret_var.inner;
4550         if (ret_var.is_owned) {
4551                 ret_ref |= 1;
4552         }
4553         return ret_ref;
4554 }
4555
4556 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
4557 CHECK(!owner->result_ok);
4558         return DecodeError_clone(&*owner->contents.err);
4559 }
4560 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
4561         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
4562         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
4563         uintptr_t ret_ref = 0;
4564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4567         ret_ref = (uintptr_t)ret_var.inner;
4568         if (ret_var.is_owned) {
4569                 ret_ref |= 1;
4570         }
4571         return ret_ref;
4572 }
4573
4574 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
4575 CHECK(owner->result_ok);
4576         return FundingLocked_clone(&*owner->contents.result);
4577 }
4578 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_ok"))) TS_CResult_FundingLockedDecodeErrorZ_get_ok(uint32_t owner) {
4579         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
4580         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
4581         uintptr_t ret_ref = 0;
4582         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4583         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4585         ret_ref = (uintptr_t)ret_var.inner;
4586         if (ret_var.is_owned) {
4587                 ret_ref |= 1;
4588         }
4589         return ret_ref;
4590 }
4591
4592 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
4593 CHECK(!owner->result_ok);
4594         return DecodeError_clone(&*owner->contents.err);
4595 }
4596 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_err"))) TS_CResult_FundingLockedDecodeErrorZ_get_err(uint32_t owner) {
4597         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
4598         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
4599         uintptr_t ret_ref = 0;
4600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4603         ret_ref = (uintptr_t)ret_var.inner;
4604         if (ret_var.is_owned) {
4605                 ret_ref |= 1;
4606         }
4607         return ret_ref;
4608 }
4609
4610 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
4611 CHECK(owner->result_ok);
4612         return Init_clone(&*owner->contents.result);
4613 }
4614 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
4615         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
4616         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
4617         uintptr_t ret_ref = 0;
4618         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4619         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4621         ret_ref = (uintptr_t)ret_var.inner;
4622         if (ret_var.is_owned) {
4623                 ret_ref |= 1;
4624         }
4625         return ret_ref;
4626 }
4627
4628 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
4629 CHECK(!owner->result_ok);
4630         return DecodeError_clone(&*owner->contents.err);
4631 }
4632 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
4633         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
4634         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
4635         uintptr_t ret_ref = 0;
4636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4639         ret_ref = (uintptr_t)ret_var.inner;
4640         if (ret_var.is_owned) {
4641                 ret_ref |= 1;
4642         }
4643         return ret_ref;
4644 }
4645
4646 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
4647 CHECK(owner->result_ok);
4648         return OpenChannel_clone(&*owner->contents.result);
4649 }
4650 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
4651         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
4652         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
4653         uintptr_t ret_ref = 0;
4654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4657         ret_ref = (uintptr_t)ret_var.inner;
4658         if (ret_var.is_owned) {
4659                 ret_ref |= 1;
4660         }
4661         return ret_ref;
4662 }
4663
4664 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
4665 CHECK(!owner->result_ok);
4666         return DecodeError_clone(&*owner->contents.err);
4667 }
4668 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
4669         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
4670         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
4671         uintptr_t ret_ref = 0;
4672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4675         ret_ref = (uintptr_t)ret_var.inner;
4676         if (ret_var.is_owned) {
4677                 ret_ref |= 1;
4678         }
4679         return ret_ref;
4680 }
4681
4682 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
4683 CHECK(owner->result_ok);
4684         return RevokeAndACK_clone(&*owner->contents.result);
4685 }
4686 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
4687         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
4688         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
4689         uintptr_t ret_ref = 0;
4690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4693         ret_ref = (uintptr_t)ret_var.inner;
4694         if (ret_var.is_owned) {
4695                 ret_ref |= 1;
4696         }
4697         return ret_ref;
4698 }
4699
4700 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
4701 CHECK(!owner->result_ok);
4702         return DecodeError_clone(&*owner->contents.err);
4703 }
4704 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
4705         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
4706         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
4707         uintptr_t ret_ref = 0;
4708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4711         ret_ref = (uintptr_t)ret_var.inner;
4712         if (ret_var.is_owned) {
4713                 ret_ref |= 1;
4714         }
4715         return ret_ref;
4716 }
4717
4718 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
4719 CHECK(owner->result_ok);
4720         return Shutdown_clone(&*owner->contents.result);
4721 }
4722 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
4723         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
4724         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
4725         uintptr_t ret_ref = 0;
4726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4729         ret_ref = (uintptr_t)ret_var.inner;
4730         if (ret_var.is_owned) {
4731                 ret_ref |= 1;
4732         }
4733         return ret_ref;
4734 }
4735
4736 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
4737 CHECK(!owner->result_ok);
4738         return DecodeError_clone(&*owner->contents.err);
4739 }
4740 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
4741         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
4742         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
4743         uintptr_t ret_ref = 0;
4744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4747         ret_ref = (uintptr_t)ret_var.inner;
4748         if (ret_var.is_owned) {
4749                 ret_ref |= 1;
4750         }
4751         return ret_ref;
4752 }
4753
4754 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
4755 CHECK(owner->result_ok);
4756         return UpdateFailHTLC_clone(&*owner->contents.result);
4757 }
4758 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
4759         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
4760         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
4761         uintptr_t ret_ref = 0;
4762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4765         ret_ref = (uintptr_t)ret_var.inner;
4766         if (ret_var.is_owned) {
4767                 ret_ref |= 1;
4768         }
4769         return ret_ref;
4770 }
4771
4772 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
4773 CHECK(!owner->result_ok);
4774         return DecodeError_clone(&*owner->contents.err);
4775 }
4776 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
4777         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
4778         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
4779         uintptr_t ret_ref = 0;
4780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4783         ret_ref = (uintptr_t)ret_var.inner;
4784         if (ret_var.is_owned) {
4785                 ret_ref |= 1;
4786         }
4787         return ret_ref;
4788 }
4789
4790 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
4791 CHECK(owner->result_ok);
4792         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
4793 }
4794 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
4795         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
4796         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
4797         uintptr_t ret_ref = 0;
4798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4801         ret_ref = (uintptr_t)ret_var.inner;
4802         if (ret_var.is_owned) {
4803                 ret_ref |= 1;
4804         }
4805         return ret_ref;
4806 }
4807
4808 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
4809 CHECK(!owner->result_ok);
4810         return DecodeError_clone(&*owner->contents.err);
4811 }
4812 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
4813         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
4814         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
4815         uintptr_t ret_ref = 0;
4816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4819         ret_ref = (uintptr_t)ret_var.inner;
4820         if (ret_var.is_owned) {
4821                 ret_ref |= 1;
4822         }
4823         return ret_ref;
4824 }
4825
4826 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
4827 CHECK(owner->result_ok);
4828         return UpdateFee_clone(&*owner->contents.result);
4829 }
4830 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
4831         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
4832         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
4833         uintptr_t ret_ref = 0;
4834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4837         ret_ref = (uintptr_t)ret_var.inner;
4838         if (ret_var.is_owned) {
4839                 ret_ref |= 1;
4840         }
4841         return ret_ref;
4842 }
4843
4844 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
4845 CHECK(!owner->result_ok);
4846         return DecodeError_clone(&*owner->contents.err);
4847 }
4848 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
4849         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
4850         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
4851         uintptr_t ret_ref = 0;
4852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4855         ret_ref = (uintptr_t)ret_var.inner;
4856         if (ret_var.is_owned) {
4857                 ret_ref |= 1;
4858         }
4859         return ret_ref;
4860 }
4861
4862 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
4863 CHECK(owner->result_ok);
4864         return UpdateFulfillHTLC_clone(&*owner->contents.result);
4865 }
4866 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
4867         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
4868         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
4869         uintptr_t ret_ref = 0;
4870         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4871         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4873         ret_ref = (uintptr_t)ret_var.inner;
4874         if (ret_var.is_owned) {
4875                 ret_ref |= 1;
4876         }
4877         return ret_ref;
4878 }
4879
4880 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
4881 CHECK(!owner->result_ok);
4882         return DecodeError_clone(&*owner->contents.err);
4883 }
4884 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
4885         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
4886         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
4887         uintptr_t ret_ref = 0;
4888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4891         ret_ref = (uintptr_t)ret_var.inner;
4892         if (ret_var.is_owned) {
4893                 ret_ref |= 1;
4894         }
4895         return ret_ref;
4896 }
4897
4898 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
4899 CHECK(owner->result_ok);
4900         return UpdateAddHTLC_clone(&*owner->contents.result);
4901 }
4902 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
4903         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
4904         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
4905         uintptr_t ret_ref = 0;
4906         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4907         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4909         ret_ref = (uintptr_t)ret_var.inner;
4910         if (ret_var.is_owned) {
4911                 ret_ref |= 1;
4912         }
4913         return ret_ref;
4914 }
4915
4916 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
4917 CHECK(!owner->result_ok);
4918         return DecodeError_clone(&*owner->contents.err);
4919 }
4920 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
4921         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
4922         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
4923         uintptr_t ret_ref = 0;
4924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4927         ret_ref = (uintptr_t)ret_var.inner;
4928         if (ret_var.is_owned) {
4929                 ret_ref |= 1;
4930         }
4931         return ret_ref;
4932 }
4933
4934 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
4935 CHECK(owner->result_ok);
4936         return Ping_clone(&*owner->contents.result);
4937 }
4938 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
4939         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
4940         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
4941         uintptr_t ret_ref = 0;
4942         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4943         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4945         ret_ref = (uintptr_t)ret_var.inner;
4946         if (ret_var.is_owned) {
4947                 ret_ref |= 1;
4948         }
4949         return ret_ref;
4950 }
4951
4952 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
4953 CHECK(!owner->result_ok);
4954         return DecodeError_clone(&*owner->contents.err);
4955 }
4956 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
4957         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
4958         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
4959         uintptr_t ret_ref = 0;
4960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4963         ret_ref = (uintptr_t)ret_var.inner;
4964         if (ret_var.is_owned) {
4965                 ret_ref |= 1;
4966         }
4967         return ret_ref;
4968 }
4969
4970 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
4971 CHECK(owner->result_ok);
4972         return Pong_clone(&*owner->contents.result);
4973 }
4974 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
4975         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
4976         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
4977         uintptr_t ret_ref = 0;
4978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4981         ret_ref = (uintptr_t)ret_var.inner;
4982         if (ret_var.is_owned) {
4983                 ret_ref |= 1;
4984         }
4985         return ret_ref;
4986 }
4987
4988 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
4989 CHECK(!owner->result_ok);
4990         return DecodeError_clone(&*owner->contents.err);
4991 }
4992 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
4993         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
4994         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
4995         uintptr_t ret_ref = 0;
4996         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4997         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4999         ret_ref = (uintptr_t)ret_var.inner;
5000         if (ret_var.is_owned) {
5001                 ret_ref |= 1;
5002         }
5003         return ret_ref;
5004 }
5005
5006 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5007 CHECK(owner->result_ok);
5008         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
5009 }
5010 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
5011         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
5012         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
5013         uintptr_t ret_ref = 0;
5014         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5015         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5017         ret_ref = (uintptr_t)ret_var.inner;
5018         if (ret_var.is_owned) {
5019                 ret_ref |= 1;
5020         }
5021         return ret_ref;
5022 }
5023
5024 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5025 CHECK(!owner->result_ok);
5026         return DecodeError_clone(&*owner->contents.err);
5027 }
5028 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
5029         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
5030         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
5031         uintptr_t ret_ref = 0;
5032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5035         ret_ref = (uintptr_t)ret_var.inner;
5036         if (ret_var.is_owned) {
5037                 ret_ref |= 1;
5038         }
5039         return ret_ref;
5040 }
5041
5042 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5043 CHECK(owner->result_ok);
5044         return ChannelAnnouncement_clone(&*owner->contents.result);
5045 }
5046 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
5047         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
5048         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
5049         uintptr_t ret_ref = 0;
5050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5053         ret_ref = (uintptr_t)ret_var.inner;
5054         if (ret_var.is_owned) {
5055                 ret_ref |= 1;
5056         }
5057         return ret_ref;
5058 }
5059
5060 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5061 CHECK(!owner->result_ok);
5062         return DecodeError_clone(&*owner->contents.err);
5063 }
5064 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
5065         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
5066         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
5067         uintptr_t ret_ref = 0;
5068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5071         ret_ref = (uintptr_t)ret_var.inner;
5072         if (ret_var.is_owned) {
5073                 ret_ref |= 1;
5074         }
5075         return ret_ref;
5076 }
5077
5078 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
5079 CHECK(owner->result_ok);
5080         return UnsignedChannelUpdate_clone(&*owner->contents.result);
5081 }
5082 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5083         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
5084         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
5085         uintptr_t ret_ref = 0;
5086         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5087         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5089         ret_ref = (uintptr_t)ret_var.inner;
5090         if (ret_var.is_owned) {
5091                 ret_ref |= 1;
5092         }
5093         return ret_ref;
5094 }
5095
5096 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
5097 CHECK(!owner->result_ok);
5098         return DecodeError_clone(&*owner->contents.err);
5099 }
5100 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
5101         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
5102         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
5103         uintptr_t ret_ref = 0;
5104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5107         ret_ref = (uintptr_t)ret_var.inner;
5108         if (ret_var.is_owned) {
5109                 ret_ref |= 1;
5110         }
5111         return ret_ref;
5112 }
5113
5114 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
5115 CHECK(owner->result_ok);
5116         return ChannelUpdate_clone(&*owner->contents.result);
5117 }
5118 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5119         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
5120         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
5121         uintptr_t ret_ref = 0;
5122         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5123         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5125         ret_ref = (uintptr_t)ret_var.inner;
5126         if (ret_var.is_owned) {
5127                 ret_ref |= 1;
5128         }
5129         return ret_ref;
5130 }
5131
5132 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
5133 CHECK(!owner->result_ok);
5134         return DecodeError_clone(&*owner->contents.err);
5135 }
5136 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
5137         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
5138         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
5139         uintptr_t ret_ref = 0;
5140         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5141         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5143         ret_ref = (uintptr_t)ret_var.inner;
5144         if (ret_var.is_owned) {
5145                 ret_ref |= 1;
5146         }
5147         return ret_ref;
5148 }
5149
5150 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
5151 CHECK(owner->result_ok);
5152         return ErrorMessage_clone(&*owner->contents.result);
5153 }
5154 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
5155         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
5156         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
5157         uintptr_t ret_ref = 0;
5158         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5159         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5161         ret_ref = (uintptr_t)ret_var.inner;
5162         if (ret_var.is_owned) {
5163                 ret_ref |= 1;
5164         }
5165         return ret_ref;
5166 }
5167
5168 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
5169 CHECK(!owner->result_ok);
5170         return DecodeError_clone(&*owner->contents.err);
5171 }
5172 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
5173         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
5174         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
5175         uintptr_t ret_ref = 0;
5176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5179         ret_ref = (uintptr_t)ret_var.inner;
5180         if (ret_var.is_owned) {
5181                 ret_ref |= 1;
5182         }
5183         return ret_ref;
5184 }
5185
5186 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5187 CHECK(owner->result_ok);
5188         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
5189 }
5190 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
5191         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
5192         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
5193         uintptr_t ret_ref = 0;
5194         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5195         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5197         ret_ref = (uintptr_t)ret_var.inner;
5198         if (ret_var.is_owned) {
5199                 ret_ref |= 1;
5200         }
5201         return ret_ref;
5202 }
5203
5204 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5205 CHECK(!owner->result_ok);
5206         return DecodeError_clone(&*owner->contents.err);
5207 }
5208 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
5209         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
5210         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
5211         uintptr_t ret_ref = 0;
5212         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5213         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5215         ret_ref = (uintptr_t)ret_var.inner;
5216         if (ret_var.is_owned) {
5217                 ret_ref |= 1;
5218         }
5219         return ret_ref;
5220 }
5221
5222 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5223 CHECK(owner->result_ok);
5224         return NodeAnnouncement_clone(&*owner->contents.result);
5225 }
5226 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
5227         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
5228         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
5229         uintptr_t ret_ref = 0;
5230         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5231         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5233         ret_ref = (uintptr_t)ret_var.inner;
5234         if (ret_var.is_owned) {
5235                 ret_ref |= 1;
5236         }
5237         return ret_ref;
5238 }
5239
5240 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5241 CHECK(!owner->result_ok);
5242         return DecodeError_clone(&*owner->contents.err);
5243 }
5244 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
5245         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
5246         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
5247         uintptr_t ret_ref = 0;
5248         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5249         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5251         ret_ref = (uintptr_t)ret_var.inner;
5252         if (ret_var.is_owned) {
5253                 ret_ref |= 1;
5254         }
5255         return ret_ref;
5256 }
5257
5258 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
5259 CHECK(owner->result_ok);
5260         return QueryShortChannelIds_clone(&*owner->contents.result);
5261 }
5262 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
5263         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
5264         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
5265         uintptr_t ret_ref = 0;
5266         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5267         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5269         ret_ref = (uintptr_t)ret_var.inner;
5270         if (ret_var.is_owned) {
5271                 ret_ref |= 1;
5272         }
5273         return ret_ref;
5274 }
5275
5276 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
5277 CHECK(!owner->result_ok);
5278         return DecodeError_clone(&*owner->contents.err);
5279 }
5280 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
5281         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
5282         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
5283         uintptr_t ret_ref = 0;
5284         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5285         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5287         ret_ref = (uintptr_t)ret_var.inner;
5288         if (ret_var.is_owned) {
5289                 ret_ref |= 1;
5290         }
5291         return ret_ref;
5292 }
5293
5294 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
5295 CHECK(owner->result_ok);
5296         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
5297 }
5298 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
5299         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
5300         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
5301         uintptr_t ret_ref = 0;
5302         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5303         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5305         ret_ref = (uintptr_t)ret_var.inner;
5306         if (ret_var.is_owned) {
5307                 ret_ref |= 1;
5308         }
5309         return ret_ref;
5310 }
5311
5312 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
5313 CHECK(!owner->result_ok);
5314         return DecodeError_clone(&*owner->contents.err);
5315 }
5316 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
5317         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
5318         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
5319         uintptr_t ret_ref = 0;
5320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5323         ret_ref = (uintptr_t)ret_var.inner;
5324         if (ret_var.is_owned) {
5325                 ret_ref |= 1;
5326         }
5327         return ret_ref;
5328 }
5329
5330 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
5331 CHECK(owner->result_ok);
5332         return QueryChannelRange_clone(&*owner->contents.result);
5333 }
5334 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
5335         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
5336         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
5337         uintptr_t ret_ref = 0;
5338         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5339         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5341         ret_ref = (uintptr_t)ret_var.inner;
5342         if (ret_var.is_owned) {
5343                 ret_ref |= 1;
5344         }
5345         return ret_ref;
5346 }
5347
5348 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
5349 CHECK(!owner->result_ok);
5350         return DecodeError_clone(&*owner->contents.err);
5351 }
5352 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
5353         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
5354         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
5355         uintptr_t ret_ref = 0;
5356         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5357         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5359         ret_ref = (uintptr_t)ret_var.inner;
5360         if (ret_var.is_owned) {
5361                 ret_ref |= 1;
5362         }
5363         return ret_ref;
5364 }
5365
5366 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
5367 CHECK(owner->result_ok);
5368         return ReplyChannelRange_clone(&*owner->contents.result);
5369 }
5370 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
5371         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
5372         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
5373         uintptr_t ret_ref = 0;
5374         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5375         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5377         ret_ref = (uintptr_t)ret_var.inner;
5378         if (ret_var.is_owned) {
5379                 ret_ref |= 1;
5380         }
5381         return ret_ref;
5382 }
5383
5384 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
5385 CHECK(!owner->result_ok);
5386         return DecodeError_clone(&*owner->contents.err);
5387 }
5388 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
5389         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
5390         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
5391         uintptr_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 struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
5403 CHECK(owner->result_ok);
5404         return GossipTimestampFilter_clone(&*owner->contents.result);
5405 }
5406 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
5407         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
5408         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
5409         uintptr_t ret_ref = 0;
5410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5413         ret_ref = (uintptr_t)ret_var.inner;
5414         if (ret_var.is_owned) {
5415                 ret_ref |= 1;
5416         }
5417         return ret_ref;
5418 }
5419
5420 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
5421 CHECK(!owner->result_ok);
5422         return DecodeError_clone(&*owner->contents.err);
5423 }
5424 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
5425         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
5426         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
5427         uintptr_t ret_ref = 0;
5428         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5429         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5431         ret_ref = (uintptr_t)ret_var.inner;
5432         if (ret_var.is_owned) {
5433                 ret_ref |= 1;
5434         }
5435         return ret_ref;
5436 }
5437
5438 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5439 CHECK(owner->result_ok);
5440         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
5441 }
5442 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
5443         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
5444         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5445         uintptr_t ret_ref = 0;
5446         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5447         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5449         ret_ref = (uintptr_t)ret_var.inner;
5450         if (ret_var.is_owned) {
5451                 ret_ref |= 1;
5452         }
5453         return ret_ref;
5454 }
5455
5456 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5457 CHECK(!owner->result_ok);
5458         return DecodeError_clone(&*owner->contents.err);
5459 }
5460 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
5461         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
5462         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5463         uintptr_t ret_ref = 0;
5464         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5465         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5467         ret_ref = (uintptr_t)ret_var.inner;
5468         if (ret_var.is_owned) {
5469                 ret_ref |= 1;
5470         }
5471         return ret_ref;
5472 }
5473
5474 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5475 CHECK(owner->result_ok);
5476         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
5477 }
5478 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
5479         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
5480         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5481         uintptr_t ret_ref = 0;
5482         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5483         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5485         ret_ref = (uintptr_t)ret_var.inner;
5486         if (ret_var.is_owned) {
5487                 ret_ref |= 1;
5488         }
5489         return ret_ref;
5490 }
5491
5492 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5493 CHECK(!owner->result_ok);
5494         return DecodeError_clone(&*owner->contents.err);
5495 }
5496 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
5497         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
5498         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5499         uintptr_t ret_ref = 0;
5500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5503         ret_ref = (uintptr_t)ret_var.inner;
5504         if (ret_var.is_owned) {
5505                 ret_ref |= 1;
5506         }
5507         return ret_ref;
5508 }
5509
5510 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5511 CHECK(owner->result_ok);
5512         return SpendableOutputDescriptor_clone(&*owner->contents.result);
5513 }
5514 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
5515         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
5516         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
5517         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5518         uintptr_t ret_ref = (uintptr_t)ret_copy;
5519         return ret_ref;
5520 }
5521
5522 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5523 CHECK(!owner->result_ok);
5524         return DecodeError_clone(&*owner->contents.err);
5525 }
5526 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
5527         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
5528         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5529         uintptr_t ret_ref = 0;
5530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5533         ret_ref = (uintptr_t)ret_var.inner;
5534         if (ret_var.is_owned) {
5535                 ret_ref |= 1;
5536         }
5537         return ret_ref;
5538 }
5539
5540 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5541 CHECK(owner->result_ok);
5542         return Sign_clone(&*owner->contents.result);
5543 }
5544 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
5545         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5546         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5547         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
5548         return (uintptr_t)ret_ret;
5549 }
5550
5551 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5552 CHECK(!owner->result_ok);
5553         return DecodeError_clone(&*owner->contents.err);
5554 }
5555 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
5556         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5557         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
5558         uintptr_t ret_ref = 0;
5559         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5560         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5562         ret_ref = (uintptr_t)ret_var.inner;
5563         if (ret_var.is_owned) {
5564                 ret_ref |= 1;
5565         }
5566         return ret_ref;
5567 }
5568
5569 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5570 CHECK(owner->result_ok);
5571         return *owner->contents.result;
5572 }
5573 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
5574         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5575         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
5576         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
5577         return ret_arr;
5578 }
5579
5580 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5581 CHECK(!owner->result_ok);
5582         return *owner->contents.err;
5583 }
5584 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
5585         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5586         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
5587 }
5588
5589 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
5590         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
5591         for (size_t i = 0; i < ret.datalen; i++) {
5592                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
5593         }
5594         return ret;
5595 }
5596 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5597 CHECK(owner->result_ok);
5598         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
5599 }
5600 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
5601         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5602         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
5603         ptrArray ret_arr = NULL;
5604         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
5605         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
5606         for (size_t m = 0; m < ret_var.datalen; m++) {
5607                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
5608                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
5609                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
5610                 CVec_u8Z_free(ret_conv_12_var);
5611                 ret_arr_ptr[m] = ret_conv_12_arr;
5612         }
5613         
5614         FREE(ret_var.data);
5615         return ret_arr;
5616 }
5617
5618 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5619 CHECK(!owner->result_ok);
5620         return *owner->contents.err;
5621 }
5622 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
5623         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5624         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
5625 }
5626
5627 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5628 CHECK(owner->result_ok);
5629         return InMemorySigner_clone(&*owner->contents.result);
5630 }
5631 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
5632         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5633         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
5634         uintptr_t ret_ref = 0;
5635         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5636         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5638         ret_ref = (uintptr_t)ret_var.inner;
5639         if (ret_var.is_owned) {
5640                 ret_ref |= 1;
5641         }
5642         return ret_ref;
5643 }
5644
5645 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5646 CHECK(!owner->result_ok);
5647         return DecodeError_clone(&*owner->contents.err);
5648 }
5649 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
5650         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5651         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
5652         uintptr_t ret_ref = 0;
5653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5656         ret_ref = (uintptr_t)ret_var.inner;
5657         if (ret_var.is_owned) {
5658                 ret_ref |= 1;
5659         }
5660         return ret_ref;
5661 }
5662
5663 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
5664         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
5665         for (size_t i = 0; i < ret.datalen; i++) {
5666                 ret.data[i] = TxOut_clone(&orig->data[i]);
5667         }
5668         return ret;
5669 }
5670 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5671 CHECK(owner->result_ok);
5672         return *owner->contents.result;
5673 }
5674 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
5675         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5676         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
5677         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5678         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5679         return ret_arr;
5680 }
5681
5682 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5683 CHECK(!owner->result_ok);
5684         return *owner->contents.err;
5685 }
5686 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
5687         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5688         CResult_TransactionNoneZ_get_err(owner_conv);
5689 }
5690
5691 typedef struct LDKFilter_JCalls {
5692         atomic_size_t refcnt;
5693         uint32_t instance_ptr;
5694 } LDKFilter_JCalls;
5695 static void LDKFilter_JCalls_free(void* this_arg) {
5696         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5697         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5698                 FREE(j_calls);
5699         }
5700 }
5701 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5702         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5703         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
5704         memcpy(txid_arr->elems, *txid, 32);
5705         LDKu8slice script_pubkey_var = script_pubkey;
5706         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
5707         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
5708         js_invoke_function_2(j_calls->instance_ptr, 18, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
5709 }
5710 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5711         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5712         LDKWatchedOutput output_var = output;
5713         uintptr_t output_ref = 0;
5714         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5715         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5716         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
5717         output_ref = (uintptr_t)output_var.inner;
5718         if (output_var.is_owned) {
5719                 output_ref |= 1;
5720         }
5721         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 19, (uint32_t)output_ref);
5722         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5723         CHECK_ACCESS(ret_ptr);
5724         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
5725         FREE((void*)ret);
5726         return ret_conv;
5727 }
5728 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
5729         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
5730         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5731 }
5732 static inline LDKFilter LDKFilter_init (JSValue o) {
5733         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5734         atomic_init(&calls->refcnt, 1);
5735         calls->instance_ptr = o;
5736
5737         LDKFilter ret = {
5738                 .this_arg = (void*) calls,
5739                 .register_tx = register_tx_LDKFilter_jcall,
5740                 .register_output = register_output_LDKFilter_jcall,
5741                 .free = LDKFilter_JCalls_free,
5742         };
5743         return ret;
5744 }
5745 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
5746         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5747         *res_ptr = LDKFilter_init(o);
5748         return (long)res_ptr;
5749 }
5750 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5751         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5752         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5753         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
5754         unsigned char txid_arr[32];
5755         CHECK(txid->arr_len == 32);
5756         memcpy(txid_arr, txid->elems, 32); FREE(txid);
5757         unsigned char (*txid_ref)[32] = &txid_arr;
5758         LDKu8slice script_pubkey_ref;
5759         script_pubkey_ref.datalen = script_pubkey->arr_len;
5760         script_pubkey_ref.data = script_pubkey->elems /* XXX script_pubkey leaks */;
5761         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5762 }
5763
5764 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5765         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5766         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5767         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
5768         LDKWatchedOutput output_conv;
5769         output_conv.inner = (void*)(output & (~1));
5770         output_conv.is_owned = (output & 1) || (output == 0);
5771         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
5772         output_conv = WatchedOutput_clone(&output_conv);
5773         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5774         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5775         uintptr_t ret_ref = (uintptr_t)ret_copy;
5776         return ret_ref;
5777 }
5778
5779 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
5780         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
5781         switch(obj->tag) {
5782                 case LDKCOption_FilterZ_Some: return 0;
5783                 case LDKCOption_FilterZ_None: return 1;
5784                 default: abort();
5785         }
5786 }
5787 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
5788         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
5789         assert(obj->tag == LDKCOption_FilterZ_Some);
5790                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
5791                         *some_ret = obj->some;
5792                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
5793         return (uintptr_t)some_ret;
5794 }
5795 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
5796 CHECK(owner->result_ok);
5797         return &*owner->contents.result;
5798 }
5799 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
5800         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
5801         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
5802         uintptr_t ret_ref = 0;
5803         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5804         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5805         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5806         ret_ref = (uintptr_t)ret_var.inner & ~1;
5807         return ret_ref;
5808 }
5809
5810 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
5811 CHECK(!owner->result_ok);
5812         return *owner->contents.err;
5813 }
5814 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
5815         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
5816         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
5817 }
5818
5819 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
5820         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
5821         for (size_t i = 0; i < ret.datalen; i++) {
5822                 ret.data[i] = OutPoint_clone(&orig->data[i]);
5823         }
5824         return ret;
5825 }
5826 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
5827         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5828         switch(obj->tag) {
5829                 case LDKAPIError_APIMisuseError: return 0;
5830                 case LDKAPIError_FeeRateTooHigh: return 1;
5831                 case LDKAPIError_RouteError: return 2;
5832                 case LDKAPIError_ChannelUnavailable: return 3;
5833                 case LDKAPIError_MonitorUpdateFailed: return 4;
5834                 case LDKAPIError_IncompatibleShutdownScript: return 5;
5835                 default: abort();
5836         }
5837 }
5838 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
5839         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5840         assert(obj->tag == LDKAPIError_APIMisuseError);
5841                         LDKStr err_str = obj->api_misuse_error.err;
5842                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
5843         return err_conv;
5844 }
5845 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
5846         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5847         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
5848                         LDKStr err_str = obj->fee_rate_too_high.err;
5849                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
5850         return err_conv;
5851 }
5852 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
5853         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5854         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
5855         return obj->fee_rate_too_high.feerate;
5856 }
5857 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
5858         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5859         assert(obj->tag == LDKAPIError_RouteError);
5860                         LDKStr err_str = obj->route_error.err;
5861                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
5862         return err_conv;
5863 }
5864 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
5865         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5866         assert(obj->tag == LDKAPIError_ChannelUnavailable);
5867                         LDKStr err_str = obj->channel_unavailable.err;
5868                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
5869         return err_conv;
5870 }
5871 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
5872         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5873         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
5874                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
5875                         uintptr_t script_ref = 0;
5876                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5877                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5878                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
5879                         script_ref = (uintptr_t)script_var.inner & ~1;
5880         return script_ref;
5881 }
5882 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5883 CHECK(owner->result_ok);
5884         return *owner->contents.result;
5885 }
5886 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
5887         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5888         CResult_NoneAPIErrorZ_get_ok(owner_conv);
5889 }
5890
5891 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5892 CHECK(!owner->result_ok);
5893         return APIError_clone(&*owner->contents.err);
5894 }
5895 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
5896         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5897         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5898         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
5899         uintptr_t ret_ref = (uintptr_t)ret_copy;
5900         return ret_ref;
5901 }
5902
5903 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
5904         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
5905         switch(obj->tag) {
5906                 case LDKCOption_u16Z_Some: return 0;
5907                 case LDKCOption_u16Z_None: return 1;
5908                 default: abort();
5909         }
5910 }
5911 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
5912         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
5913         assert(obj->tag == LDKCOption_u16Z_Some);
5914         return obj->some;
5915 }
5916 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
5917         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
5918         for (size_t i = 0; i < ret.datalen; i++) {
5919                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
5920         }
5921         return ret;
5922 }
5923 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
5924         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
5925         for (size_t i = 0; i < ret.datalen; i++) {
5926                 ret.data[i] = APIError_clone(&orig->data[i]);
5927         }
5928         return ret;
5929 }
5930 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5931 CHECK(owner->result_ok);
5932         return ThirtyTwoBytes_clone(&*owner->contents.result);
5933 }
5934 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
5935         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
5936         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5937         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
5938         return ret_arr;
5939 }
5940
5941 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5942 CHECK(!owner->result_ok);
5943         return APIError_clone(&*owner->contents.err);
5944 }
5945 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
5946         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
5947         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5948         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
5949         uintptr_t ret_ref = (uintptr_t)ret_copy;
5950         return ret_ref;
5951 }
5952
5953 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
5954         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5955         switch(obj->tag) {
5956                 case LDKPaymentSendFailure_ParameterError: return 0;
5957                 case LDKPaymentSendFailure_PathParameterError: return 1;
5958                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
5959                 case LDKPaymentSendFailure_PartialFailure: return 3;
5960                 default: abort();
5961         }
5962 }
5963 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
5964         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5965         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
5966                         uintptr_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
5967         return parameter_error_ref;
5968 }
5969 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
5970         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5971         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
5972                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
5973                         uint32_tArray path_parameter_error_arr = NULL;
5974                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
5975                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
5976                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
5977                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5978                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
5979                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
5980                                 path_parameter_error_arr_ptr[w] = (uintptr_t)path_parameter_error_conv_22_conv;
5981                         }
5982                         
5983         return path_parameter_error_arr;
5984 }
5985 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
5986         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5987         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
5988                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
5989                         uint32_tArray all_failed_retry_safe_arr = NULL;
5990                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
5991                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
5992                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
5993                                 uintptr_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
5994                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
5995                         }
5996                         
5997         return all_failed_retry_safe_arr;
5998 }
5999 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
6000         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
6001         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
6002                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
6003                         uint32_tArray results_arr = NULL;
6004                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
6005                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
6006                         for (size_t w = 0; w < results_var.datalen; w++) {
6007                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6008                                 *results_conv_22_conv = results_var.data[w];
6009                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
6010                                 results_arr_ptr[w] = (uintptr_t)results_conv_22_conv;
6011                         }
6012                         
6013         return results_arr;
6014 }
6015 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
6016         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
6017         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
6018                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
6019                         uintptr_t failed_paths_retry_ref = 0;
6020                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
6021                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6022                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6023                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
6024                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
6025                         }
6026         return failed_paths_retry_ref;
6027 }
6028 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
6029         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
6030         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
6031                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
6032                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
6033         return payment_id_arr;
6034 }
6035 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6036 CHECK(owner->result_ok);
6037         return ThirtyTwoBytes_clone(&*owner->contents.result);
6038 }
6039 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
6040         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
6041         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6042         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
6043         return ret_arr;
6044 }
6045
6046 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6047 CHECK(!owner->result_ok);
6048         return PaymentSendFailure_clone(&*owner->contents.err);
6049 }
6050 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
6051         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
6052         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6053         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
6054         uintptr_t ret_ref = (uintptr_t)ret_copy;
6055         return ret_ref;
6056 }
6057
6058 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6059 CHECK(owner->result_ok);
6060         return *owner->contents.result;
6061 }
6062 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
6063         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
6064         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
6065 }
6066
6067 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6068 CHECK(!owner->result_ok);
6069         return PaymentSendFailure_clone(&*owner->contents.err);
6070 }
6071 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
6072         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
6073         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6074         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
6075         uintptr_t ret_ref = (uintptr_t)ret_copy;
6076         return ret_ref;
6077 }
6078
6079 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6080         return ThirtyTwoBytes_clone(&owner->a);
6081 }
6082 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
6083         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
6084         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6085         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
6086         return ret_arr;
6087 }
6088
6089 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6090         return ThirtyTwoBytes_clone(&owner->b);
6091 }
6092 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
6093         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
6094         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6095         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
6096         return ret_arr;
6097 }
6098
6099 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6100 CHECK(owner->result_ok);
6101         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
6102 }
6103 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
6104         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
6105         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
6106         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
6107         return ((uintptr_t)ret_conv);
6108 }
6109
6110 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6111 CHECK(!owner->result_ok);
6112         return PaymentSendFailure_clone(&*owner->contents.err);
6113 }
6114 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
6115         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
6116         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6117         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
6118         uintptr_t ret_ref = (uintptr_t)ret_copy;
6119         return ret_ref;
6120 }
6121
6122 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6123         return ThirtyTwoBytes_clone(&owner->a);
6124 }
6125 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
6126         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6127         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6128         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
6129         return ret_arr;
6130 }
6131
6132 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6133         return ThirtyTwoBytes_clone(&owner->b);
6134 }
6135 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
6136         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6137         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6138         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
6139         return ret_arr;
6140 }
6141
6142 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6143 CHECK(owner->result_ok);
6144         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6145 }
6146 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
6147         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6148         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6149         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
6150         return ((uintptr_t)ret_conv);
6151 }
6152
6153 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6154 CHECK(!owner->result_ok);
6155         return *owner->contents.err;
6156 }
6157 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
6158         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6159         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
6160 }
6161
6162 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6163 CHECK(owner->result_ok);
6164         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6165 }
6166 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
6167         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6168         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6169         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
6170         return ((uintptr_t)ret_conv);
6171 }
6172
6173 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6174 CHECK(!owner->result_ok);
6175         return APIError_clone(&*owner->contents.err);
6176 }
6177 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
6178         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6179         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6180         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
6181         uintptr_t ret_ref = (uintptr_t)ret_copy;
6182         return ret_ref;
6183 }
6184
6185 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6186 CHECK(owner->result_ok);
6187         return ThirtyTwoBytes_clone(&*owner->contents.result);
6188 }
6189 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
6190         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6191         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6192         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
6193         return ret_arr;
6194 }
6195
6196 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6197 CHECK(!owner->result_ok);
6198         return *owner->contents.err;
6199 }
6200 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
6201         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6202         CResult_PaymentSecretNoneZ_get_err(owner_conv);
6203 }
6204
6205 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6206 CHECK(owner->result_ok);
6207         return ThirtyTwoBytes_clone(&*owner->contents.result);
6208 }
6209 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
6210         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6211         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6212         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
6213         return ret_arr;
6214 }
6215
6216 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6217 CHECK(!owner->result_ok);
6218         return APIError_clone(&*owner->contents.err);
6219 }
6220 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
6221         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6222         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6223         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6224         uintptr_t ret_ref = (uintptr_t)ret_copy;
6225         return ret_ref;
6226 }
6227
6228 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6229 CHECK(owner->result_ok);
6230         return ThirtyTwoBytes_clone(&*owner->contents.result);
6231 }
6232 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
6233         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6234         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6235         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
6236         return ret_arr;
6237 }
6238
6239 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6240 CHECK(!owner->result_ok);
6241         return APIError_clone(&*owner->contents.err);
6242 }
6243 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
6244         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6245         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6246         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6247         uintptr_t ret_ref = (uintptr_t)ret_copy;
6248         return ret_ref;
6249 }
6250
6251 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6252         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6253         for (size_t i = 0; i < ret.datalen; i++) {
6254                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6255         }
6256         return ret;
6257 }
6258 typedef struct LDKWatch_JCalls {
6259         atomic_size_t refcnt;
6260         uint32_t instance_ptr;
6261 } LDKWatch_JCalls;
6262 static void LDKWatch_JCalls_free(void* this_arg) {
6263         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6264         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6265                 FREE(j_calls);
6266         }
6267 }
6268 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6269         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6270         LDKOutPoint funding_txo_var = funding_txo;
6271         uintptr_t funding_txo_ref = 0;
6272         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6273         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6274         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6275         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6276         if (funding_txo_var.is_owned) {
6277                 funding_txo_ref |= 1;
6278         }
6279         LDKChannelMonitor monitor_var = monitor;
6280         uintptr_t monitor_ref = 0;
6281         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6282         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6283         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
6284         monitor_ref = (uintptr_t)monitor_var.inner;
6285         if (monitor_var.is_owned) {
6286                 monitor_ref |= 1;
6287         }
6288         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 20, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
6289         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6290         CHECK_ACCESS(ret_ptr);
6291         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6292         FREE((void*)ret);
6293         return ret_conv;
6294 }
6295 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
6296         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6297         LDKOutPoint funding_txo_var = funding_txo;
6298         uintptr_t funding_txo_ref = 0;
6299         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6300         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6301         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6302         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6303         if (funding_txo_var.is_owned) {
6304                 funding_txo_ref |= 1;
6305         }
6306         LDKChannelMonitorUpdate update_var = update;
6307         uintptr_t update_ref = 0;
6308         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6309         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6310         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
6311         update_ref = (uintptr_t)update_var.inner;
6312         if (update_var.is_owned) {
6313                 update_ref |= 1;
6314         }
6315         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 21, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
6316         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6317         CHECK_ACCESS(ret_ptr);
6318         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6319         FREE((void*)ret);
6320         return ret_conv;
6321 }
6322 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
6323         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6324         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 22);
6325         LDKCVec_MonitorEventZ ret_constr;
6326         ret_constr.datalen = ret->arr_len;
6327         if (ret_constr.datalen > 0)
6328                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
6329         else
6330                 ret_constr.data = NULL;
6331         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
6332         for (size_t o = 0; o < ret_constr.datalen; o++) {
6333                 uint32_t ret_conv_14 = ret_vals[o];
6334                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
6335                 CHECK_ACCESS(ret_conv_14_ptr);
6336                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
6337                 FREE((void*)ret_conv_14);
6338                 ret_constr.data[o] = ret_conv_14_conv;
6339         }
6340         return ret_constr;
6341 }
6342 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
6343         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
6344         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6345 }
6346 static inline LDKWatch LDKWatch_init (JSValue o) {
6347         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
6348         atomic_init(&calls->refcnt, 1);
6349         calls->instance_ptr = o;
6350
6351         LDKWatch ret = {
6352                 .this_arg = (void*) calls,
6353                 .watch_channel = watch_channel_LDKWatch_jcall,
6354                 .update_channel = update_channel_LDKWatch_jcall,
6355                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
6356                 .free = LDKWatch_JCalls_free,
6357         };
6358         return ret;
6359 }
6360 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
6361         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
6362         *res_ptr = LDKWatch_init(o);
6363         return (long)res_ptr;
6364 }
6365 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
6366         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6367         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6368         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6369         LDKOutPoint funding_txo_conv;
6370         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6371         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6372         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6373         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6374         LDKChannelMonitor monitor_conv;
6375         monitor_conv.inner = (void*)(monitor & (~1));
6376         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
6377         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
6378         monitor_conv = ChannelMonitor_clone(&monitor_conv);
6379         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6380         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
6381         return (uintptr_t)ret_conv;
6382 }
6383
6384 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
6385         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6386         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6387         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6388         LDKOutPoint funding_txo_conv;
6389         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6390         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6391         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6392         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6393         LDKChannelMonitorUpdate update_conv;
6394         update_conv.inner = (void*)(update & (~1));
6395         update_conv.is_owned = (update & 1) || (update == 0);
6396         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
6397         update_conv = ChannelMonitorUpdate_clone(&update_conv);
6398         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6399         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
6400         return (uintptr_t)ret_conv;
6401 }
6402
6403 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
6404         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6405         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6406         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6407         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
6408         uint32_tArray ret_arr = NULL;
6409         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6410         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6411         for (size_t o = 0; o < ret_var.datalen; o++) {
6412                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
6413                 *ret_conv_14_copy = ret_var.data[o];
6414                 uintptr_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
6415                 ret_arr_ptr[o] = ret_conv_14_ref;
6416         }
6417         
6418         FREE(ret_var.data);
6419         return ret_arr;
6420 }
6421
6422 typedef struct LDKBroadcasterInterface_JCalls {
6423         atomic_size_t refcnt;
6424         uint32_t instance_ptr;
6425 } LDKBroadcasterInterface_JCalls;
6426 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
6427         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6428         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6429                 FREE(j_calls);
6430         }
6431 }
6432 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
6433         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6434         LDKTransaction tx_var = tx;
6435         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
6436         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
6437         Transaction_free(tx_var);
6438         js_invoke_function_1(j_calls->instance_ptr, 23, (uint32_t)tx_arr);
6439 }
6440 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
6441         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
6442         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6443 }
6444 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
6445         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
6446         atomic_init(&calls->refcnt, 1);
6447         calls->instance_ptr = o;
6448
6449         LDKBroadcasterInterface ret = {
6450                 .this_arg = (void*) calls,
6451                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
6452                 .free = LDKBroadcasterInterface_JCalls_free,
6453         };
6454         return ret;
6455 }
6456 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
6457         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
6458         *res_ptr = LDKBroadcasterInterface_init(o);
6459         return (long)res_ptr;
6460 }
6461 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
6462         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6463         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6464         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
6465         LDKTransaction tx_ref;
6466         tx_ref.datalen = tx->arr_len;
6467         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
6468         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
6469         tx_ref.data_is_owned = true;
6470         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
6471 }
6472
6473 typedef struct LDKKeysInterface_JCalls {
6474         atomic_size_t refcnt;
6475         uint32_t instance_ptr;
6476 } LDKKeysInterface_JCalls;
6477 static void LDKKeysInterface_JCalls_free(void* this_arg) {
6478         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6479         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6480                 FREE(j_calls);
6481         }
6482 }
6483 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
6484         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6485         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 24);
6486         LDKSecretKey ret_ref;
6487         CHECK(ret->arr_len == 32);
6488         memcpy(ret_ref.bytes, ret->elems, 32); FREE(ret);
6489         return ret_ref;
6490 }
6491 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
6492         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6493         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 25);
6494         LDKCVec_u8Z ret_ref;
6495         ret_ref.datalen = ret->arr_len;
6496         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6497         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
6498         return ret_ref;
6499 }
6500 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
6501         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6502         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 26);
6503         LDKShutdownScript ret_conv;
6504         ret_conv.inner = (void*)(ret & (~1));
6505         ret_conv.is_owned = (ret & 1) || (ret == 0);
6506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
6507         return ret_conv;
6508 }
6509 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
6510         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6511         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 27, (uint32_t)inbound, (uint32_t)channel_value_satoshis);
6512         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6513         CHECK_ACCESS(ret_ptr);
6514         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
6515         FREE((void*)ret);
6516         return ret_conv;
6517 }
6518 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
6519         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6520         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 28);
6521         LDKThirtyTwoBytes ret_ref;
6522         CHECK(ret->arr_len == 32);
6523         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
6524         return ret_ref;
6525 }
6526 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
6527         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6528         LDKu8slice reader_var = reader;
6529         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
6530         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
6531         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 29, (uint32_t)reader_arr);
6532         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6533         CHECK_ACCESS(ret_ptr);
6534         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
6535         FREE((void*)ret);
6536         return ret_conv;
6537 }
6538 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
6539         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6540         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
6541         int8_tArray invoice_preimage_arr = init_int8_tArray(invoice_preimage_var.datalen, __LINE__);
6542         memcpy(invoice_preimage_arr->elems, invoice_preimage_var.data, invoice_preimage_var.datalen);
6543         CVec_u8Z_free(invoice_preimage_var);
6544         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 30, (uint32_t)invoice_preimage_arr);
6545         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6546         CHECK_ACCESS(ret_ptr);
6547         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
6548         FREE((void*)ret);
6549         return ret_conv;
6550 }
6551 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
6552         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6553         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 31);
6554         LDKThirtyTwoBytes ret_ref;
6555         CHECK(ret->arr_len == 32);
6556         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
6557         return ret_ref;
6558 }
6559 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
6560         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
6561         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6562 }
6563 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
6564         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
6565         atomic_init(&calls->refcnt, 1);
6566         calls->instance_ptr = o;
6567
6568         LDKKeysInterface ret = {
6569                 .this_arg = (void*) calls,
6570                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
6571                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
6572                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
6573                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
6574                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
6575                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
6576                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
6577                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
6578                 .free = LDKKeysInterface_JCalls_free,
6579         };
6580         return ret;
6581 }
6582 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
6583         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6584         *res_ptr = LDKKeysInterface_init(o);
6585         return (long)res_ptr;
6586 }
6587 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
6588         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6589         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6590         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6591         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6592         memcpy(ret_arr->elems, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
6593         return ret_arr;
6594 }
6595
6596 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
6597         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6598         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6599         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6600         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
6601         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6602         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6603         CVec_u8Z_free(ret_var);
6604         return ret_arr;
6605 }
6606
6607 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
6608         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6609         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6610         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6611         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6612         uintptr_t ret_ref = 0;
6613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6616         ret_ref = (uintptr_t)ret_var.inner;
6617         if (ret_var.is_owned) {
6618                 ret_ref |= 1;
6619         }
6620         return ret_ref;
6621 }
6622
6623 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) {
6624         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6625         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6626         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6627         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6628         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
6629         return (uintptr_t)ret_ret;
6630 }
6631
6632 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
6633         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6634         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6635         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6636         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6637         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
6638         return ret_arr;
6639 }
6640
6641 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
6642         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6643         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6644         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6645         LDKu8slice reader_ref;
6646         reader_ref.datalen = reader->arr_len;
6647         reader_ref.data = reader->elems /* XXX reader leaks */;
6648         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
6649         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6650         return (uintptr_t)ret_conv;
6651 }
6652
6653 uint32_t  __attribute__((export_name("TS_KeysInterface_sign_invoice"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
6654         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6655         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6656         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6657         LDKCVec_u8Z invoice_preimage_ref;
6658         invoice_preimage_ref.datalen = invoice_preimage->arr_len;
6659         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
6660         memcpy(invoice_preimage_ref.data, invoice_preimage->elems, invoice_preimage_ref.datalen); FREE(invoice_preimage);
6661         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6662         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
6663         return (uintptr_t)ret_conv;
6664 }
6665
6666 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
6667         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6668         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6669         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6670         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6671         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
6672         return ret_arr;
6673 }
6674
6675 typedef struct LDKFeeEstimator_JCalls {
6676         atomic_size_t refcnt;
6677         uint32_t instance_ptr;
6678 } LDKFeeEstimator_JCalls;
6679 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
6680         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6681         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6682                 FREE(j_calls);
6683         }
6684 }
6685 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
6686         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6687         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
6688         return js_invoke_function_1(j_calls->instance_ptr, 32, (uint32_t)confirmation_target_conv);
6689 }
6690 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
6691         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
6692         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6693 }
6694 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
6695         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
6696         atomic_init(&calls->refcnt, 1);
6697         calls->instance_ptr = o;
6698
6699         LDKFeeEstimator ret = {
6700                 .this_arg = (void*) calls,
6701                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
6702                 .free = LDKFeeEstimator_JCalls_free,
6703         };
6704         return ret;
6705 }
6706 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
6707         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
6708         *res_ptr = LDKFeeEstimator_init(o);
6709         return (long)res_ptr;
6710 }
6711 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) {
6712         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6713         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6714         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
6715         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
6716         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
6717         return ret_val;
6718 }
6719
6720 typedef struct LDKLogger_JCalls {
6721         atomic_size_t refcnt;
6722         uint32_t instance_ptr;
6723 } LDKLogger_JCalls;
6724 static void LDKLogger_JCalls_free(void* this_arg) {
6725         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6726         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6727                 FREE(j_calls);
6728         }
6729 }
6730 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
6731         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6732         LDKRecord record_var = *record;
6733         uintptr_t record_ref = 0;
6734         record_var = Record_clone(record);
6735         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6736         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6737         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
6738         record_ref = (uintptr_t)record_var.inner;
6739         if (record_var.is_owned) {
6740                 record_ref |= 1;
6741         }
6742         js_invoke_function_1(j_calls->instance_ptr, 33, (uint32_t)record_ref);
6743 }
6744 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
6745         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
6746         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6747 }
6748 static inline LDKLogger LDKLogger_init (JSValue o) {
6749         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
6750         atomic_init(&calls->refcnt, 1);
6751         calls->instance_ptr = o;
6752
6753         LDKLogger ret = {
6754                 .this_arg = (void*) calls,
6755                 .log = log_LDKLogger_jcall,
6756                 .free = LDKLogger_JCalls_free,
6757         };
6758         return ret;
6759 }
6760 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
6761         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
6762         *res_ptr = LDKLogger_init(o);
6763         return (long)res_ptr;
6764 }
6765 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6766         return ThirtyTwoBytes_clone(&owner->a);
6767 }
6768 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
6769         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6770         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6771         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
6772         return ret_arr;
6773 }
6774
6775 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6776         return &owner->b;
6777 }
6778 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
6779         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6780         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
6781         uintptr_t ret_ref = 0;
6782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6785         ret_ref = (uintptr_t)ret_var.inner & ~1;
6786         return ret_ref;
6787 }
6788
6789 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6790 CHECK(owner->result_ok);
6791         return &*owner->contents.result;
6792 }
6793 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
6794         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6795         uintptr_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
6796         return ret_ret;
6797 }
6798
6799 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6800 CHECK(!owner->result_ok);
6801         return DecodeError_clone(&*owner->contents.err);
6802 }
6803 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
6804         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6805         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
6806         uintptr_t ret_ref = 0;
6807         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6808         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6810         ret_ref = (uintptr_t)ret_var.inner;
6811         if (ret_var.is_owned) {
6812                 ret_ref |= 1;
6813         }
6814         return ret_ref;
6815 }
6816
6817 typedef struct LDKMessageSendEventsProvider_JCalls {
6818         atomic_size_t refcnt;
6819         uint32_t instance_ptr;
6820 } LDKMessageSendEventsProvider_JCalls;
6821 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
6822         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6823         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6824                 FREE(j_calls);
6825         }
6826 }
6827 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
6828         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6829         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 34);
6830         LDKCVec_MessageSendEventZ ret_constr;
6831         ret_constr.datalen = ret->arr_len;
6832         if (ret_constr.datalen > 0)
6833                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
6834         else
6835                 ret_constr.data = NULL;
6836         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
6837         for (size_t s = 0; s < ret_constr.datalen; s++) {
6838                 uint32_t ret_conv_18 = ret_vals[s];
6839                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
6840                 CHECK_ACCESS(ret_conv_18_ptr);
6841                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
6842                 FREE((void*)ret_conv_18);
6843                 ret_constr.data[s] = ret_conv_18_conv;
6844         }
6845         return ret_constr;
6846 }
6847 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
6848         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
6849         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6850 }
6851 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
6852         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
6853         atomic_init(&calls->refcnt, 1);
6854         calls->instance_ptr = o;
6855
6856         LDKMessageSendEventsProvider ret = {
6857                 .this_arg = (void*) calls,
6858                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6859                 .free = LDKMessageSendEventsProvider_JCalls_free,
6860         };
6861         return ret;
6862 }
6863 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
6864         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6865         *res_ptr = LDKMessageSendEventsProvider_init(o);
6866         return (long)res_ptr;
6867 }
6868 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) {
6869         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6870         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6871         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
6872         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6873         uint32_tArray ret_arr = NULL;
6874         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6875         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6876         for (size_t s = 0; s < ret_var.datalen; s++) {
6877                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6878                 *ret_conv_18_copy = ret_var.data[s];
6879                 uintptr_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
6880                 ret_arr_ptr[s] = ret_conv_18_ref;
6881         }
6882         
6883         FREE(ret_var.data);
6884         return ret_arr;
6885 }
6886
6887 typedef struct LDKEventHandler_JCalls {
6888         atomic_size_t refcnt;
6889         uint32_t instance_ptr;
6890 } LDKEventHandler_JCalls;
6891 static void LDKEventHandler_JCalls_free(void* this_arg) {
6892         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6893         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6894                 FREE(j_calls);
6895         }
6896 }
6897 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
6898         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6899         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
6900         *ret_event = Event_clone(event);
6901         js_invoke_function_1(j_calls->instance_ptr, 35, (uint32_t)(uintptr_t)ret_event);
6902 }
6903 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
6904         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
6905         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6906 }
6907 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
6908         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6909         atomic_init(&calls->refcnt, 1);
6910         calls->instance_ptr = o;
6911
6912         LDKEventHandler ret = {
6913                 .this_arg = (void*) calls,
6914                 .handle_event = handle_event_LDKEventHandler_jcall,
6915                 .free = LDKEventHandler_JCalls_free,
6916         };
6917         return ret;
6918 }
6919 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
6920         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6921         *res_ptr = LDKEventHandler_init(o);
6922         return (long)res_ptr;
6923 }
6924 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
6925         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6926         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6927         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
6928         LDKEvent* event_conv = (LDKEvent*)event;
6929         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6930 }
6931
6932 typedef struct LDKEventsProvider_JCalls {
6933         atomic_size_t refcnt;
6934         uint32_t instance_ptr;
6935 } LDKEventsProvider_JCalls;
6936 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6937         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6938         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6939                 FREE(j_calls);
6940         }
6941 }
6942 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6943         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6944         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6945         *handler_ret = handler;
6946         js_invoke_function_1(j_calls->instance_ptr, 36, (uint32_t)(uintptr_t)handler_ret);
6947 }
6948 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
6949         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
6950         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6951 }
6952 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
6953         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6954         atomic_init(&calls->refcnt, 1);
6955         calls->instance_ptr = o;
6956
6957         LDKEventsProvider ret = {
6958                 .this_arg = (void*) calls,
6959                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6960                 .free = LDKEventsProvider_JCalls_free,
6961         };
6962         return ret;
6963 }
6964 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
6965         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6966         *res_ptr = LDKEventsProvider_init(o);
6967         return (long)res_ptr;
6968 }
6969 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
6970         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6971         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6972         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
6973         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
6974         CHECK_ACCESS(handler_ptr);
6975         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
6976         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6977 }
6978
6979 typedef struct LDKListen_JCalls {
6980         atomic_size_t refcnt;
6981         uint32_t instance_ptr;
6982 } LDKListen_JCalls;
6983 static void LDKListen_JCalls_free(void* this_arg) {
6984         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6985         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6986                 FREE(j_calls);
6987         }
6988 }
6989 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6990         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6991         LDKu8slice block_var = block;
6992         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
6993         memcpy(block_arr->elems, block_var.data, block_var.datalen);
6994         js_invoke_function_2(j_calls->instance_ptr, 37, (uint32_t)block_arr, (uint32_t)height);
6995 }
6996 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6997         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6998         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
6999         memcpy(header_arr->elems, *header, 80);
7000         js_invoke_function_2(j_calls->instance_ptr, 38, (uint32_t)header_arr, (uint32_t)height);
7001 }
7002 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
7003         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
7004         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7005 }
7006 static inline LDKListen LDKListen_init (JSValue o) {
7007         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
7008         atomic_init(&calls->refcnt, 1);
7009         calls->instance_ptr = o;
7010
7011         LDKListen ret = {
7012                 .this_arg = (void*) calls,
7013                 .block_connected = block_connected_LDKListen_jcall,
7014                 .block_disconnected = block_disconnected_LDKListen_jcall,
7015                 .free = LDKListen_JCalls_free,
7016         };
7017         return ret;
7018 }
7019 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
7020         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
7021         *res_ptr = LDKListen_init(o);
7022         return (long)res_ptr;
7023 }
7024 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
7025         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7026         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7027         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7028         LDKu8slice block_ref;
7029         block_ref.datalen = block->arr_len;
7030         block_ref.data = block->elems /* XXX block leaks */;
7031         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
7032 }
7033
7034 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
7035         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7036         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7037         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7038         unsigned char header_arr[80];
7039         CHECK(header->arr_len == 80);
7040         memcpy(header_arr, header->elems, 80); FREE(header);
7041         unsigned char (*header_ref)[80] = &header_arr;
7042         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
7043 }
7044
7045 typedef struct LDKConfirm_JCalls {
7046         atomic_size_t refcnt;
7047         uint32_t instance_ptr;
7048 } LDKConfirm_JCalls;
7049 static void LDKConfirm_JCalls_free(void* this_arg) {
7050         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7051         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7052                 FREE(j_calls);
7053         }
7054 }
7055 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
7056         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7057         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
7058         memcpy(header_arr->elems, *header, 80);
7059         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
7060         uint32_tArray txdata_arr = NULL;
7061         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
7062         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
7063         for (size_t c = 0; c < txdata_var.datalen; c++) {
7064                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7065                 *txdata_conv_28_conv = txdata_var.data[c];
7066                 txdata_arr_ptr[c] = ((uintptr_t)txdata_conv_28_conv);
7067         }
7068         
7069         FREE(txdata_var.data);
7070         js_invoke_function_3(j_calls->instance_ptr, 39, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height);
7071 }
7072 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
7073         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7074         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
7075         memcpy(txid_arr->elems, *txid, 32);
7076         js_invoke_function_1(j_calls->instance_ptr, 40, (uint32_t)txid_arr);
7077 }
7078 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7079         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7080         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
7081         memcpy(header_arr->elems, *header, 80);
7082         js_invoke_function_2(j_calls->instance_ptr, 41, (uint32_t)header_arr, (uint32_t)height);
7083 }
7084 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
7085         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7086         ptrArray ret = (ptrArray)js_invoke_function_0(j_calls->instance_ptr, 42);
7087         LDKCVec_TxidZ ret_constr;
7088         ret_constr.datalen = ret->arr_len;
7089         if (ret_constr.datalen > 0)
7090                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7091         else
7092                 ret_constr.data = NULL;
7093         int8_tArray* ret_vals = (void*) ret->elems /* XXX ret leaks */;
7094         for (size_t m = 0; m < ret_constr.datalen; m++) {
7095                 int8_tArray ret_conv_12 = ret_vals[m];
7096                 LDKThirtyTwoBytes ret_conv_12_ref;
7097                 CHECK(ret_conv_12->arr_len == 32);
7098                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
7099                 ret_constr.data[m] = ret_conv_12_ref;
7100         }
7101         return ret_constr;
7102 }
7103 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
7104         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
7105         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7106 }
7107 static inline LDKConfirm LDKConfirm_init (JSValue o) {
7108         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
7109         atomic_init(&calls->refcnt, 1);
7110         calls->instance_ptr = o;
7111
7112         LDKConfirm ret = {
7113                 .this_arg = (void*) calls,
7114                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
7115                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
7116                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
7117                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
7118                 .free = LDKConfirm_JCalls_free,
7119         };
7120         return ret;
7121 }
7122 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
7123         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
7124         *res_ptr = LDKConfirm_init(o);
7125         return (long)res_ptr;
7126 }
7127 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) {
7128         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7129         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7130         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7131         unsigned char header_arr[80];
7132         CHECK(header->arr_len == 80);
7133         memcpy(header_arr, header->elems, 80); FREE(header);
7134         unsigned char (*header_ref)[80] = &header_arr;
7135         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
7136         txdata_constr.datalen = txdata->arr_len;
7137         if (txdata_constr.datalen > 0)
7138                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7139         else
7140                 txdata_constr.data = NULL;
7141         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
7142         for (size_t c = 0; c < txdata_constr.datalen; c++) {
7143                 uint32_t txdata_conv_28 = txdata_vals[c];
7144                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
7145                 CHECK_ACCESS(txdata_conv_28_ptr);
7146                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
7147                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
7148                 txdata_constr.data[c] = txdata_conv_28_conv;
7149         }
7150         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
7151 }
7152
7153 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
7154         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7155         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7156         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7157         unsigned char txid_arr[32];
7158         CHECK(txid->arr_len == 32);
7159         memcpy(txid_arr, txid->elems, 32); FREE(txid);
7160         unsigned char (*txid_ref)[32] = &txid_arr;
7161         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
7162 }
7163
7164 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
7165         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7166         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7167         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7168         unsigned char header_arr[80];
7169         CHECK(header->arr_len == 80);
7170         memcpy(header_arr, header->elems, 80); FREE(header);
7171         unsigned char (*header_ref)[80] = &header_arr;
7172         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
7173 }
7174
7175 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
7176         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7177         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7178         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7179         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
7180         ptrArray ret_arr = NULL;
7181         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
7182         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
7183         for (size_t m = 0; m < ret_var.datalen; m++) {
7184                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
7185                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
7186                 ret_arr_ptr[m] = ret_conv_12_arr;
7187         }
7188         
7189         FREE(ret_var.data);
7190         return ret_arr;
7191 }
7192
7193 typedef struct LDKPersist_JCalls {
7194         atomic_size_t refcnt;
7195         uint32_t instance_ptr;
7196 } LDKPersist_JCalls;
7197 static void LDKPersist_JCalls_free(void* this_arg) {
7198         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7199         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7200                 FREE(j_calls);
7201         }
7202 }
7203 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
7204         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7205         LDKOutPoint channel_id_var = channel_id;
7206         uintptr_t channel_id_ref = 0;
7207         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7208         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7209         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
7210         channel_id_ref = (uintptr_t)channel_id_var.inner;
7211         if (channel_id_var.is_owned) {
7212                 channel_id_ref |= 1;
7213         }
7214         LDKChannelMonitor data_var = *data;
7215         uintptr_t data_ref = 0;
7216         data_var = ChannelMonitor_clone(data);
7217         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7218         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7219         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
7220         data_ref = (uintptr_t)data_var.inner;
7221         if (data_var.is_owned) {
7222                 data_ref |= 1;
7223         }
7224         LDKMonitorUpdateId update_id_var = update_id;
7225         uintptr_t update_id_ref = 0;
7226         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7227         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7228         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
7229         update_id_ref = (uintptr_t)update_id_var.inner;
7230         if (update_id_var.is_owned) {
7231                 update_id_ref |= 1;
7232         }
7233         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);
7234         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7235         CHECK_ACCESS(ret_ptr);
7236         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
7237         FREE((void*)ret);
7238         return ret_conv;
7239 }
7240 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
7241         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7242         LDKOutPoint channel_id_var = channel_id;
7243         uintptr_t channel_id_ref = 0;
7244         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7245         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7246         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
7247         channel_id_ref = (uintptr_t)channel_id_var.inner;
7248         if (channel_id_var.is_owned) {
7249                 channel_id_ref |= 1;
7250         }
7251         LDKChannelMonitorUpdate update_var = *update;
7252         uintptr_t update_ref = 0;
7253         if ((uintptr_t)update_var.inner > 4096) {
7254                 update_var = ChannelMonitorUpdate_clone(update);
7255                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7256                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7257         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
7258                 update_ref = (uintptr_t)update_var.inner;
7259                 if (update_var.is_owned) {
7260                         update_ref |= 1;
7261                 }
7262         }
7263         LDKChannelMonitor data_var = *data;
7264         uintptr_t data_ref = 0;
7265         data_var = ChannelMonitor_clone(data);
7266         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7267         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7268         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
7269         data_ref = (uintptr_t)data_var.inner;
7270         if (data_var.is_owned) {
7271                 data_ref |= 1;
7272         }
7273         LDKMonitorUpdateId update_id_var = update_id;
7274         uintptr_t update_id_ref = 0;
7275         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7276         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7277         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
7278         update_id_ref = (uintptr_t)update_id_var.inner;
7279         if (update_id_var.is_owned) {
7280                 update_id_ref |= 1;
7281         }
7282         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);
7283         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7284         CHECK_ACCESS(ret_ptr);
7285         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
7286         FREE((void*)ret);
7287         return ret_conv;
7288 }
7289 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
7290         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
7291         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7292 }
7293 static inline LDKPersist LDKPersist_init (JSValue o) {
7294         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
7295         atomic_init(&calls->refcnt, 1);
7296         calls->instance_ptr = o;
7297
7298         LDKPersist ret = {
7299                 .this_arg = (void*) calls,
7300                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
7301                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
7302                 .free = LDKPersist_JCalls_free,
7303         };
7304         return ret;
7305 }
7306 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
7307         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
7308         *res_ptr = LDKPersist_init(o);
7309         return (long)res_ptr;
7310 }
7311 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) {
7312         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7313         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7314         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
7315         LDKOutPoint channel_id_conv;
7316         channel_id_conv.inner = (void*)(channel_id & (~1));
7317         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
7318         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
7319         channel_id_conv = OutPoint_clone(&channel_id_conv);
7320         LDKChannelMonitor data_conv;
7321         data_conv.inner = (void*)(data & (~1));
7322         data_conv.is_owned = false;
7323         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
7324         LDKMonitorUpdateId update_id_conv;
7325         update_id_conv.inner = (void*)(update_id & (~1));
7326         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
7327         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
7328         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
7329         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7330         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
7331         return (uintptr_t)ret_conv;
7332 }
7333
7334 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) {
7335         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7336         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7337         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
7338         LDKOutPoint channel_id_conv;
7339         channel_id_conv.inner = (void*)(channel_id & (~1));
7340         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
7341         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
7342         channel_id_conv = OutPoint_clone(&channel_id_conv);
7343         LDKChannelMonitorUpdate update_conv;
7344         update_conv.inner = (void*)(update & (~1));
7345         update_conv.is_owned = false;
7346         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
7347         LDKChannelMonitor data_conv;
7348         data_conv.inner = (void*)(data & (~1));
7349         data_conv.is_owned = false;
7350         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
7351         LDKMonitorUpdateId update_id_conv;
7352         update_id_conv.inner = (void*)(update_id & (~1));
7353         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
7354         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
7355         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
7356         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7357         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
7358         return (uintptr_t)ret_conv;
7359 }
7360
7361 typedef struct LDKChannelMessageHandler_JCalls {
7362         atomic_size_t refcnt;
7363         uint32_t instance_ptr;
7364         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7365 } LDKChannelMessageHandler_JCalls;
7366 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
7367         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7368         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7369                 FREE(j_calls);
7370         }
7371 }
7372 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
7373         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7374         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7375         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7376         LDKInitFeatures their_features_var = their_features;
7377         uintptr_t their_features_ref = 0;
7378         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7379         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7380         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
7381         their_features_ref = (uintptr_t)their_features_var.inner;
7382         if (their_features_var.is_owned) {
7383                 their_features_ref |= 1;
7384         }
7385         LDKOpenChannel msg_var = *msg;
7386         uintptr_t msg_ref = 0;
7387         msg_var = OpenChannel_clone(msg);
7388         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7389         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7390         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7391         msg_ref = (uintptr_t)msg_var.inner;
7392         if (msg_var.is_owned) {
7393                 msg_ref |= 1;
7394         }
7395         js_invoke_function_3(j_calls->instance_ptr, 45, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
7396 }
7397 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
7398         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7399         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7400         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7401         LDKInitFeatures their_features_var = their_features;
7402         uintptr_t their_features_ref = 0;
7403         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7404         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7405         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
7406         their_features_ref = (uintptr_t)their_features_var.inner;
7407         if (their_features_var.is_owned) {
7408                 their_features_ref |= 1;
7409         }
7410         LDKAcceptChannel msg_var = *msg;
7411         uintptr_t msg_ref = 0;
7412         msg_var = AcceptChannel_clone(msg);
7413         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7414         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7415         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7416         msg_ref = (uintptr_t)msg_var.inner;
7417         if (msg_var.is_owned) {
7418                 msg_ref |= 1;
7419         }
7420         js_invoke_function_3(j_calls->instance_ptr, 46, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
7421 }
7422 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
7423         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7424         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7425         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7426         LDKFundingCreated msg_var = *msg;
7427         uintptr_t msg_ref = 0;
7428         msg_var = FundingCreated_clone(msg);
7429         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7430         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7431         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7432         msg_ref = (uintptr_t)msg_var.inner;
7433         if (msg_var.is_owned) {
7434                 msg_ref |= 1;
7435         }
7436         js_invoke_function_2(j_calls->instance_ptr, 47, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7437 }
7438 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7439         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7440         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7441         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7442         LDKFundingSigned msg_var = *msg;
7443         uintptr_t msg_ref = 0;
7444         msg_var = FundingSigned_clone(msg);
7445         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7446         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7447         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7448         msg_ref = (uintptr_t)msg_var.inner;
7449         if (msg_var.is_owned) {
7450                 msg_ref |= 1;
7451         }
7452         js_invoke_function_2(j_calls->instance_ptr, 48, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7453 }
7454 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7455         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7456         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7457         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7458         LDKFundingLocked msg_var = *msg;
7459         uintptr_t msg_ref = 0;
7460         msg_var = FundingLocked_clone(msg);
7461         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7462         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7463         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7464         msg_ref = (uintptr_t)msg_var.inner;
7465         if (msg_var.is_owned) {
7466                 msg_ref |= 1;
7467         }
7468         js_invoke_function_2(j_calls->instance_ptr, 49, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7469 }
7470 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7471         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7472         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7473         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7474         LDKInitFeatures their_features_var = *their_features;
7475         uintptr_t their_features_ref = 0;
7476         their_features_var = InitFeatures_clone(their_features);
7477         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7478         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7479         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
7480         their_features_ref = (uintptr_t)their_features_var.inner;
7481         if (their_features_var.is_owned) {
7482                 their_features_ref |= 1;
7483         }
7484         LDKShutdown msg_var = *msg;
7485         uintptr_t msg_ref = 0;
7486         msg_var = Shutdown_clone(msg);
7487         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7488         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7489         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7490         msg_ref = (uintptr_t)msg_var.inner;
7491         if (msg_var.is_owned) {
7492                 msg_ref |= 1;
7493         }
7494         js_invoke_function_3(j_calls->instance_ptr, 50, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
7495 }
7496 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7497         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7498         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7499         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7500         LDKClosingSigned msg_var = *msg;
7501         uintptr_t msg_ref = 0;
7502         msg_var = ClosingSigned_clone(msg);
7503         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7504         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7505         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7506         msg_ref = (uintptr_t)msg_var.inner;
7507         if (msg_var.is_owned) {
7508                 msg_ref |= 1;
7509         }
7510         js_invoke_function_2(j_calls->instance_ptr, 51, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7511 }
7512 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7513         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7514         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7515         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7516         LDKUpdateAddHTLC msg_var = *msg;
7517         uintptr_t msg_ref = 0;
7518         msg_var = UpdateAddHTLC_clone(msg);
7519         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7520         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7521         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7522         msg_ref = (uintptr_t)msg_var.inner;
7523         if (msg_var.is_owned) {
7524                 msg_ref |= 1;
7525         }
7526         js_invoke_function_2(j_calls->instance_ptr, 52, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7527 }
7528 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7529         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7530         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7531         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7532         LDKUpdateFulfillHTLC msg_var = *msg;
7533         uintptr_t msg_ref = 0;
7534         msg_var = UpdateFulfillHTLC_clone(msg);
7535         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7536         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7537         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7538         msg_ref = (uintptr_t)msg_var.inner;
7539         if (msg_var.is_owned) {
7540                 msg_ref |= 1;
7541         }
7542         js_invoke_function_2(j_calls->instance_ptr, 53, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7543 }
7544 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7545         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7546         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7547         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7548         LDKUpdateFailHTLC msg_var = *msg;
7549         uintptr_t msg_ref = 0;
7550         msg_var = UpdateFailHTLC_clone(msg);
7551         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7552         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7553         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7554         msg_ref = (uintptr_t)msg_var.inner;
7555         if (msg_var.is_owned) {
7556                 msg_ref |= 1;
7557         }
7558         js_invoke_function_2(j_calls->instance_ptr, 54, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7559 }
7560 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7561         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7562         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7563         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7564         LDKUpdateFailMalformedHTLC msg_var = *msg;
7565         uintptr_t msg_ref = 0;
7566         msg_var = UpdateFailMalformedHTLC_clone(msg);
7567         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7568         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7569         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7570         msg_ref = (uintptr_t)msg_var.inner;
7571         if (msg_var.is_owned) {
7572                 msg_ref |= 1;
7573         }
7574         js_invoke_function_2(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7575 }
7576 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7577         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7578         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7579         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7580         LDKCommitmentSigned msg_var = *msg;
7581         uintptr_t msg_ref = 0;
7582         msg_var = CommitmentSigned_clone(msg);
7583         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7584         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7585         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7586         msg_ref = (uintptr_t)msg_var.inner;
7587         if (msg_var.is_owned) {
7588                 msg_ref |= 1;
7589         }
7590         js_invoke_function_2(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7591 }
7592 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7593         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7594         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7595         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7596         LDKRevokeAndACK msg_var = *msg;
7597         uintptr_t msg_ref = 0;
7598         msg_var = RevokeAndACK_clone(msg);
7599         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7600         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7601         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7602         msg_ref = (uintptr_t)msg_var.inner;
7603         if (msg_var.is_owned) {
7604                 msg_ref |= 1;
7605         }
7606         js_invoke_function_2(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7607 }
7608 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7609         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7610         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7611         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7612         LDKUpdateFee msg_var = *msg;
7613         uintptr_t msg_ref = 0;
7614         msg_var = UpdateFee_clone(msg);
7615         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7616         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7617         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7618         msg_ref = (uintptr_t)msg_var.inner;
7619         if (msg_var.is_owned) {
7620                 msg_ref |= 1;
7621         }
7622         js_invoke_function_2(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7623 }
7624 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7625         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7626         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7627         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7628         LDKAnnouncementSignatures msg_var = *msg;
7629         uintptr_t msg_ref = 0;
7630         msg_var = AnnouncementSignatures_clone(msg);
7631         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7632         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7633         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7634         msg_ref = (uintptr_t)msg_var.inner;
7635         if (msg_var.is_owned) {
7636                 msg_ref |= 1;
7637         }
7638         js_invoke_function_2(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7639 }
7640 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7641         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7642         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7643         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7644         js_invoke_function_2(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible);
7645 }
7646 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7647         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7648         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7649         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7650         LDKInit msg_var = *msg;
7651         uintptr_t msg_ref = 0;
7652         msg_var = Init_clone(msg);
7653         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7654         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7655         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7656         msg_ref = (uintptr_t)msg_var.inner;
7657         if (msg_var.is_owned) {
7658                 msg_ref |= 1;
7659         }
7660         js_invoke_function_2(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7661 }
7662 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7663         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7664         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7665         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7666         LDKChannelReestablish msg_var = *msg;
7667         uintptr_t msg_ref = 0;
7668         msg_var = ChannelReestablish_clone(msg);
7669         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7670         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7671         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7672         msg_ref = (uintptr_t)msg_var.inner;
7673         if (msg_var.is_owned) {
7674                 msg_ref |= 1;
7675         }
7676         js_invoke_function_2(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7677 }
7678 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
7679         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7680         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7681         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7682         LDKChannelUpdate msg_var = *msg;
7683         uintptr_t msg_ref = 0;
7684         msg_var = ChannelUpdate_clone(msg);
7685         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7686         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7687         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7688         msg_ref = (uintptr_t)msg_var.inner;
7689         if (msg_var.is_owned) {
7690                 msg_ref |= 1;
7691         }
7692         js_invoke_function_2(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7693 }
7694 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7695         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7696         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7697         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7698         LDKErrorMessage msg_var = *msg;
7699         uintptr_t msg_ref = 0;
7700         msg_var = ErrorMessage_clone(msg);
7701         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7702         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7703         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7704         msg_ref = (uintptr_t)msg_var.inner;
7705         if (msg_var.is_owned) {
7706                 msg_ref |= 1;
7707         }
7708         js_invoke_function_2(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7709 }
7710 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
7711         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
7712         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7713         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7714 }
7715 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
7716         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7717         atomic_init(&calls->refcnt, 1);
7718         calls->instance_ptr = o;
7719
7720         LDKChannelMessageHandler ret = {
7721                 .this_arg = (void*) calls,
7722                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7723                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7724                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7725                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7726                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7727                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7728                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7729                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7730                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7731                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7732                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7733                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7734                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7735                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7736                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7737                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7738                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7739                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7740                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7741                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7742                 .free = LDKChannelMessageHandler_JCalls_free,
7743                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
7744         };
7745         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7746         return ret;
7747 }
7748 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
7749         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7750         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
7751         return (long)res_ptr;
7752 }
7753 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) {
7754         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7755         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7756         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7757         LDKPublicKey their_node_id_ref;
7758         CHECK(their_node_id->arr_len == 33);
7759         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7760         LDKInitFeatures their_features_conv;
7761         their_features_conv.inner = (void*)(their_features & (~1));
7762         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7763         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
7764         their_features_conv = InitFeatures_clone(&their_features_conv);
7765         LDKOpenChannel msg_conv;
7766         msg_conv.inner = (void*)(msg & (~1));
7767         msg_conv.is_owned = false;
7768         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7769         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7770 }
7771
7772 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) {
7773         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7774         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7775         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7776         LDKPublicKey their_node_id_ref;
7777         CHECK(their_node_id->arr_len == 33);
7778         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7779         LDKInitFeatures their_features_conv;
7780         their_features_conv.inner = (void*)(their_features & (~1));
7781         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7782         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
7783         their_features_conv = InitFeatures_clone(&their_features_conv);
7784         LDKAcceptChannel msg_conv;
7785         msg_conv.inner = (void*)(msg & (~1));
7786         msg_conv.is_owned = false;
7787         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7788         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7789 }
7790
7791 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) {
7792         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7793         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7794         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7795         LDKPublicKey their_node_id_ref;
7796         CHECK(their_node_id->arr_len == 33);
7797         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7798         LDKFundingCreated msg_conv;
7799         msg_conv.inner = (void*)(msg & (~1));
7800         msg_conv.is_owned = false;
7801         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7802         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7803 }
7804
7805 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) {
7806         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7807         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7808         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7809         LDKPublicKey their_node_id_ref;
7810         CHECK(their_node_id->arr_len == 33);
7811         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7812         LDKFundingSigned msg_conv;
7813         msg_conv.inner = (void*)(msg & (~1));
7814         msg_conv.is_owned = false;
7815         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7816         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7817 }
7818
7819 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) {
7820         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7821         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7822         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7823         LDKPublicKey their_node_id_ref;
7824         CHECK(their_node_id->arr_len == 33);
7825         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7826         LDKFundingLocked msg_conv;
7827         msg_conv.inner = (void*)(msg & (~1));
7828         msg_conv.is_owned = false;
7829         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7830         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7831 }
7832
7833 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) {
7834         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7835         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7836         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7837         LDKPublicKey their_node_id_ref;
7838         CHECK(their_node_id->arr_len == 33);
7839         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7840         LDKInitFeatures their_features_conv;
7841         their_features_conv.inner = (void*)(their_features & (~1));
7842         their_features_conv.is_owned = false;
7843         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
7844         LDKShutdown msg_conv;
7845         msg_conv.inner = (void*)(msg & (~1));
7846         msg_conv.is_owned = false;
7847         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7848         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
7849 }
7850
7851 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) {
7852         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7853         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7854         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7855         LDKPublicKey their_node_id_ref;
7856         CHECK(their_node_id->arr_len == 33);
7857         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7858         LDKClosingSigned msg_conv;
7859         msg_conv.inner = (void*)(msg & (~1));
7860         msg_conv.is_owned = false;
7861         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7862         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7863 }
7864
7865 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) {
7866         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7867         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7868         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7869         LDKPublicKey their_node_id_ref;
7870         CHECK(their_node_id->arr_len == 33);
7871         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7872         LDKUpdateAddHTLC msg_conv;
7873         msg_conv.inner = (void*)(msg & (~1));
7874         msg_conv.is_owned = false;
7875         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7876         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7877 }
7878
7879 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) {
7880         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7881         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7882         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7883         LDKPublicKey their_node_id_ref;
7884         CHECK(their_node_id->arr_len == 33);
7885         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7886         LDKUpdateFulfillHTLC msg_conv;
7887         msg_conv.inner = (void*)(msg & (~1));
7888         msg_conv.is_owned = false;
7889         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7890         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7891 }
7892
7893 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) {
7894         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7895         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7896         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7897         LDKPublicKey their_node_id_ref;
7898         CHECK(their_node_id->arr_len == 33);
7899         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7900         LDKUpdateFailHTLC msg_conv;
7901         msg_conv.inner = (void*)(msg & (~1));
7902         msg_conv.is_owned = false;
7903         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7904         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7905 }
7906
7907 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) {
7908         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7909         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7910         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7911         LDKPublicKey their_node_id_ref;
7912         CHECK(their_node_id->arr_len == 33);
7913         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7914         LDKUpdateFailMalformedHTLC msg_conv;
7915         msg_conv.inner = (void*)(msg & (~1));
7916         msg_conv.is_owned = false;
7917         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7918         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7919 }
7920
7921 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) {
7922         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7923         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7924         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7925         LDKPublicKey their_node_id_ref;
7926         CHECK(their_node_id->arr_len == 33);
7927         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7928         LDKCommitmentSigned msg_conv;
7929         msg_conv.inner = (void*)(msg & (~1));
7930         msg_conv.is_owned = false;
7931         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7932         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7933 }
7934
7935 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) {
7936         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7937         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7938         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7939         LDKPublicKey their_node_id_ref;
7940         CHECK(their_node_id->arr_len == 33);
7941         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7942         LDKRevokeAndACK msg_conv;
7943         msg_conv.inner = (void*)(msg & (~1));
7944         msg_conv.is_owned = false;
7945         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7946         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7947 }
7948
7949 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) {
7950         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7951         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7952         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7953         LDKPublicKey their_node_id_ref;
7954         CHECK(their_node_id->arr_len == 33);
7955         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7956         LDKUpdateFee msg_conv;
7957         msg_conv.inner = (void*)(msg & (~1));
7958         msg_conv.is_owned = false;
7959         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7960         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7961 }
7962
7963 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) {
7964         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7965         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7966         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7967         LDKPublicKey their_node_id_ref;
7968         CHECK(their_node_id->arr_len == 33);
7969         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7970         LDKAnnouncementSignatures msg_conv;
7971         msg_conv.inner = (void*)(msg & (~1));
7972         msg_conv.is_owned = false;
7973         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7974         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7975 }
7976
7977 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) {
7978         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7979         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7980         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7981         LDKPublicKey their_node_id_ref;
7982         CHECK(their_node_id->arr_len == 33);
7983         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7984         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
7985 }
7986
7987 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7988         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7989         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7990         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7991         LDKPublicKey their_node_id_ref;
7992         CHECK(their_node_id->arr_len == 33);
7993         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7994         LDKInit msg_conv;
7995         msg_conv.inner = (void*)(msg & (~1));
7996         msg_conv.is_owned = false;
7997         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7998         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7999 }
8000
8001 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) {
8002         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8003         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8004         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8005         LDKPublicKey their_node_id_ref;
8006         CHECK(their_node_id->arr_len == 33);
8007         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8008         LDKChannelReestablish msg_conv;
8009         msg_conv.inner = (void*)(msg & (~1));
8010         msg_conv.is_owned = false;
8011         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8012         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8013 }
8014
8015 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) {
8016         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8017         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8018         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8019         LDKPublicKey their_node_id_ref;
8020         CHECK(their_node_id->arr_len == 33);
8021         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8022         LDKChannelUpdate msg_conv;
8023         msg_conv.inner = (void*)(msg & (~1));
8024         msg_conv.is_owned = false;
8025         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8026         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8027 }
8028
8029 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
8030         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8031         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8032         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8033         LDKPublicKey their_node_id_ref;
8034         CHECK(their_node_id->arr_len == 33);
8035         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8036         LDKErrorMessage msg_conv;
8037         msg_conv.inner = (void*)(msg & (~1));
8038         msg_conv.is_owned = false;
8039         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8040         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8041 }
8042
8043 typedef struct LDKRoutingMessageHandler_JCalls {
8044         atomic_size_t refcnt;
8045         uint32_t instance_ptr;
8046         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8047 } LDKRoutingMessageHandler_JCalls;
8048 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
8049         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8050         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8051                 FREE(j_calls);
8052         }
8053 }
8054 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
8055         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8056         LDKNodeAnnouncement msg_var = *msg;
8057         uintptr_t msg_ref = 0;
8058         msg_var = NodeAnnouncement_clone(msg);
8059         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8060         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8061         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8062         msg_ref = (uintptr_t)msg_var.inner;
8063         if (msg_var.is_owned) {
8064                 msg_ref |= 1;
8065         }
8066         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 65, (uint32_t)msg_ref);
8067         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8068         CHECK_ACCESS(ret_ptr);
8069         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
8070         FREE((void*)ret);
8071         return ret_conv;
8072 }
8073 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
8074         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8075         LDKChannelAnnouncement msg_var = *msg;
8076         uintptr_t msg_ref = 0;
8077         msg_var = ChannelAnnouncement_clone(msg);
8078         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8079         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8080         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8081         msg_ref = (uintptr_t)msg_var.inner;
8082         if (msg_var.is_owned) {
8083                 msg_ref |= 1;
8084         }
8085         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 66, (uint32_t)msg_ref);
8086         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8087         CHECK_ACCESS(ret_ptr);
8088         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
8089         FREE((void*)ret);
8090         return ret_conv;
8091 }
8092 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
8093         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8094         LDKChannelUpdate msg_var = *msg;
8095         uintptr_t msg_ref = 0;
8096         msg_var = ChannelUpdate_clone(msg);
8097         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8098         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8099         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8100         msg_ref = (uintptr_t)msg_var.inner;
8101         if (msg_var.is_owned) {
8102                 msg_ref |= 1;
8103         }
8104         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 67, (uint32_t)msg_ref);
8105         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8106         CHECK_ACCESS(ret_ptr);
8107         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
8108         FREE((void*)ret);
8109         return ret_conv;
8110 }
8111 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
8112         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8113         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 68, (uint32_t)starting_point, (uint32_t)batch_amount);
8114         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
8115         ret_constr.datalen = ret->arr_len;
8116         if (ret_constr.datalen > 0)
8117                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
8118         else
8119                 ret_constr.data = NULL;
8120         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
8121         for (size_t h = 0; h < ret_constr.datalen; h++) {
8122                 uint32_t ret_conv_59 = ret_vals[h];
8123                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
8124                 CHECK_ACCESS(ret_conv_59_ptr);
8125                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
8126                 FREE((void*)ret_conv_59);
8127                 ret_constr.data[h] = ret_conv_59_conv;
8128         }
8129         return ret_constr;
8130 }
8131 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
8132         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8133         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
8134         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
8135         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 69, (uint32_t)starting_point_arr, (uint32_t)batch_amount);
8136         LDKCVec_NodeAnnouncementZ ret_constr;
8137         ret_constr.datalen = ret->arr_len;
8138         if (ret_constr.datalen > 0)
8139                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
8140         else
8141                 ret_constr.data = NULL;
8142         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
8143         for (size_t s = 0; s < ret_constr.datalen; s++) {
8144                 uint32_t ret_conv_18 = ret_vals[s];
8145                 LDKNodeAnnouncement ret_conv_18_conv;
8146                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
8147                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
8148                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
8149                 ret_constr.data[s] = ret_conv_18_conv;
8150         }
8151         return ret_constr;
8152 }
8153 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
8154         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8155         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8156         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8157         LDKInit init_var = *init;
8158         uintptr_t init_ref = 0;
8159         init_var = Init_clone(init);
8160         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8161         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8162         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
8163         init_ref = (uintptr_t)init_var.inner;
8164         if (init_var.is_owned) {
8165                 init_ref |= 1;
8166         }
8167         js_invoke_function_2(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
8168 }
8169 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
8170         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8171         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8172         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8173         LDKReplyChannelRange msg_var = msg;
8174         uintptr_t msg_ref = 0;
8175         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8176         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8177         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8178         msg_ref = (uintptr_t)msg_var.inner;
8179         if (msg_var.is_owned) {
8180                 msg_ref |= 1;
8181         }
8182         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8183         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8184         CHECK_ACCESS(ret_ptr);
8185         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8186         FREE((void*)ret);
8187         return ret_conv;
8188 }
8189 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8190         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8191         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8192         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8193         LDKReplyShortChannelIdsEnd msg_var = msg;
8194         uintptr_t msg_ref = 0;
8195         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8196         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8197         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8198         msg_ref = (uintptr_t)msg_var.inner;
8199         if (msg_var.is_owned) {
8200                 msg_ref |= 1;
8201         }
8202         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8203         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8204         CHECK_ACCESS(ret_ptr);
8205         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8206         FREE((void*)ret);
8207         return ret_conv;
8208 }
8209 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8210         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8211         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8212         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8213         LDKQueryChannelRange msg_var = msg;
8214         uintptr_t msg_ref = 0;
8215         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8216         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8217         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8218         msg_ref = (uintptr_t)msg_var.inner;
8219         if (msg_var.is_owned) {
8220                 msg_ref |= 1;
8221         }
8222         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8223         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8224         CHECK_ACCESS(ret_ptr);
8225         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8226         FREE((void*)ret);
8227         return ret_conv;
8228 }
8229 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8230         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8231         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8232         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8233         LDKQueryShortChannelIds msg_var = msg;
8234         uintptr_t msg_ref = 0;
8235         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8236         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8237         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8238         msg_ref = (uintptr_t)msg_var.inner;
8239         if (msg_var.is_owned) {
8240                 msg_ref |= 1;
8241         }
8242         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8243         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8244         CHECK_ACCESS(ret_ptr);
8245         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8246         FREE((void*)ret);
8247         return ret_conv;
8248 }
8249 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
8250         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
8251         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8252         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8253 }
8254 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
8255         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8256         atomic_init(&calls->refcnt, 1);
8257         calls->instance_ptr = o;
8258
8259         LDKRoutingMessageHandler ret = {
8260                 .this_arg = (void*) calls,
8261                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8262                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8263                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8264                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8265                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8266                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8267                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8268                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8269                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8270                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8271                 .free = LDKRoutingMessageHandler_JCalls_free,
8272                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
8273         };
8274         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8275         return ret;
8276 }
8277 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
8278         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8279         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
8280         return (long)res_ptr;
8281 }
8282 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
8283         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8284         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8285         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8286         LDKNodeAnnouncement msg_conv;
8287         msg_conv.inner = (void*)(msg & (~1));
8288         msg_conv.is_owned = false;
8289         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8290         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8291         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8292         return (uintptr_t)ret_conv;
8293 }
8294
8295 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
8296         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8297         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8298         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8299         LDKChannelAnnouncement msg_conv;
8300         msg_conv.inner = (void*)(msg & (~1));
8301         msg_conv.is_owned = false;
8302         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8303         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8304         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8305         return (uintptr_t)ret_conv;
8306 }
8307
8308 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
8309         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8310         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8311         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8312         LDKChannelUpdate msg_conv;
8313         msg_conv.inner = (void*)(msg & (~1));
8314         msg_conv.is_owned = false;
8315         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8316         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8317         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
8318         return (uintptr_t)ret_conv;
8319 }
8320
8321 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) {
8322         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8323         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8324         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8325         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8326         uint32_tArray ret_arr = NULL;
8327         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8328         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8329         for (size_t h = 0; h < ret_var.datalen; h++) {
8330                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8331                 *ret_conv_59_conv = ret_var.data[h];
8332                 ret_arr_ptr[h] = ((uintptr_t)ret_conv_59_conv);
8333         }
8334         
8335         FREE(ret_var.data);
8336         return ret_arr;
8337 }
8338
8339 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) {
8340         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8341         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8342         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8343         LDKPublicKey starting_point_ref;
8344         CHECK(starting_point->arr_len == 33);
8345         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
8346         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8347         uint32_tArray ret_arr = NULL;
8348         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8349         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8350         for (size_t s = 0; s < ret_var.datalen; s++) {
8351                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8352                 uintptr_t ret_conv_18_ref = 0;
8353                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8354                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8355                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
8356                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
8357                 if (ret_conv_18_var.is_owned) {
8358                         ret_conv_18_ref |= 1;
8359                 }
8360                 ret_arr_ptr[s] = ret_conv_18_ref;
8361         }
8362         
8363         FREE(ret_var.data);
8364         return ret_arr;
8365 }
8366
8367 void  __attribute__((export_name("TS_RoutingMessageHandler_sync_routing_table"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
8368         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8369         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8370         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8371         LDKPublicKey their_node_id_ref;
8372         CHECK(their_node_id->arr_len == 33);
8373         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8374         LDKInit init_conv;
8375         init_conv.inner = (void*)(init & (~1));
8376         init_conv.is_owned = false;
8377         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
8378         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8379 }
8380
8381 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) {
8382         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8383         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8384         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8385         LDKPublicKey their_node_id_ref;
8386         CHECK(their_node_id->arr_len == 33);
8387         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8388         LDKReplyChannelRange msg_conv;
8389         msg_conv.inner = (void*)(msg & (~1));
8390         msg_conv.is_owned = (msg & 1) || (msg == 0);
8391         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8392         msg_conv = ReplyChannelRange_clone(&msg_conv);
8393         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8394         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8395         return (uintptr_t)ret_conv;
8396 }
8397
8398 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) {
8399         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8400         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8401         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8402         LDKPublicKey their_node_id_ref;
8403         CHECK(their_node_id->arr_len == 33);
8404         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8405         LDKReplyShortChannelIdsEnd msg_conv;
8406         msg_conv.inner = (void*)(msg & (~1));
8407         msg_conv.is_owned = (msg & 1) || (msg == 0);
8408         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8409         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8410         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8411         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8412         return (uintptr_t)ret_conv;
8413 }
8414
8415 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) {
8416         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8417         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8418         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8419         LDKPublicKey their_node_id_ref;
8420         CHECK(their_node_id->arr_len == 33);
8421         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8422         LDKQueryChannelRange msg_conv;
8423         msg_conv.inner = (void*)(msg & (~1));
8424         msg_conv.is_owned = (msg & 1) || (msg == 0);
8425         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8426         msg_conv = QueryChannelRange_clone(&msg_conv);
8427         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8428         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8429         return (uintptr_t)ret_conv;
8430 }
8431
8432 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) {
8433         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8434         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8435         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8436         LDKPublicKey their_node_id_ref;
8437         CHECK(their_node_id->arr_len == 33);
8438         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8439         LDKQueryShortChannelIds msg_conv;
8440         msg_conv.inner = (void*)(msg & (~1));
8441         msg_conv.is_owned = (msg & 1) || (msg == 0);
8442         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8443         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8444         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8445         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8446         return (uintptr_t)ret_conv;
8447 }
8448
8449 typedef struct LDKCustomMessageReader_JCalls {
8450         atomic_size_t refcnt;
8451         uint32_t instance_ptr;
8452 } LDKCustomMessageReader_JCalls;
8453 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
8454         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
8455         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8456                 FREE(j_calls);
8457         }
8458 }
8459 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
8460         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
8461         LDKu8slice buffer_var = buffer;
8462         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
8463         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
8464         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 75, (uint32_t)message_type, (uint32_t)buffer_arr);
8465         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8466         CHECK_ACCESS(ret_ptr);
8467         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
8468         FREE((void*)ret);
8469         return ret_conv;
8470 }
8471 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
8472         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
8473         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8474 }
8475 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
8476         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
8477         atomic_init(&calls->refcnt, 1);
8478         calls->instance_ptr = o;
8479
8480         LDKCustomMessageReader ret = {
8481                 .this_arg = (void*) calls,
8482                 .read = read_LDKCustomMessageReader_jcall,
8483                 .free = LDKCustomMessageReader_JCalls_free,
8484         };
8485         return ret;
8486 }
8487 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
8488         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
8489         *res_ptr = LDKCustomMessageReader_init(o);
8490         return (long)res_ptr;
8491 }
8492 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
8493         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8494         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8495         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
8496         LDKu8slice buffer_ref;
8497         buffer_ref.datalen = buffer->arr_len;
8498         buffer_ref.data = buffer->elems /* XXX buffer leaks */;
8499         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
8500         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
8501         return (uintptr_t)ret_conv;
8502 }
8503
8504 typedef struct LDKCustomMessageHandler_JCalls {
8505         atomic_size_t refcnt;
8506         uint32_t instance_ptr;
8507         LDKCustomMessageReader_JCalls* CustomMessageReader;
8508 } LDKCustomMessageHandler_JCalls;
8509 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
8510         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
8511         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8512                 FREE(j_calls);
8513         }
8514 }
8515 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
8516         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
8517         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
8518         *msg_ret = msg;
8519         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
8520         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
8521         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 76, (uint32_t)(uintptr_t)msg_ret, (uint32_t)sender_node_id_arr);
8522         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8523         CHECK_ACCESS(ret_ptr);
8524         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8525         FREE((void*)ret);
8526         return ret_conv;
8527 }
8528 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
8529         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
8530         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 77);
8531         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
8532         ret_constr.datalen = ret->arr_len;
8533         if (ret_constr.datalen > 0)
8534                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
8535         else
8536                 ret_constr.data = NULL;
8537         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
8538         for (size_t z = 0; z < ret_constr.datalen; z++) {
8539                 uint32_t ret_conv_25 = ret_vals[z];
8540                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
8541                 CHECK_ACCESS(ret_conv_25_ptr);
8542                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
8543                 FREE((void*)ret_conv_25);
8544                 ret_constr.data[z] = ret_conv_25_conv;
8545         }
8546         return ret_constr;
8547 }
8548 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
8549         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
8550         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8551         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
8552 }
8553 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
8554         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
8555         atomic_init(&calls->refcnt, 1);
8556         calls->instance_ptr = o;
8557
8558         LDKCustomMessageHandler ret = {
8559                 .this_arg = (void*) calls,
8560                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
8561                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
8562                 .free = LDKCustomMessageHandler_JCalls_free,
8563                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
8564         };
8565         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
8566         return ret;
8567 }
8568 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
8569         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
8570         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
8571         return (long)res_ptr;
8572 }
8573 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) {
8574         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8575         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8576         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
8577         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
8578         CHECK_ACCESS(msg_ptr);
8579         LDKType msg_conv = *(LDKType*)(msg_ptr);
8580         LDKPublicKey sender_node_id_ref;
8581         CHECK(sender_node_id->arr_len == 33);
8582         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
8583         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8584         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
8585         return (uintptr_t)ret_conv;
8586 }
8587
8588 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
8589         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8590         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8591         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
8592         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
8593         uint32_tArray ret_arr = NULL;
8594         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8595         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8596         for (size_t z = 0; z < ret_var.datalen; z++) {
8597                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
8598                 *ret_conv_25_conv = ret_var.data[z];
8599                 ret_arr_ptr[z] = ((uintptr_t)ret_conv_25_conv);
8600         }
8601         
8602         FREE(ret_var.data);
8603         return ret_arr;
8604 }
8605
8606 typedef struct LDKSocketDescriptor_JCalls {
8607         atomic_size_t refcnt;
8608         uint32_t instance_ptr;
8609 } LDKSocketDescriptor_JCalls;
8610 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8611         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8612         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8613                 FREE(j_calls);
8614         }
8615 }
8616 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8617         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8618         LDKu8slice data_var = data;
8619         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
8620         memcpy(data_arr->elems, data_var.data, data_var.datalen);
8621         return js_invoke_function_2(j_calls->instance_ptr, 78, (uint32_t)data_arr, (uint32_t)resume_read);
8622 }
8623 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8624         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8625         js_invoke_function_0(j_calls->instance_ptr, 79);
8626 }
8627 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8628         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8629         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8630         *other_arg_clone = SocketDescriptor_clone(other_arg);
8631         return js_invoke_function_1(j_calls->instance_ptr, 80, (uint32_t)(uintptr_t)other_arg_clone);
8632 }
8633 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8634         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8635         return js_invoke_function_0(j_calls->instance_ptr, 81);
8636 }
8637 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
8638         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
8639         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8640 }
8641 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
8642         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8643         atomic_init(&calls->refcnt, 1);
8644         calls->instance_ptr = o;
8645
8646         LDKSocketDescriptor ret = {
8647                 .this_arg = (void*) calls,
8648                 .send_data = send_data_LDKSocketDescriptor_jcall,
8649                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8650                 .eq = eq_LDKSocketDescriptor_jcall,
8651                 .hash = hash_LDKSocketDescriptor_jcall,
8652                 .cloned = LDKSocketDescriptor_JCalls_cloned,
8653                 .free = LDKSocketDescriptor_JCalls_free,
8654         };
8655         return ret;
8656 }
8657 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
8658         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8659         *res_ptr = LDKSocketDescriptor_init(o);
8660         return (long)res_ptr;
8661 }
8662 intptr_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
8663         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8664         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8665         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
8666         LDKu8slice data_ref;
8667         data_ref.datalen = data->arr_len;
8668         data_ref.data = data->elems /* XXX data leaks */;
8669         intptr_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8670         return ret_val;
8671 }
8672
8673 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
8674         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8675         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8676         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
8677         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8678 }
8679
8680 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
8681         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8682         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8683         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
8684         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8685         return ret_val;
8686 }
8687
8688 typedef struct LDKScore_JCalls {
8689         atomic_size_t refcnt;
8690         uint32_t instance_ptr;
8691 } LDKScore_JCalls;
8692 static void LDKScore_JCalls_free(void* this_arg) {
8693         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8694         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8695                 FREE(j_calls);
8696         }
8697 }
8698 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, LDKCOption_u64Z channel_capacity_msat, const LDKNodeId * source, const LDKNodeId * target) {
8699         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8700         LDKCOption_u64Z *channel_capacity_msat_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
8701         *channel_capacity_msat_copy = channel_capacity_msat;
8702         uintptr_t channel_capacity_msat_ref = (uintptr_t)channel_capacity_msat_copy;
8703         LDKNodeId source_var = *source;
8704         uintptr_t source_ref = 0;
8705         source_var = NodeId_clone(source);
8706         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8707         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8708         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
8709         source_ref = (uintptr_t)source_var.inner;
8710         if (source_var.is_owned) {
8711                 source_ref |= 1;
8712         }
8713         LDKNodeId target_var = *target;
8714         uintptr_t target_ref = 0;
8715         target_var = NodeId_clone(target);
8716         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8717         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8718         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
8719         target_ref = (uintptr_t)target_var.inner;
8720         if (target_var.is_owned) {
8721                 target_ref |= 1;
8722         }
8723         return js_invoke_function_5(j_calls->instance_ptr, 82, (uint32_t)short_channel_id, (uint32_t)send_amt_msat, (uint32_t)channel_capacity_msat_ref, (uint32_t)source_ref, (uint32_t)target_ref);
8724 }
8725 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8726         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8727         LDKCVec_RouteHopZ path_var = path;
8728         uint32_tArray path_arr = NULL;
8729         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8730         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8731         for (size_t k = 0; k < path_var.datalen; k++) {
8732                 LDKRouteHop path_conv_10_var = path_var.data[k];
8733                 uintptr_t path_conv_10_ref = 0;
8734                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8735                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8736                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8737                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8738                 if (path_conv_10_var.is_owned) {
8739                         path_conv_10_ref |= 1;
8740                 }
8741                 path_arr_ptr[k] = path_conv_10_ref;
8742         }
8743         
8744         FREE(path_var.data);
8745         js_invoke_function_2(j_calls->instance_ptr, 83, (uint32_t)path_arr, (uint32_t)short_channel_id);
8746 }
8747 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8748         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8749         LDKCVec_RouteHopZ path_var = path;
8750         uint32_tArray path_arr = NULL;
8751         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8752         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8753         for (size_t k = 0; k < path_var.datalen; k++) {
8754                 LDKRouteHop path_conv_10_var = path_var.data[k];
8755                 uintptr_t path_conv_10_ref = 0;
8756                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8757                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8758                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8759                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8760                 if (path_conv_10_var.is_owned) {
8761                         path_conv_10_ref |= 1;
8762                 }
8763                 path_arr_ptr[k] = path_conv_10_ref;
8764         }
8765         
8766         FREE(path_var.data);
8767         js_invoke_function_1(j_calls->instance_ptr, 84, (uint32_t)path_arr);
8768 }
8769 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
8770         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8771         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 85);
8772         LDKCVec_u8Z ret_ref;
8773         ret_ref.datalen = ret->arr_len;
8774         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8775         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
8776         return ret_ref;
8777 }
8778 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
8779         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
8780         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8781 }
8782 static inline LDKScore LDKScore_init (JSValue o) {
8783         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
8784         atomic_init(&calls->refcnt, 1);
8785         calls->instance_ptr = o;
8786
8787         LDKScore ret = {
8788                 .this_arg = (void*) calls,
8789                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
8790                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
8791                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
8792                 .write = write_LDKScore_jcall,
8793                 .free = LDKScore_JCalls_free,
8794         };
8795         return ret;
8796 }
8797 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
8798         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
8799         *res_ptr = LDKScore_init(o);
8800         return (long)res_ptr;
8801 }
8802 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, uint32_t channel_capacity_msat, uint32_t source, uint32_t target) {
8803         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8804         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8805         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8806         void* channel_capacity_msat_ptr = (void*)(((uintptr_t)channel_capacity_msat) & ~1);
8807         CHECK_ACCESS(channel_capacity_msat_ptr);
8808         LDKCOption_u64Z channel_capacity_msat_conv = *(LDKCOption_u64Z*)(channel_capacity_msat_ptr);
8809         channel_capacity_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)channel_capacity_msat) & ~1));
8810         LDKNodeId source_conv;
8811         source_conv.inner = (void*)(source & (~1));
8812         source_conv.is_owned = false;
8813         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
8814         LDKNodeId target_conv;
8815         target_conv.inner = (void*)(target & (~1));
8816         target_conv.is_owned = false;
8817         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
8818         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, send_amt_msat, channel_capacity_msat_conv, &source_conv, &target_conv);
8819         return ret_val;
8820 }
8821
8822 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) {
8823         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8824         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8825         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8826         LDKCVec_RouteHopZ path_constr;
8827         path_constr.datalen = path->arr_len;
8828         if (path_constr.datalen > 0)
8829                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8830         else
8831                 path_constr.data = NULL;
8832         uint32_t* path_vals = path->elems /* XXX path leaks */;
8833         for (size_t k = 0; k < path_constr.datalen; k++) {
8834                 uint32_t path_conv_10 = path_vals[k];
8835                 LDKRouteHop path_conv_10_conv;
8836                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8837                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8838                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8839                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8840                 path_constr.data[k] = path_conv_10_conv;
8841         }
8842         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8843 }
8844
8845 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
8846         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8847         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8848         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8849         LDKCVec_RouteHopZ path_constr;
8850         path_constr.datalen = path->arr_len;
8851         if (path_constr.datalen > 0)
8852                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8853         else
8854                 path_constr.data = NULL;
8855         uint32_t* path_vals = path->elems /* XXX path leaks */;
8856         for (size_t k = 0; k < path_constr.datalen; k++) {
8857                 uint32_t path_conv_10 = path_vals[k];
8858                 LDKRouteHop path_conv_10_conv;
8859                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8860                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8861                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8862                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8863                 path_constr.data[k] = path_conv_10_conv;
8864         }
8865         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
8866 }
8867
8868 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
8869         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8870         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8871         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8872         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8873         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
8874         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
8875         CVec_u8Z_free(ret_var);
8876         return ret_arr;
8877 }
8878
8879 typedef struct LDKLockableScore_JCalls {
8880         atomic_size_t refcnt;
8881         uint32_t instance_ptr;
8882 } LDKLockableScore_JCalls;
8883 static void LDKLockableScore_JCalls_free(void* this_arg) {
8884         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
8885         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8886                 FREE(j_calls);
8887         }
8888 }
8889 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
8890         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
8891         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 86);
8892         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8893         CHECK_ACCESS(ret_ptr);
8894         LDKScore ret_conv = *(LDKScore*)(ret_ptr);// Warning: we may need a move here but no clone is available for LDKScore
8895         
8896         return ret_conv;
8897 }
8898 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
8899         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
8900         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8901 }
8902 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
8903         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
8904         atomic_init(&calls->refcnt, 1);
8905         calls->instance_ptr = o;
8906
8907         LDKLockableScore ret = {
8908                 .this_arg = (void*) calls,
8909                 .lock = lock_LDKLockableScore_jcall,
8910                 .free = LDKLockableScore_JCalls_free,
8911         };
8912         return ret;
8913 }
8914 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
8915         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
8916         *res_ptr = LDKLockableScore_init(o);
8917         return (long)res_ptr;
8918 }
8919 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
8920         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8921         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8922         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
8923         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
8924         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
8925         return (uintptr_t)ret_ret;
8926 }
8927
8928 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
8929         LDKStr ret_str = _ldk_get_compiled_version();
8930         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
8931         Str_free(ret_str);
8932         return ret_conv;
8933 }
8934
8935 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
8936         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
8937         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
8938         Str_free(ret_str);
8939         return ret_conv;
8940 }
8941
8942 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
8943         LDKTransaction _res_ref;
8944         _res_ref.datalen = _res->arr_len;
8945         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
8946         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
8947         _res_ref.data_is_owned = true;
8948         Transaction_free(_res_ref);
8949 }
8950
8951 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
8952         LDKCVec_u8Z script_pubkey_ref;
8953         script_pubkey_ref.datalen = script_pubkey->arr_len;
8954         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
8955         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
8956         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8957         *ret_ref = TxOut_new(script_pubkey_ref, value);
8958         return (uintptr_t)ret_ref;
8959 }
8960
8961 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
8962         if ((_res & 1) != 0) return;
8963         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
8964         CHECK_ACCESS(_res_ptr);
8965         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
8966         FREE((void*)_res);
8967         TxOut_free(_res_conv);
8968 }
8969
8970 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
8971         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8972         *ret_ref = TxOut_clone(arg);
8973         return (uintptr_t)ret_ref;
8974 }
8975 intptr_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
8976         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
8977         intptr_t ret_val = TxOut_clone_ptr(arg_conv);
8978         return ret_val;
8979 }
8980
8981 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
8982         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
8983         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8984         *ret_ref = TxOut_clone(orig_conv);
8985         return (uintptr_t)ret_ref;
8986 }
8987
8988 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
8989         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
8990         Str_free(dummy);
8991 }
8992
8993 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
8994         LDKChannelConfig o_conv;
8995         o_conv.inner = (void*)(o & (~1));
8996         o_conv.is_owned = (o & 1) || (o == 0);
8997         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
8998         o_conv = ChannelConfig_clone(&o_conv);
8999         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9000         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
9001         return (uintptr_t)ret_conv;
9002 }
9003
9004 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
9005         LDKDecodeError e_conv;
9006         e_conv.inner = (void*)(e & (~1));
9007         e_conv.is_owned = (e & 1) || (e == 0);
9008         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9009         e_conv = DecodeError_clone(&e_conv);
9010         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9011         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
9012         return (uintptr_t)ret_conv;
9013 }
9014
9015 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
9016         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
9017         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
9018         return ret_val;
9019 }
9020
9021 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
9022         if ((_res & 1) != 0) return;
9023         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9024         CHECK_ACCESS(_res_ptr);
9025         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
9026         FREE((void*)_res);
9027         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
9028 }
9029
9030 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
9031         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9032         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
9033         return (uintptr_t)ret_conv;
9034 }
9035 intptr_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
9036         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
9037         intptr_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
9038         return ret_val;
9039 }
9040
9041 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
9042         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
9043         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9044         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
9045         return (uintptr_t)ret_conv;
9046 }
9047
9048 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
9049         LDKOutPoint o_conv;
9050         o_conv.inner = (void*)(o & (~1));
9051         o_conv.is_owned = (o & 1) || (o == 0);
9052         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9053         o_conv = OutPoint_clone(&o_conv);
9054         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9055         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
9056         return (uintptr_t)ret_conv;
9057 }
9058
9059 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
9060         LDKDecodeError e_conv;
9061         e_conv.inner = (void*)(e & (~1));
9062         e_conv.is_owned = (e & 1) || (e == 0);
9063         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9064         e_conv = DecodeError_clone(&e_conv);
9065         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9066         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
9067         return (uintptr_t)ret_conv;
9068 }
9069
9070 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
9071         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
9072         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
9073         return ret_val;
9074 }
9075
9076 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
9077         if ((_res & 1) != 0) return;
9078         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9079         CHECK_ACCESS(_res_ptr);
9080         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
9081         FREE((void*)_res);
9082         CResult_OutPointDecodeErrorZ_free(_res_conv);
9083 }
9084
9085 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
9086         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9087         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
9088         return (uintptr_t)ret_conv;
9089 }
9090 intptr_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
9091         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
9092         intptr_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
9093         return ret_val;
9094 }
9095
9096 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
9097         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
9098         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9099         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
9100         return (uintptr_t)ret_conv;
9101 }
9102
9103 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
9104         LDKSecretKey o_ref;
9105         CHECK(o->arr_len == 32);
9106         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
9107         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9108         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
9109         return (uintptr_t)ret_conv;
9110 }
9111
9112 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
9113         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9114         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9115         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
9116         return (uintptr_t)ret_conv;
9117 }
9118
9119 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
9120         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
9121         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
9122         return ret_val;
9123 }
9124
9125 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
9126         if ((_res & 1) != 0) return;
9127         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9128         CHECK_ACCESS(_res_ptr);
9129         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
9130         FREE((void*)_res);
9131         CResult_SecretKeyErrorZ_free(_res_conv);
9132 }
9133
9134 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
9135         LDKPublicKey o_ref;
9136         CHECK(o->arr_len == 33);
9137         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
9138         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9139         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
9140         return (uintptr_t)ret_conv;
9141 }
9142
9143 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
9144         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9145         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9146         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
9147         return (uintptr_t)ret_conv;
9148 }
9149
9150 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
9151         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
9152         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
9153         return ret_val;
9154 }
9155
9156 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
9157         if ((_res & 1) != 0) return;
9158         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9159         CHECK_ACCESS(_res_ptr);
9160         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
9161         FREE((void*)_res);
9162         CResult_PublicKeyErrorZ_free(_res_conv);
9163 }
9164
9165 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
9166         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9167         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
9168         return (uintptr_t)ret_conv;
9169 }
9170 intptr_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
9171         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
9172         intptr_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
9173         return ret_val;
9174 }
9175
9176 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
9177         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
9178         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9179         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
9180         return (uintptr_t)ret_conv;
9181 }
9182
9183 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
9184         LDKTxCreationKeys o_conv;
9185         o_conv.inner = (void*)(o & (~1));
9186         o_conv.is_owned = (o & 1) || (o == 0);
9187         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9188         o_conv = TxCreationKeys_clone(&o_conv);
9189         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9190         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
9191         return (uintptr_t)ret_conv;
9192 }
9193
9194 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
9195         LDKDecodeError e_conv;
9196         e_conv.inner = (void*)(e & (~1));
9197         e_conv.is_owned = (e & 1) || (e == 0);
9198         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9199         e_conv = DecodeError_clone(&e_conv);
9200         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9201         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
9202         return (uintptr_t)ret_conv;
9203 }
9204
9205 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
9206         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
9207         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
9208         return ret_val;
9209 }
9210
9211 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
9212         if ((_res & 1) != 0) return;
9213         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9214         CHECK_ACCESS(_res_ptr);
9215         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
9216         FREE((void*)_res);
9217         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
9218 }
9219
9220 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
9221         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9222         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
9223         return (uintptr_t)ret_conv;
9224 }
9225 intptr_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
9226         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
9227         intptr_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
9228         return ret_val;
9229 }
9230
9231 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
9232         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
9233         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9234         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
9235         return (uintptr_t)ret_conv;
9236 }
9237
9238 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
9239         LDKChannelPublicKeys o_conv;
9240         o_conv.inner = (void*)(o & (~1));
9241         o_conv.is_owned = (o & 1) || (o == 0);
9242         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9243         o_conv = ChannelPublicKeys_clone(&o_conv);
9244         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9245         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
9246         return (uintptr_t)ret_conv;
9247 }
9248
9249 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
9250         LDKDecodeError e_conv;
9251         e_conv.inner = (void*)(e & (~1));
9252         e_conv.is_owned = (e & 1) || (e == 0);
9253         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9254         e_conv = DecodeError_clone(&e_conv);
9255         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9256         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
9257         return (uintptr_t)ret_conv;
9258 }
9259
9260 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
9261         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
9262         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
9263         return ret_val;
9264 }
9265
9266 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
9267         if ((_res & 1) != 0) return;
9268         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9269         CHECK_ACCESS(_res_ptr);
9270         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
9271         FREE((void*)_res);
9272         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
9273 }
9274
9275 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
9276         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9277         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
9278         return (uintptr_t)ret_conv;
9279 }
9280 intptr_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
9281         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
9282         intptr_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
9283         return ret_val;
9284 }
9285
9286 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
9287         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
9288         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9289         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
9290         return (uintptr_t)ret_conv;
9291 }
9292
9293 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
9294         LDKTxCreationKeys o_conv;
9295         o_conv.inner = (void*)(o & (~1));
9296         o_conv.is_owned = (o & 1) || (o == 0);
9297         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9298         o_conv = TxCreationKeys_clone(&o_conv);
9299         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9300         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
9301         return (uintptr_t)ret_conv;
9302 }
9303
9304 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
9305         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9306         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9307         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
9308         return (uintptr_t)ret_conv;
9309 }
9310
9311 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
9312         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
9313         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
9314         return ret_val;
9315 }
9316
9317 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
9318         if ((_res & 1) != 0) return;
9319         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9320         CHECK_ACCESS(_res_ptr);
9321         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
9322         FREE((void*)_res);
9323         CResult_TxCreationKeysErrorZ_free(_res_conv);
9324 }
9325
9326 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
9327         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9328         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
9329         return (uintptr_t)ret_conv;
9330 }
9331 intptr_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
9332         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
9333         intptr_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
9334         return ret_val;
9335 }
9336
9337 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
9338         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
9339         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9340         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
9341         return (uintptr_t)ret_conv;
9342 }
9343
9344 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
9345         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9346         *ret_copy = COption_u32Z_some(o);
9347         uintptr_t ret_ref = (uintptr_t)ret_copy;
9348         return ret_ref;
9349 }
9350
9351 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
9352         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9353         *ret_copy = COption_u32Z_none();
9354         uintptr_t ret_ref = (uintptr_t)ret_copy;
9355         return ret_ref;
9356 }
9357
9358 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
9359         if ((_res & 1) != 0) return;
9360         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9361         CHECK_ACCESS(_res_ptr);
9362         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
9363         FREE((void*)_res);
9364         COption_u32Z_free(_res_conv);
9365 }
9366
9367 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
9368         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9369         *ret_copy = COption_u32Z_clone(arg);
9370 uintptr_t ret_ref = (uintptr_t)ret_copy;
9371         return ret_ref;
9372 }
9373 intptr_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
9374         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
9375         intptr_t ret_val = COption_u32Z_clone_ptr(arg_conv);
9376         return ret_val;
9377 }
9378
9379 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
9380         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
9381         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9382         *ret_copy = COption_u32Z_clone(orig_conv);
9383         uintptr_t ret_ref = (uintptr_t)ret_copy;
9384         return ret_ref;
9385 }
9386
9387 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
9388         LDKHTLCOutputInCommitment o_conv;
9389         o_conv.inner = (void*)(o & (~1));
9390         o_conv.is_owned = (o & 1) || (o == 0);
9391         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9392         o_conv = HTLCOutputInCommitment_clone(&o_conv);
9393         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9394         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
9395         return (uintptr_t)ret_conv;
9396 }
9397
9398 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
9399         LDKDecodeError e_conv;
9400         e_conv.inner = (void*)(e & (~1));
9401         e_conv.is_owned = (e & 1) || (e == 0);
9402         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9403         e_conv = DecodeError_clone(&e_conv);
9404         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9405         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
9406         return (uintptr_t)ret_conv;
9407 }
9408
9409 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
9410         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
9411         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
9412         return ret_val;
9413 }
9414
9415 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
9416         if ((_res & 1) != 0) return;
9417         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9418         CHECK_ACCESS(_res_ptr);
9419         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
9420         FREE((void*)_res);
9421         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
9422 }
9423
9424 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
9425         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9426         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
9427         return (uintptr_t)ret_conv;
9428 }
9429 intptr_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
9430         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
9431         intptr_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
9432         return ret_val;
9433 }
9434
9435 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
9436         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
9437         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9438         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
9439         return (uintptr_t)ret_conv;
9440 }
9441
9442 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
9443         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
9444         return ret_conv;
9445 }
9446
9447 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
9448         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
9449         return ret_conv;
9450 }
9451
9452 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
9453         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
9454         COption_NoneZ_free(_res_conv);
9455 }
9456
9457 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
9458         LDKCounterpartyChannelTransactionParameters o_conv;
9459         o_conv.inner = (void*)(o & (~1));
9460         o_conv.is_owned = (o & 1) || (o == 0);
9461         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9462         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
9463         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9464         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9465         return (uintptr_t)ret_conv;
9466 }
9467
9468 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
9469         LDKDecodeError e_conv;
9470         e_conv.inner = (void*)(e & (~1));
9471         e_conv.is_owned = (e & 1) || (e == 0);
9472         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9473         e_conv = DecodeError_clone(&e_conv);
9474         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9475         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
9476         return (uintptr_t)ret_conv;
9477 }
9478
9479 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
9480         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
9481         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
9482         return ret_val;
9483 }
9484
9485 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
9486         if ((_res & 1) != 0) return;
9487         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9488         CHECK_ACCESS(_res_ptr);
9489         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
9490         FREE((void*)_res);
9491         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9492 }
9493
9494 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
9495         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9496         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
9497         return (uintptr_t)ret_conv;
9498 }
9499 intptr_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
9500         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
9501         intptr_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
9502         return ret_val;
9503 }
9504
9505 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
9506         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9507         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9508         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9509         return (uintptr_t)ret_conv;
9510 }
9511
9512 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
9513         LDKChannelTransactionParameters o_conv;
9514         o_conv.inner = (void*)(o & (~1));
9515         o_conv.is_owned = (o & 1) || (o == 0);
9516         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9517         o_conv = ChannelTransactionParameters_clone(&o_conv);
9518         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9519         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9520         return (uintptr_t)ret_conv;
9521 }
9522
9523 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
9524         LDKDecodeError e_conv;
9525         e_conv.inner = (void*)(e & (~1));
9526         e_conv.is_owned = (e & 1) || (e == 0);
9527         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9528         e_conv = DecodeError_clone(&e_conv);
9529         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9530         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
9531         return (uintptr_t)ret_conv;
9532 }
9533
9534 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
9535         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
9536         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
9537         return ret_val;
9538 }
9539
9540 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
9541         if ((_res & 1) != 0) return;
9542         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9543         CHECK_ACCESS(_res_ptr);
9544         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
9545         FREE((void*)_res);
9546         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9547 }
9548
9549 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
9550         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9551         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
9552         return (uintptr_t)ret_conv;
9553 }
9554 intptr_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
9555         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
9556         intptr_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
9557         return ret_val;
9558 }
9559
9560 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
9561         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9562         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9563         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9564         return (uintptr_t)ret_conv;
9565 }
9566
9567 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
9568         LDKCVec_SignatureZ _res_constr;
9569         _res_constr.datalen = _res->arr_len;
9570         if (_res_constr.datalen > 0)
9571                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9572         else
9573                 _res_constr.data = NULL;
9574         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
9575         for (size_t m = 0; m < _res_constr.datalen; m++) {
9576                 int8_tArray _res_conv_12 = _res_vals[m];
9577                 LDKSignature _res_conv_12_ref;
9578                 CHECK(_res_conv_12->arr_len == 64);
9579                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
9580                 _res_constr.data[m] = _res_conv_12_ref;
9581         }
9582         CVec_SignatureZ_free(_res_constr);
9583 }
9584
9585 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
9586         LDKHolderCommitmentTransaction o_conv;
9587         o_conv.inner = (void*)(o & (~1));
9588         o_conv.is_owned = (o & 1) || (o == 0);
9589         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9590         o_conv = HolderCommitmentTransaction_clone(&o_conv);
9591         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9592         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
9593         return (uintptr_t)ret_conv;
9594 }
9595
9596 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
9597         LDKDecodeError e_conv;
9598         e_conv.inner = (void*)(e & (~1));
9599         e_conv.is_owned = (e & 1) || (e == 0);
9600         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9601         e_conv = DecodeError_clone(&e_conv);
9602         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9603         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
9604         return (uintptr_t)ret_conv;
9605 }
9606
9607 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
9608         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
9609         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
9610         return ret_val;
9611 }
9612
9613 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
9614         if ((_res & 1) != 0) return;
9615         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9616         CHECK_ACCESS(_res_ptr);
9617         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
9618         FREE((void*)_res);
9619         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
9620 }
9621
9622 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
9623         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9624         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
9625         return (uintptr_t)ret_conv;
9626 }
9627 intptr_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
9628         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
9629         intptr_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
9630         return ret_val;
9631 }
9632
9633 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
9634         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9635         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9636         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9637         return (uintptr_t)ret_conv;
9638 }
9639
9640 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
9641         LDKBuiltCommitmentTransaction o_conv;
9642         o_conv.inner = (void*)(o & (~1));
9643         o_conv.is_owned = (o & 1) || (o == 0);
9644         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9645         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
9646         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9647         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
9648         return (uintptr_t)ret_conv;
9649 }
9650
9651 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
9652         LDKDecodeError e_conv;
9653         e_conv.inner = (void*)(e & (~1));
9654         e_conv.is_owned = (e & 1) || (e == 0);
9655         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9656         e_conv = DecodeError_clone(&e_conv);
9657         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9658         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
9659         return (uintptr_t)ret_conv;
9660 }
9661
9662 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
9663         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
9664         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
9665         return ret_val;
9666 }
9667
9668 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
9669         if ((_res & 1) != 0) return;
9670         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9671         CHECK_ACCESS(_res_ptr);
9672         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
9673         FREE((void*)_res);
9674         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
9675 }
9676
9677 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
9678         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9679         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
9680         return (uintptr_t)ret_conv;
9681 }
9682 intptr_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
9683         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
9684         intptr_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
9685         return ret_val;
9686 }
9687
9688 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
9689         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9690         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9691         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9692         return (uintptr_t)ret_conv;
9693 }
9694
9695 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
9696         LDKTrustedClosingTransaction o_conv;
9697         o_conv.inner = (void*)(o & (~1));
9698         o_conv.is_owned = (o & 1) || (o == 0);
9699         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9700         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
9701         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
9702         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
9703         return (uintptr_t)ret_conv;
9704 }
9705
9706 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
9707         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
9708         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
9709         return (uintptr_t)ret_conv;
9710 }
9711
9712 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
9713         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
9714         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
9715         return ret_val;
9716 }
9717
9718 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
9719         if ((_res & 1) != 0) return;
9720         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9721         CHECK_ACCESS(_res_ptr);
9722         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
9723         FREE((void*)_res);
9724         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
9725 }
9726
9727 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
9728         LDKCommitmentTransaction o_conv;
9729         o_conv.inner = (void*)(o & (~1));
9730         o_conv.is_owned = (o & 1) || (o == 0);
9731         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9732         o_conv = CommitmentTransaction_clone(&o_conv);
9733         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9734         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9735         return (uintptr_t)ret_conv;
9736 }
9737
9738 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
9739         LDKDecodeError e_conv;
9740         e_conv.inner = (void*)(e & (~1));
9741         e_conv.is_owned = (e & 1) || (e == 0);
9742         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9743         e_conv = DecodeError_clone(&e_conv);
9744         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9745         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9746         return (uintptr_t)ret_conv;
9747 }
9748
9749 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
9750         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
9751         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
9752         return ret_val;
9753 }
9754
9755 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
9756         if ((_res & 1) != 0) return;
9757         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9758         CHECK_ACCESS(_res_ptr);
9759         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
9760         FREE((void*)_res);
9761         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9762 }
9763
9764 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
9765         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9766         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
9767         return (uintptr_t)ret_conv;
9768 }
9769 intptr_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
9770         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
9771         intptr_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
9772         return ret_val;
9773 }
9774
9775 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
9776         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9777         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9778         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9779         return (uintptr_t)ret_conv;
9780 }
9781
9782 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
9783         LDKTrustedCommitmentTransaction o_conv;
9784         o_conv.inner = (void*)(o & (~1));
9785         o_conv.is_owned = (o & 1) || (o == 0);
9786         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9787         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9788         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9789         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9790         return (uintptr_t)ret_conv;
9791 }
9792
9793 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
9794         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9795         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9796         return (uintptr_t)ret_conv;
9797 }
9798
9799 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
9800         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
9801         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
9802         return ret_val;
9803 }
9804
9805 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
9806         if ((_res & 1) != 0) return;
9807         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9808         CHECK_ACCESS(_res_ptr);
9809         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
9810         FREE((void*)_res);
9811         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9812 }
9813
9814 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
9815         LDKCVec_SignatureZ o_constr;
9816         o_constr.datalen = o->arr_len;
9817         if (o_constr.datalen > 0)
9818                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9819         else
9820                 o_constr.data = NULL;
9821         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
9822         for (size_t m = 0; m < o_constr.datalen; m++) {
9823                 int8_tArray o_conv_12 = o_vals[m];
9824                 LDKSignature o_conv_12_ref;
9825                 CHECK(o_conv_12->arr_len == 64);
9826                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
9827                 o_constr.data[m] = o_conv_12_ref;
9828         }
9829         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9830         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9831         return (uintptr_t)ret_conv;
9832 }
9833
9834 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
9835         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9836         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9837         return (uintptr_t)ret_conv;
9838 }
9839
9840 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
9841         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
9842         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
9843         return ret_val;
9844 }
9845
9846 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
9847         if ((_res & 1) != 0) return;
9848         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9849         CHECK_ACCESS(_res_ptr);
9850         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
9851         FREE((void*)_res);
9852         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9853 }
9854
9855 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
9856         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9857         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
9858         return (uintptr_t)ret_conv;
9859 }
9860 intptr_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
9861         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
9862         intptr_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
9863         return ret_val;
9864 }
9865
9866 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
9867         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9868         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9869         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9870         return (uintptr_t)ret_conv;
9871 }
9872
9873 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
9874         LDKShutdownScript o_conv;
9875         o_conv.inner = (void*)(o & (~1));
9876         o_conv.is_owned = (o & 1) || (o == 0);
9877         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9878         o_conv = ShutdownScript_clone(&o_conv);
9879         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9880         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
9881         return (uintptr_t)ret_conv;
9882 }
9883
9884 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
9885         LDKDecodeError e_conv;
9886         e_conv.inner = (void*)(e & (~1));
9887         e_conv.is_owned = (e & 1) || (e == 0);
9888         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9889         e_conv = DecodeError_clone(&e_conv);
9890         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9891         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
9892         return (uintptr_t)ret_conv;
9893 }
9894
9895 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
9896         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
9897         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
9898         return ret_val;
9899 }
9900
9901 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
9902         if ((_res & 1) != 0) return;
9903         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9904         CHECK_ACCESS(_res_ptr);
9905         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
9906         FREE((void*)_res);
9907         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
9908 }
9909
9910 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
9911         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9912         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
9913         return (uintptr_t)ret_conv;
9914 }
9915 intptr_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
9916         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
9917         intptr_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
9918         return ret_val;
9919 }
9920
9921 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
9922         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
9923         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9924         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
9925         return (uintptr_t)ret_conv;
9926 }
9927
9928 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
9929         LDKShutdownScript o_conv;
9930         o_conv.inner = (void*)(o & (~1));
9931         o_conv.is_owned = (o & 1) || (o == 0);
9932         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9933         o_conv = ShutdownScript_clone(&o_conv);
9934         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9935         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
9936         return (uintptr_t)ret_conv;
9937 }
9938
9939 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
9940         LDKInvalidShutdownScript e_conv;
9941         e_conv.inner = (void*)(e & (~1));
9942         e_conv.is_owned = (e & 1) || (e == 0);
9943         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9944         e_conv = InvalidShutdownScript_clone(&e_conv);
9945         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9946         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
9947         return (uintptr_t)ret_conv;
9948 }
9949
9950 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
9951         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
9952         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
9953         return ret_val;
9954 }
9955
9956 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
9957         if ((_res & 1) != 0) return;
9958         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9959         CHECK_ACCESS(_res_ptr);
9960         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
9961         FREE((void*)_res);
9962         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
9963 }
9964
9965 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
9966         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9967         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
9968         return (uintptr_t)ret_conv;
9969 }
9970 intptr_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
9971         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
9972         intptr_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
9973         return ret_val;
9974 }
9975
9976 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
9977         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
9978         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9979         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
9980         return (uintptr_t)ret_conv;
9981 }
9982
9983 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
9984         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
9985         CHECK_ACCESS(o_ptr);
9986         LDKType o_conv = *(LDKType*)(o_ptr);
9987         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9988         *ret_copy = COption_TypeZ_some(o_conv);
9989         uintptr_t ret_ref = (uintptr_t)ret_copy;
9990         return ret_ref;
9991 }
9992
9993 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
9994         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9995         *ret_copy = COption_TypeZ_none();
9996         uintptr_t ret_ref = (uintptr_t)ret_copy;
9997         return ret_ref;
9998 }
9999
10000 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
10001         if ((_res & 1) != 0) return;
10002         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10003         CHECK_ACCESS(_res_ptr);
10004         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
10005         FREE((void*)_res);
10006         COption_TypeZ_free(_res_conv);
10007 }
10008
10009 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
10010         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
10011         *ret_copy = COption_TypeZ_clone(arg);
10012 uintptr_t ret_ref = (uintptr_t)ret_copy;
10013         return ret_ref;
10014 }
10015 intptr_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
10016         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
10017         intptr_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
10018         return ret_val;
10019 }
10020
10021 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
10022         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
10023         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
10024         *ret_copy = COption_TypeZ_clone(orig_conv);
10025         uintptr_t ret_ref = (uintptr_t)ret_copy;
10026         return ret_ref;
10027 }
10028
10029 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
10030         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
10031         CHECK_ACCESS(o_ptr);
10032         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
10033         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
10034         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10035         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
10036         return (uintptr_t)ret_conv;
10037 }
10038
10039 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
10040         LDKDecodeError e_conv;
10041         e_conv.inner = (void*)(e & (~1));
10042         e_conv.is_owned = (e & 1) || (e == 0);
10043         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10044         e_conv = DecodeError_clone(&e_conv);
10045         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10046         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
10047         return (uintptr_t)ret_conv;
10048 }
10049
10050 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
10051         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
10052         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
10053         return ret_val;
10054 }
10055
10056 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
10057         if ((_res & 1) != 0) return;
10058         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10059         CHECK_ACCESS(_res_ptr);
10060         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
10061         FREE((void*)_res);
10062         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
10063 }
10064
10065 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
10066         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10067         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
10068         return (uintptr_t)ret_conv;
10069 }
10070 intptr_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
10071         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
10072         intptr_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
10073         return ret_val;
10074 }
10075
10076 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
10077         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
10078         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10079         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
10080         return (uintptr_t)ret_conv;
10081 }
10082
10083 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
10084         LDKStr o_conv = str_ref_to_owned_c(o);
10085         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10086         *ret_conv = CResult_StringErrorZ_ok(o_conv);
10087         return (uintptr_t)ret_conv;
10088 }
10089
10090 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
10091         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10092         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10093         *ret_conv = CResult_StringErrorZ_err(e_conv);
10094         return (uintptr_t)ret_conv;
10095 }
10096
10097 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
10098         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
10099         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
10100         return ret_val;
10101 }
10102
10103 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
10104         if ((_res & 1) != 0) return;
10105         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10106         CHECK_ACCESS(_res_ptr);
10107         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
10108         FREE((void*)_res);
10109         CResult_StringErrorZ_free(_res_conv);
10110 }
10111
10112 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
10113         LDKChannelMonitorUpdate o_conv;
10114         o_conv.inner = (void*)(o & (~1));
10115         o_conv.is_owned = (o & 1) || (o == 0);
10116         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10117         o_conv = ChannelMonitorUpdate_clone(&o_conv);
10118         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10119         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
10120         return (uintptr_t)ret_conv;
10121 }
10122
10123 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
10124         LDKDecodeError e_conv;
10125         e_conv.inner = (void*)(e & (~1));
10126         e_conv.is_owned = (e & 1) || (e == 0);
10127         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10128         e_conv = DecodeError_clone(&e_conv);
10129         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10130         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
10131         return (uintptr_t)ret_conv;
10132 }
10133
10134 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
10135         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
10136         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
10137         return ret_val;
10138 }
10139
10140 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
10141         if ((_res & 1) != 0) return;
10142         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10143         CHECK_ACCESS(_res_ptr);
10144         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
10145         FREE((void*)_res);
10146         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
10147 }
10148
10149 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
10150         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10151         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
10152         return (uintptr_t)ret_conv;
10153 }
10154 intptr_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
10155         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
10156         intptr_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
10157         return ret_val;
10158 }
10159
10160 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
10161         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
10162         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10163         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
10164         return (uintptr_t)ret_conv;
10165 }
10166
10167 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
10168         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
10169         CHECK_ACCESS(o_ptr);
10170         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
10171         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
10172         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
10173         *ret_copy = COption_MonitorEventZ_some(o_conv);
10174         uintptr_t ret_ref = (uintptr_t)ret_copy;
10175         return ret_ref;
10176 }
10177
10178 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
10179         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
10180         *ret_copy = COption_MonitorEventZ_none();
10181         uintptr_t ret_ref = (uintptr_t)ret_copy;
10182         return ret_ref;
10183 }
10184
10185 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
10186         if ((_res & 1) != 0) return;
10187         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10188         CHECK_ACCESS(_res_ptr);
10189         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
10190         FREE((void*)_res);
10191         COption_MonitorEventZ_free(_res_conv);
10192 }
10193
10194 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
10195         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
10196         *ret_copy = COption_MonitorEventZ_clone(arg);
10197 uintptr_t ret_ref = (uintptr_t)ret_copy;
10198         return ret_ref;
10199 }
10200 intptr_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
10201         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
10202         intptr_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
10203         return ret_val;
10204 }
10205
10206 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
10207         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
10208         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
10209         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
10210         uintptr_t ret_ref = (uintptr_t)ret_copy;
10211         return ret_ref;
10212 }
10213
10214 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
10215         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
10216         CHECK_ACCESS(o_ptr);
10217         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
10218         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
10219         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
10220         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
10221         return (uintptr_t)ret_conv;
10222 }
10223
10224 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
10225         LDKDecodeError e_conv;
10226         e_conv.inner = (void*)(e & (~1));
10227         e_conv.is_owned = (e & 1) || (e == 0);
10228         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10229         e_conv = DecodeError_clone(&e_conv);
10230         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
10231         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
10232         return (uintptr_t)ret_conv;
10233 }
10234
10235 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
10236         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
10237         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
10238         return ret_val;
10239 }
10240
10241 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
10242         if ((_res & 1) != 0) return;
10243         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10244         CHECK_ACCESS(_res_ptr);
10245         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
10246         FREE((void*)_res);
10247         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
10248 }
10249
10250 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
10251         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
10252         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
10253         return (uintptr_t)ret_conv;
10254 }
10255 intptr_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
10256         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
10257         intptr_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
10258         return ret_val;
10259 }
10260
10261 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
10262         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
10263         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
10264         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
10265         return (uintptr_t)ret_conv;
10266 }
10267
10268 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
10269         LDKHTLCUpdate o_conv;
10270         o_conv.inner = (void*)(o & (~1));
10271         o_conv.is_owned = (o & 1) || (o == 0);
10272         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10273         o_conv = HTLCUpdate_clone(&o_conv);
10274         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10275         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
10276         return (uintptr_t)ret_conv;
10277 }
10278
10279 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
10280         LDKDecodeError e_conv;
10281         e_conv.inner = (void*)(e & (~1));
10282         e_conv.is_owned = (e & 1) || (e == 0);
10283         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10284         e_conv = DecodeError_clone(&e_conv);
10285         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10286         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
10287         return (uintptr_t)ret_conv;
10288 }
10289
10290 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
10291         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
10292         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
10293         return ret_val;
10294 }
10295
10296 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
10297         if ((_res & 1) != 0) return;
10298         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10299         CHECK_ACCESS(_res_ptr);
10300         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
10301         FREE((void*)_res);
10302         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
10303 }
10304
10305 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
10306         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10307         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
10308         return (uintptr_t)ret_conv;
10309 }
10310 intptr_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
10311         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
10312         intptr_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
10313         return ret_val;
10314 }
10315
10316 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
10317         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
10318         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10319         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
10320         return (uintptr_t)ret_conv;
10321 }
10322
10323 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
10324         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10325         *ret_conv = CResult_NoneNoneZ_ok();
10326         return (uintptr_t)ret_conv;
10327 }
10328
10329 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
10330         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10331         *ret_conv = CResult_NoneNoneZ_err();
10332         return (uintptr_t)ret_conv;
10333 }
10334
10335 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
10336         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
10337         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
10338         return ret_val;
10339 }
10340
10341 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
10342         if ((_res & 1) != 0) return;
10343         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10344         CHECK_ACCESS(_res_ptr);
10345         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
10346         FREE((void*)_res);
10347         CResult_NoneNoneZ_free(_res_conv);
10348 }
10349
10350 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
10351         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10352         *ret_conv = CResult_NoneNoneZ_clone(arg);
10353         return (uintptr_t)ret_conv;
10354 }
10355 intptr_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
10356         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
10357         intptr_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
10358         return ret_val;
10359 }
10360
10361 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
10362         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
10363         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10364         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
10365         return (uintptr_t)ret_conv;
10366 }
10367
10368 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
10369         LDKOutPoint a_conv;
10370         a_conv.inner = (void*)(a & (~1));
10371         a_conv.is_owned = (a & 1) || (a == 0);
10372         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
10373         a_conv = OutPoint_clone(&a_conv);
10374         LDKCVec_u8Z b_ref;
10375         b_ref.datalen = b->arr_len;
10376         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10377         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
10378         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10379         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
10380         return ((uintptr_t)ret_conv);
10381 }
10382
10383 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
10384         if ((_res & 1) != 0) return;
10385         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10386         CHECK_ACCESS(_res_ptr);
10387         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
10388         FREE((void*)_res);
10389         C2Tuple_OutPointScriptZ_free(_res_conv);
10390 }
10391
10392 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
10393         LDKCVec_u8Z b_ref;
10394         b_ref.datalen = b->arr_len;
10395         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10396         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
10397         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
10398         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
10399         return ((uintptr_t)ret_conv);
10400 }
10401
10402 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
10403         if ((_res & 1) != 0) return;
10404         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10405         CHECK_ACCESS(_res_ptr);
10406         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
10407         FREE((void*)_res);
10408         C2Tuple_u32ScriptZ_free(_res_conv);
10409 }
10410
10411 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
10412         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
10413         _res_constr.datalen = _res->arr_len;
10414         if (_res_constr.datalen > 0)
10415                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10416         else
10417                 _res_constr.data = NULL;
10418         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10419         for (size_t v = 0; v < _res_constr.datalen; v++) {
10420                 uint32_t _res_conv_21 = _res_vals[v];
10421                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
10422                 CHECK_ACCESS(_res_conv_21_ptr);
10423                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
10424                 FREE((void*)_res_conv_21);
10425                 _res_constr.data[v] = _res_conv_21_conv;
10426         }
10427         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
10428 }
10429
10430 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
10431         LDKThirtyTwoBytes a_ref;
10432         CHECK(a->arr_len == 32);
10433         memcpy(a_ref.data, a->elems, 32); FREE(a);
10434         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
10435         b_constr.datalen = b->arr_len;
10436         if (b_constr.datalen > 0)
10437                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10438         else
10439                 b_constr.data = NULL;
10440         uint32_t* b_vals = b->elems /* XXX b leaks */;
10441         for (size_t v = 0; v < b_constr.datalen; v++) {
10442                 uint32_t b_conv_21 = b_vals[v];
10443                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
10444                 CHECK_ACCESS(b_conv_21_ptr);
10445                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
10446                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_u32ScriptZ
10447                 b_constr.data[v] = b_conv_21_conv;
10448         }
10449         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
10450         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
10451         return ((uintptr_t)ret_conv);
10452 }
10453
10454 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
10455         if ((_res & 1) != 0) return;
10456         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10457         CHECK_ACCESS(_res_ptr);
10458         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
10459         FREE((void*)_res);
10460         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
10461 }
10462
10463 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
10464         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
10465         _res_constr.datalen = _res->arr_len;
10466         if (_res_constr.datalen > 0)
10467                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
10468         else
10469                 _res_constr.data = NULL;
10470         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10471         for (size_t o = 0; o < _res_constr.datalen; o++) {
10472                 uint32_t _res_conv_40 = _res_vals[o];
10473                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
10474                 CHECK_ACCESS(_res_conv_40_ptr);
10475                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
10476                 FREE((void*)_res_conv_40);
10477                 _res_constr.data[o] = _res_conv_40_conv;
10478         }
10479         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
10480 }
10481
10482 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
10483         LDKCVec_MonitorEventZ _res_constr;
10484         _res_constr.datalen = _res->arr_len;
10485         if (_res_constr.datalen > 0)
10486                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
10487         else
10488                 _res_constr.data = NULL;
10489         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10490         for (size_t o = 0; o < _res_constr.datalen; o++) {
10491                 uint32_t _res_conv_14 = _res_vals[o];
10492                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
10493                 CHECK_ACCESS(_res_conv_14_ptr);
10494                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
10495                 FREE((void*)_res_conv_14);
10496                 _res_constr.data[o] = _res_conv_14_conv;
10497         }
10498         CVec_MonitorEventZ_free(_res_constr);
10499 }
10500
10501 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
10502         LDKCVec_EventZ _res_constr;
10503         _res_constr.datalen = _res->arr_len;
10504         if (_res_constr.datalen > 0)
10505                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
10506         else
10507                 _res_constr.data = NULL;
10508         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10509         for (size_t h = 0; h < _res_constr.datalen; h++) {
10510                 uint32_t _res_conv_7 = _res_vals[h];
10511                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
10512                 CHECK_ACCESS(_res_conv_7_ptr);
10513                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
10514                 FREE((void*)_res_conv_7);
10515                 _res_constr.data[h] = _res_conv_7_conv;
10516         }
10517         CVec_EventZ_free(_res_constr);
10518 }
10519
10520 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
10521         LDKCVec_TransactionZ _res_constr;
10522         _res_constr.datalen = _res->arr_len;
10523         if (_res_constr.datalen > 0)
10524                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
10525         else
10526                 _res_constr.data = NULL;
10527         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
10528         for (size_t m = 0; m < _res_constr.datalen; m++) {
10529                 int8_tArray _res_conv_12 = _res_vals[m];
10530                 LDKTransaction _res_conv_12_ref;
10531                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
10532                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
10533                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
10534                 _res_conv_12_ref.data_is_owned = true;
10535                 _res_constr.data[m] = _res_conv_12_ref;
10536         }
10537         CVec_TransactionZ_free(_res_constr);
10538 }
10539
10540 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
10541         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10542         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
10543         return ((uintptr_t)ret_conv);
10544 }
10545 intptr_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
10546         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
10547         intptr_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
10548         return ret_val;
10549 }
10550
10551 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
10552         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
10553         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10554         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
10555         return ((uintptr_t)ret_conv);
10556 }
10557
10558 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(intptr_t a, int8_tArray b) {
10559         LDKTransaction b_ref;
10560         b_ref.datalen = b->arr_len;
10561         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
10562         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
10563         b_ref.data_is_owned = true;
10564         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10565         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
10566         return ((uintptr_t)ret_conv);
10567 }
10568
10569 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
10570         if ((_res & 1) != 0) return;
10571         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10572         CHECK_ACCESS(_res_ptr);
10573         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
10574         FREE((void*)_res);
10575         C2Tuple_usizeTransactionZ_free(_res_conv);
10576 }
10577
10578 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
10579         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
10580         _res_constr.datalen = _res->arr_len;
10581         if (_res_constr.datalen > 0)
10582                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10583         else
10584                 _res_constr.data = NULL;
10585         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10586         for (size_t c = 0; c < _res_constr.datalen; c++) {
10587                 uint32_t _res_conv_28 = _res_vals[c];
10588                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
10589                 CHECK_ACCESS(_res_conv_28_ptr);
10590                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
10591                 FREE((void*)_res_conv_28);
10592                 _res_constr.data[c] = _res_conv_28_conv;
10593         }
10594         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
10595 }
10596
10597 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
10598         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
10599         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
10600         return ((uintptr_t)ret_conv);
10601 }
10602 intptr_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
10603         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
10604         intptr_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
10605         return ret_val;
10606 }
10607
10608 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
10609         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
10610         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
10611         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
10612         return ((uintptr_t)ret_conv);
10613 }
10614
10615 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
10616         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
10617         CHECK_ACCESS(b_ptr);
10618         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
10619         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
10620         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
10621         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
10622         return ((uintptr_t)ret_conv);
10623 }
10624
10625 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
10626         if ((_res & 1) != 0) return;
10627         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10628         CHECK_ACCESS(_res_ptr);
10629         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
10630         FREE((void*)_res);
10631         C2Tuple_u32TxOutZ_free(_res_conv);
10632 }
10633
10634 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
10635         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
10636         _res_constr.datalen = _res->arr_len;
10637         if (_res_constr.datalen > 0)
10638                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
10639         else
10640                 _res_constr.data = NULL;
10641         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10642         for (size_t u = 0; u < _res_constr.datalen; u++) {
10643                 uint32_t _res_conv_20 = _res_vals[u];
10644                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
10645                 CHECK_ACCESS(_res_conv_20_ptr);
10646                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
10647                 FREE((void*)_res_conv_20);
10648                 _res_constr.data[u] = _res_conv_20_conv;
10649         }
10650         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
10651 }
10652
10653 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
10654         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10655         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
10656         return ((uintptr_t)ret_conv);
10657 }
10658 intptr_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
10659         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
10660         intptr_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
10661         return ret_val;
10662 }
10663
10664 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
10665         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
10666         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10667         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
10668         return ((uintptr_t)ret_conv);
10669 }
10670
10671 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
10672         LDKThirtyTwoBytes a_ref;
10673         CHECK(a->arr_len == 32);
10674         memcpy(a_ref.data, a->elems, 32); FREE(a);
10675         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
10676         b_constr.datalen = b->arr_len;
10677         if (b_constr.datalen > 0)
10678                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
10679         else
10680                 b_constr.data = NULL;
10681         uint32_t* b_vals = b->elems /* XXX b leaks */;
10682         for (size_t u = 0; u < b_constr.datalen; u++) {
10683                 uint32_t b_conv_20 = b_vals[u];
10684                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
10685                 CHECK_ACCESS(b_conv_20_ptr);
10686                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
10687                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
10688                 b_constr.data[u] = b_conv_20_conv;
10689         }
10690         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10691         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
10692         return ((uintptr_t)ret_conv);
10693 }
10694
10695 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
10696         if ((_res & 1) != 0) return;
10697         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10698         CHECK_ACCESS(_res_ptr);
10699         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
10700         FREE((void*)_res);
10701         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
10702 }
10703
10704 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
10705         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
10706         _res_constr.datalen = _res->arr_len;
10707         if (_res_constr.datalen > 0)
10708                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
10709         else
10710                 _res_constr.data = NULL;
10711         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10712         for (size_t n = 0; n < _res_constr.datalen; n++) {
10713                 uint32_t _res_conv_39 = _res_vals[n];
10714                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
10715                 CHECK_ACCESS(_res_conv_39_ptr);
10716                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
10717                 FREE((void*)_res_conv_39);
10718                 _res_constr.data[n] = _res_conv_39_conv;
10719         }
10720         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
10721 }
10722
10723 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
10724         LDKCVec_TxidZ _res_constr;
10725         _res_constr.datalen = _res->arr_len;
10726         if (_res_constr.datalen > 0)
10727                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
10728         else
10729                 _res_constr.data = NULL;
10730         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
10731         for (size_t m = 0; m < _res_constr.datalen; m++) {
10732                 int8_tArray _res_conv_12 = _res_vals[m];
10733                 LDKThirtyTwoBytes _res_conv_12_ref;
10734                 CHECK(_res_conv_12->arr_len == 32);
10735                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
10736                 _res_constr.data[m] = _res_conv_12_ref;
10737         }
10738         CVec_TxidZ_free(_res_constr);
10739 }
10740
10741 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
10742         LDKCVec_BalanceZ _res_constr;
10743         _res_constr.datalen = _res->arr_len;
10744         if (_res_constr.datalen > 0)
10745                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
10746         else
10747                 _res_constr.data = NULL;
10748         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10749         for (size_t j = 0; j < _res_constr.datalen; j++) {
10750                 uint32_t _res_conv_9 = _res_vals[j];
10751                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
10752                 CHECK_ACCESS(_res_conv_9_ptr);
10753                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
10754                 FREE((void*)_res_conv_9);
10755                 _res_constr.data[j] = _res_conv_9_conv;
10756         }
10757         CVec_BalanceZ_free(_res_constr);
10758 }
10759
10760 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
10761         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10762         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
10763         return ((uintptr_t)ret_conv);
10764 }
10765 intptr_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
10766         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
10767         intptr_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
10768         return ret_val;
10769 }
10770
10771 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
10772         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
10773         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10774         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
10775         return ((uintptr_t)ret_conv);
10776 }
10777
10778 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
10779         LDKThirtyTwoBytes a_ref;
10780         CHECK(a->arr_len == 32);
10781         memcpy(a_ref.data, a->elems, 32); FREE(a);
10782         LDKChannelMonitor b_conv;
10783         b_conv.inner = (void*)(b & (~1));
10784         b_conv.is_owned = (b & 1) || (b == 0);
10785         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
10786         b_conv = ChannelMonitor_clone(&b_conv);
10787         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10788         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10789         return ((uintptr_t)ret_conv);
10790 }
10791
10792 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
10793         if ((_res & 1) != 0) return;
10794         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10795         CHECK_ACCESS(_res_ptr);
10796         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
10797         FREE((void*)_res);
10798         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10799 }
10800
10801 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
10802         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
10803         CHECK_ACCESS(o_ptr);
10804         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
10805         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
10806         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10807         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
10808         return (uintptr_t)ret_conv;
10809 }
10810
10811 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
10812         LDKDecodeError e_conv;
10813         e_conv.inner = (void*)(e & (~1));
10814         e_conv.is_owned = (e & 1) || (e == 0);
10815         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10816         e_conv = DecodeError_clone(&e_conv);
10817         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10818         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
10819         return (uintptr_t)ret_conv;
10820 }
10821
10822 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
10823         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
10824         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
10825         return ret_val;
10826 }
10827
10828 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
10829         if ((_res & 1) != 0) return;
10830         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10831         CHECK_ACCESS(_res_ptr);
10832         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
10833         FREE((void*)_res);
10834         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
10835 }
10836
10837 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
10838         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10839         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
10840         return (uintptr_t)ret_conv;
10841 }
10842 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
10843         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
10844         intptr_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
10845         return ret_val;
10846 }
10847
10848 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
10849         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
10850         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10851         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
10852         return (uintptr_t)ret_conv;
10853 }
10854
10855 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
10856         LDKRouteHop o_conv;
10857         o_conv.inner = (void*)(o & (~1));
10858         o_conv.is_owned = (o & 1) || (o == 0);
10859         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10860         o_conv = RouteHop_clone(&o_conv);
10861         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10862         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
10863         return (uintptr_t)ret_conv;
10864 }
10865
10866 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
10867         LDKDecodeError e_conv;
10868         e_conv.inner = (void*)(e & (~1));
10869         e_conv.is_owned = (e & 1) || (e == 0);
10870         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10871         e_conv = DecodeError_clone(&e_conv);
10872         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10873         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
10874         return (uintptr_t)ret_conv;
10875 }
10876
10877 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
10878         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
10879         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
10880         return ret_val;
10881 }
10882
10883 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
10884         if ((_res & 1) != 0) return;
10885         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10886         CHECK_ACCESS(_res_ptr);
10887         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
10888         FREE((void*)_res);
10889         CResult_RouteHopDecodeErrorZ_free(_res_conv);
10890 }
10891
10892 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
10893         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10894         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
10895         return (uintptr_t)ret_conv;
10896 }
10897 intptr_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
10898         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
10899         intptr_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
10900         return ret_val;
10901 }
10902
10903 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
10904         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
10905         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10906         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
10907         return (uintptr_t)ret_conv;
10908 }
10909
10910 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
10911         LDKCVec_RouteHopZ _res_constr;
10912         _res_constr.datalen = _res->arr_len;
10913         if (_res_constr.datalen > 0)
10914                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10915         else
10916                 _res_constr.data = NULL;
10917         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10918         for (size_t k = 0; k < _res_constr.datalen; k++) {
10919                 uint32_t _res_conv_10 = _res_vals[k];
10920                 LDKRouteHop _res_conv_10_conv;
10921                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
10922                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
10923                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
10924                 _res_constr.data[k] = _res_conv_10_conv;
10925         }
10926         CVec_RouteHopZ_free(_res_constr);
10927 }
10928
10929 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
10930         LDKCVec_CVec_RouteHopZZ _res_constr;
10931         _res_constr.datalen = _res->arr_len;
10932         if (_res_constr.datalen > 0)
10933                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
10934         else
10935                 _res_constr.data = NULL;
10936         uint32_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
10937         for (size_t m = 0; m < _res_constr.datalen; m++) {
10938                 uint32_tArray _res_conv_12 = _res_vals[m];
10939                 LDKCVec_RouteHopZ _res_conv_12_constr;
10940                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
10941                 if (_res_conv_12_constr.datalen > 0)
10942                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10943                 else
10944                         _res_conv_12_constr.data = NULL;
10945                 uint32_t* _res_conv_12_vals = _res_conv_12->elems /* XXX _res_conv_12 leaks */;
10946                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
10947                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
10948                         LDKRouteHop _res_conv_12_conv_10_conv;
10949                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
10950                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
10951                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
10952                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
10953                 }
10954                 _res_constr.data[m] = _res_conv_12_constr;
10955         }
10956         CVec_CVec_RouteHopZZ_free(_res_constr);
10957 }
10958
10959 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
10960         LDKRoute o_conv;
10961         o_conv.inner = (void*)(o & (~1));
10962         o_conv.is_owned = (o & 1) || (o == 0);
10963         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10964         o_conv = Route_clone(&o_conv);
10965         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
10966         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
10967         return (uintptr_t)ret_conv;
10968 }
10969
10970 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
10971         LDKDecodeError e_conv;
10972         e_conv.inner = (void*)(e & (~1));
10973         e_conv.is_owned = (e & 1) || (e == 0);
10974         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10975         e_conv = DecodeError_clone(&e_conv);
10976         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
10977         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
10978         return (uintptr_t)ret_conv;
10979 }
10980
10981 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
10982         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
10983         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
10984         return ret_val;
10985 }
10986
10987 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
10988         if ((_res & 1) != 0) return;
10989         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10990         CHECK_ACCESS(_res_ptr);
10991         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
10992         FREE((void*)_res);
10993         CResult_RouteDecodeErrorZ_free(_res_conv);
10994 }
10995
10996 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
10997         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
10998         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
10999         return (uintptr_t)ret_conv;
11000 }
11001 intptr_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
11002         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
11003         intptr_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
11004         return ret_val;
11005 }
11006
11007 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
11008         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
11009         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11010         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
11011         return (uintptr_t)ret_conv;
11012 }
11013
11014 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
11015         LDKRouteParameters o_conv;
11016         o_conv.inner = (void*)(o & (~1));
11017         o_conv.is_owned = (o & 1) || (o == 0);
11018         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11019         o_conv = RouteParameters_clone(&o_conv);
11020         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11021         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
11022         return (uintptr_t)ret_conv;
11023 }
11024
11025 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
11026         LDKDecodeError e_conv;
11027         e_conv.inner = (void*)(e & (~1));
11028         e_conv.is_owned = (e & 1) || (e == 0);
11029         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11030         e_conv = DecodeError_clone(&e_conv);
11031         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11032         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
11033         return (uintptr_t)ret_conv;
11034 }
11035
11036 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
11037         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
11038         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
11039         return ret_val;
11040 }
11041
11042 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
11043         if ((_res & 1) != 0) return;
11044         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11045         CHECK_ACCESS(_res_ptr);
11046         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
11047         FREE((void*)_res);
11048         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
11049 }
11050
11051 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
11052         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11053         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
11054         return (uintptr_t)ret_conv;
11055 }
11056 intptr_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11057         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
11058         intptr_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
11059         return ret_val;
11060 }
11061
11062 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
11063         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
11064         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11065         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
11066         return (uintptr_t)ret_conv;
11067 }
11068
11069 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
11070         LDKCVec_RouteHintZ _res_constr;
11071         _res_constr.datalen = _res->arr_len;
11072         if (_res_constr.datalen > 0)
11073                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
11074         else
11075                 _res_constr.data = NULL;
11076         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11077         for (size_t l = 0; l < _res_constr.datalen; l++) {
11078                 uint32_t _res_conv_11 = _res_vals[l];
11079                 LDKRouteHint _res_conv_11_conv;
11080                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
11081                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
11082                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
11083                 _res_constr.data[l] = _res_conv_11_conv;
11084         }
11085         CVec_RouteHintZ_free(_res_constr);
11086 }
11087
11088 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
11089         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11090         *ret_copy = COption_u64Z_some(o);
11091         uintptr_t ret_ref = (uintptr_t)ret_copy;
11092         return ret_ref;
11093 }
11094
11095 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
11096         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11097         *ret_copy = COption_u64Z_none();
11098         uintptr_t ret_ref = (uintptr_t)ret_copy;
11099         return ret_ref;
11100 }
11101
11102 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
11103         if ((_res & 1) != 0) return;
11104         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11105         CHECK_ACCESS(_res_ptr);
11106         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
11107         FREE((void*)_res);
11108         COption_u64Z_free(_res_conv);
11109 }
11110
11111 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
11112         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11113         *ret_copy = COption_u64Z_clone(arg);
11114 uintptr_t ret_ref = (uintptr_t)ret_copy;
11115         return ret_ref;
11116 }
11117 intptr_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
11118         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
11119         intptr_t ret_val = COption_u64Z_clone_ptr(arg_conv);
11120         return ret_val;
11121 }
11122
11123 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
11124         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
11125         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11126         *ret_copy = COption_u64Z_clone(orig_conv);
11127         uintptr_t ret_ref = (uintptr_t)ret_copy;
11128         return ret_ref;
11129 }
11130
11131 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_ok"))) TS_CResult_PayeeDecodeErrorZ_ok(uint32_t o) {
11132         LDKPayee 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 = Payee_clone(&o_conv);
11137         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
11138         *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
11139         return (uintptr_t)ret_conv;
11140 }
11141
11142 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_err"))) TS_CResult_PayeeDecodeErrorZ_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_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
11149         *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
11150         return (uintptr_t)ret_conv;
11151 }
11152
11153 jboolean  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_is_ok"))) TS_CResult_PayeeDecodeErrorZ_is_ok(uint32_t o) {
11154         LDKCResult_PayeeDecodeErrorZ* o_conv = (LDKCResult_PayeeDecodeErrorZ*)(o & ~1);
11155         jboolean ret_val = CResult_PayeeDecodeErrorZ_is_ok(o_conv);
11156         return ret_val;
11157 }
11158
11159 void  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_free"))) TS_CResult_PayeeDecodeErrorZ_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_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
11164         FREE((void*)_res);
11165         CResult_PayeeDecodeErrorZ_free(_res_conv);
11166 }
11167
11168 static inline uintptr_t CResult_PayeeDecodeErrorZ_clone_ptr(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR arg) {
11169         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
11170         *ret_conv = CResult_PayeeDecodeErrorZ_clone(arg);
11171         return (uintptr_t)ret_conv;
11172 }
11173 intptr_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_clone_ptr"))) TS_CResult_PayeeDecodeErrorZ_clone_ptr(uint32_t arg) {
11174         LDKCResult_PayeeDecodeErrorZ* arg_conv = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
11175         intptr_t ret_val = CResult_PayeeDecodeErrorZ_clone_ptr(arg_conv);
11176         return ret_val;
11177 }
11178
11179 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_clone"))) TS_CResult_PayeeDecodeErrorZ_clone(uint32_t orig) {
11180         LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
11181         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
11182         *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
11183         return (uintptr_t)ret_conv;
11184 }
11185
11186 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
11187         LDKCVec_RouteHintHopZ _res_constr;
11188         _res_constr.datalen = _res->arr_len;
11189         if (_res_constr.datalen > 0)
11190                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
11191         else
11192                 _res_constr.data = NULL;
11193         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11194         for (size_t o = 0; o < _res_constr.datalen; o++) {
11195                 uint32_t _res_conv_14 = _res_vals[o];
11196                 LDKRouteHintHop _res_conv_14_conv;
11197                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11198                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11199                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
11200                 _res_constr.data[o] = _res_conv_14_conv;
11201         }
11202         CVec_RouteHintHopZ_free(_res_constr);
11203 }
11204
11205 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
11206         LDKRouteHint o_conv;
11207         o_conv.inner = (void*)(o & (~1));
11208         o_conv.is_owned = (o & 1) || (o == 0);
11209         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11210         o_conv = RouteHint_clone(&o_conv);
11211         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11212         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
11213         return (uintptr_t)ret_conv;
11214 }
11215
11216 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
11217         LDKDecodeError e_conv;
11218         e_conv.inner = (void*)(e & (~1));
11219         e_conv.is_owned = (e & 1) || (e == 0);
11220         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11221         e_conv = DecodeError_clone(&e_conv);
11222         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11223         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
11224         return (uintptr_t)ret_conv;
11225 }
11226
11227 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
11228         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
11229         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
11230         return ret_val;
11231 }
11232
11233 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
11234         if ((_res & 1) != 0) return;
11235         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11236         CHECK_ACCESS(_res_ptr);
11237         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
11238         FREE((void*)_res);
11239         CResult_RouteHintDecodeErrorZ_free(_res_conv);
11240 }
11241
11242 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
11243         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11244         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
11245         return (uintptr_t)ret_conv;
11246 }
11247 intptr_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
11248         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
11249         intptr_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
11250         return ret_val;
11251 }
11252
11253 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
11254         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
11255         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11256         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
11257         return (uintptr_t)ret_conv;
11258 }
11259
11260 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
11261         LDKRouteHintHop o_conv;
11262         o_conv.inner = (void*)(o & (~1));
11263         o_conv.is_owned = (o & 1) || (o == 0);
11264         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11265         o_conv = RouteHintHop_clone(&o_conv);
11266         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11267         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
11268         return (uintptr_t)ret_conv;
11269 }
11270
11271 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
11272         LDKDecodeError e_conv;
11273         e_conv.inner = (void*)(e & (~1));
11274         e_conv.is_owned = (e & 1) || (e == 0);
11275         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11276         e_conv = DecodeError_clone(&e_conv);
11277         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11278         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
11279         return (uintptr_t)ret_conv;
11280 }
11281
11282 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
11283         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
11284         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
11285         return ret_val;
11286 }
11287
11288 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
11289         if ((_res & 1) != 0) return;
11290         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11291         CHECK_ACCESS(_res_ptr);
11292         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
11293         FREE((void*)_res);
11294         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
11295 }
11296
11297 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
11298         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11299         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
11300         return (uintptr_t)ret_conv;
11301 }
11302 intptr_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
11303         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
11304         intptr_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
11305         return ret_val;
11306 }
11307
11308 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
11309         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
11310         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11311         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
11312         return (uintptr_t)ret_conv;
11313 }
11314
11315 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
11316         LDKCVec_ChannelDetailsZ _res_constr;
11317         _res_constr.datalen = _res->arr_len;
11318         if (_res_constr.datalen > 0)
11319                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11320         else
11321                 _res_constr.data = NULL;
11322         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11323         for (size_t q = 0; q < _res_constr.datalen; q++) {
11324                 uint32_t _res_conv_16 = _res_vals[q];
11325                 LDKChannelDetails _res_conv_16_conv;
11326                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11327                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11328                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
11329                 _res_constr.data[q] = _res_conv_16_conv;
11330         }
11331         CVec_ChannelDetailsZ_free(_res_constr);
11332 }
11333
11334 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
11335         LDKRoute o_conv;
11336         o_conv.inner = (void*)(o & (~1));
11337         o_conv.is_owned = (o & 1) || (o == 0);
11338         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11339         o_conv = Route_clone(&o_conv);
11340         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11341         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
11342         return (uintptr_t)ret_conv;
11343 }
11344
11345 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
11346         LDKLightningError e_conv;
11347         e_conv.inner = (void*)(e & (~1));
11348         e_conv.is_owned = (e & 1) || (e == 0);
11349         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11350         e_conv = LightningError_clone(&e_conv);
11351         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11352         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
11353         return (uintptr_t)ret_conv;
11354 }
11355
11356 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
11357         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
11358         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
11359         return ret_val;
11360 }
11361
11362 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
11363         if ((_res & 1) != 0) return;
11364         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11365         CHECK_ACCESS(_res_ptr);
11366         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
11367         FREE((void*)_res);
11368         CResult_RouteLightningErrorZ_free(_res_conv);
11369 }
11370
11371 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
11372         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11373         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
11374         return (uintptr_t)ret_conv;
11375 }
11376 intptr_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
11377         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
11378         intptr_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
11379         return ret_val;
11380 }
11381
11382 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
11383         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
11384         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11385         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
11386         return (uintptr_t)ret_conv;
11387 }
11388
11389 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
11390         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11391         *ret_conv = CResult_NoneLightningErrorZ_ok();
11392         return (uintptr_t)ret_conv;
11393 }
11394
11395 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
11396         LDKLightningError e_conv;
11397         e_conv.inner = (void*)(e & (~1));
11398         e_conv.is_owned = (e & 1) || (e == 0);
11399         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11400         e_conv = LightningError_clone(&e_conv);
11401         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11402         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11403         return (uintptr_t)ret_conv;
11404 }
11405
11406 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
11407         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
11408         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
11409         return ret_val;
11410 }
11411
11412 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
11413         if ((_res & 1) != 0) return;
11414         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11415         CHECK_ACCESS(_res_ptr);
11416         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
11417         FREE((void*)_res);
11418         CResult_NoneLightningErrorZ_free(_res_conv);
11419 }
11420
11421 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
11422         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11423         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
11424         return (uintptr_t)ret_conv;
11425 }
11426 intptr_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
11427         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
11428         intptr_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
11429         return ret_val;
11430 }
11431
11432 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
11433         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11434         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11435         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11436         return (uintptr_t)ret_conv;
11437 }
11438
11439 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
11440         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
11441         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
11442         return ((uintptr_t)ret_conv);
11443 }
11444 intptr_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
11445         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
11446         intptr_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
11447         return ret_val;
11448 }
11449
11450 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
11451         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
11452         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
11453         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
11454         return ((uintptr_t)ret_conv);
11455 }
11456
11457 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
11458         LDKPublicKey a_ref;
11459         CHECK(a->arr_len == 33);
11460         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
11461         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
11462         CHECK_ACCESS(b_ptr);
11463         LDKType b_conv = *(LDKType*)(b_ptr);
11464         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
11465         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
11466         return ((uintptr_t)ret_conv);
11467 }
11468
11469 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
11470         if ((_res & 1) != 0) return;
11471         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11472         CHECK_ACCESS(_res_ptr);
11473         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
11474         FREE((void*)_res);
11475         C2Tuple_PublicKeyTypeZ_free(_res_conv);
11476 }
11477
11478 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
11479         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
11480         _res_constr.datalen = _res->arr_len;
11481         if (_res_constr.datalen > 0)
11482                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
11483         else
11484                 _res_constr.data = NULL;
11485         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11486         for (size_t z = 0; z < _res_constr.datalen; z++) {
11487                 uint32_t _res_conv_25 = _res_vals[z];
11488                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
11489                 CHECK_ACCESS(_res_conv_25_ptr);
11490                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
11491                 FREE((void*)_res_conv_25);
11492                 _res_constr.data[z] = _res_conv_25_conv;
11493         }
11494         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
11495 }
11496
11497 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
11498         LDKCVec_MessageSendEventZ _res_constr;
11499         _res_constr.datalen = _res->arr_len;
11500         if (_res_constr.datalen > 0)
11501                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
11502         else
11503                 _res_constr.data = NULL;
11504         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11505         for (size_t s = 0; s < _res_constr.datalen; s++) {
11506                 uint32_t _res_conv_18 = _res_vals[s];
11507                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
11508                 CHECK_ACCESS(_res_conv_18_ptr);
11509                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
11510                 FREE((void*)_res_conv_18);
11511                 _res_constr.data[s] = _res_conv_18_conv;
11512         }
11513         CVec_MessageSendEventZ_free(_res_constr);
11514 }
11515
11516 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
11517         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11518         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11519         return (uintptr_t)ret_conv;
11520 }
11521
11522 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
11523         LDKLightningError e_conv;
11524         e_conv.inner = (void*)(e & (~1));
11525         e_conv.is_owned = (e & 1) || (e == 0);
11526         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11527         e_conv = LightningError_clone(&e_conv);
11528         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11529         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11530         return (uintptr_t)ret_conv;
11531 }
11532
11533 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
11534         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
11535         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
11536         return ret_val;
11537 }
11538
11539 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
11540         if ((_res & 1) != 0) return;
11541         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11542         CHECK_ACCESS(_res_ptr);
11543         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
11544         FREE((void*)_res);
11545         CResult_boolLightningErrorZ_free(_res_conv);
11546 }
11547
11548 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
11549         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11550         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
11551         return (uintptr_t)ret_conv;
11552 }
11553 intptr_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
11554         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
11555         intptr_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
11556         return ret_val;
11557 }
11558
11559 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
11560         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11561         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11562         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11563         return (uintptr_t)ret_conv;
11564 }
11565
11566 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
11567         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11568         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
11569         return ((uintptr_t)ret_conv);
11570 }
11571 intptr_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
11572         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
11573         intptr_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
11574         return ret_val;
11575 }
11576
11577 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
11578         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11579         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11580         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11581         return ((uintptr_t)ret_conv);
11582 }
11583
11584 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
11585         LDKChannelAnnouncement a_conv;
11586         a_conv.inner = (void*)(a & (~1));
11587         a_conv.is_owned = (a & 1) || (a == 0);
11588         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
11589         a_conv = ChannelAnnouncement_clone(&a_conv);
11590         LDKChannelUpdate b_conv;
11591         b_conv.inner = (void*)(b & (~1));
11592         b_conv.is_owned = (b & 1) || (b == 0);
11593         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
11594         b_conv = ChannelUpdate_clone(&b_conv);
11595         LDKChannelUpdate c_conv;
11596         c_conv.inner = (void*)(c & (~1));
11597         c_conv.is_owned = (c & 1) || (c == 0);
11598         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
11599         c_conv = ChannelUpdate_clone(&c_conv);
11600         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11601         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11602         return ((uintptr_t)ret_conv);
11603 }
11604
11605 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
11606         if ((_res & 1) != 0) return;
11607         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11608         CHECK_ACCESS(_res_ptr);
11609         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
11610         FREE((void*)_res);
11611         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11612 }
11613
11614 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
11615         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11616         _res_constr.datalen = _res->arr_len;
11617         if (_res_constr.datalen > 0)
11618                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11619         else
11620                 _res_constr.data = NULL;
11621         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11622         for (size_t h = 0; h < _res_constr.datalen; h++) {
11623                 uint32_t _res_conv_59 = _res_vals[h];
11624                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
11625                 CHECK_ACCESS(_res_conv_59_ptr);
11626                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
11627                 FREE((void*)_res_conv_59);
11628                 _res_constr.data[h] = _res_conv_59_conv;
11629         }
11630         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11631 }
11632
11633 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
11634         LDKCVec_NodeAnnouncementZ _res_constr;
11635         _res_constr.datalen = _res->arr_len;
11636         if (_res_constr.datalen > 0)
11637                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11638         else
11639                 _res_constr.data = NULL;
11640         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11641         for (size_t s = 0; s < _res_constr.datalen; s++) {
11642                 uint32_t _res_conv_18 = _res_vals[s];
11643                 LDKNodeAnnouncement _res_conv_18_conv;
11644                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11645                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11646                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
11647                 _res_constr.data[s] = _res_conv_18_conv;
11648         }
11649         CVec_NodeAnnouncementZ_free(_res_constr);
11650 }
11651
11652 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
11653         LDKCVec_PublicKeyZ _res_constr;
11654         _res_constr.datalen = _res->arr_len;
11655         if (_res_constr.datalen > 0)
11656                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11657         else
11658                 _res_constr.data = NULL;
11659         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11660         for (size_t m = 0; m < _res_constr.datalen; m++) {
11661                 int8_tArray _res_conv_12 = _res_vals[m];
11662                 LDKPublicKey _res_conv_12_ref;
11663                 CHECK(_res_conv_12->arr_len == 33);
11664                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
11665                 _res_constr.data[m] = _res_conv_12_ref;
11666         }
11667         CVec_PublicKeyZ_free(_res_constr);
11668 }
11669
11670 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
11671         LDKCVec_u8Z _res_ref;
11672         _res_ref.datalen = _res->arr_len;
11673         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
11674         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
11675         CVec_u8Z_free(_res_ref);
11676 }
11677
11678 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
11679         LDKCVec_u8Z o_ref;
11680         o_ref.datalen = o->arr_len;
11681         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11682         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
11683         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11684         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11685         return (uintptr_t)ret_conv;
11686 }
11687
11688 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
11689         LDKPeerHandleError e_conv;
11690         e_conv.inner = (void*)(e & (~1));
11691         e_conv.is_owned = (e & 1) || (e == 0);
11692         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11693         e_conv = PeerHandleError_clone(&e_conv);
11694         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11695         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11696         return (uintptr_t)ret_conv;
11697 }
11698
11699 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
11700         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
11701         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
11702         return ret_val;
11703 }
11704
11705 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
11706         if ((_res & 1) != 0) return;
11707         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11708         CHECK_ACCESS(_res_ptr);
11709         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
11710         FREE((void*)_res);
11711         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11712 }
11713
11714 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
11715         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11716         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
11717         return (uintptr_t)ret_conv;
11718 }
11719 intptr_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
11720         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
11721         intptr_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
11722         return ret_val;
11723 }
11724
11725 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
11726         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11727         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11728         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11729         return (uintptr_t)ret_conv;
11730 }
11731
11732 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
11733         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11734         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11735         return (uintptr_t)ret_conv;
11736 }
11737
11738 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
11739         LDKPeerHandleError e_conv;
11740         e_conv.inner = (void*)(e & (~1));
11741         e_conv.is_owned = (e & 1) || (e == 0);
11742         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11743         e_conv = PeerHandleError_clone(&e_conv);
11744         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11745         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11746         return (uintptr_t)ret_conv;
11747 }
11748
11749 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
11750         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
11751         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
11752         return ret_val;
11753 }
11754
11755 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
11756         if ((_res & 1) != 0) return;
11757         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11758         CHECK_ACCESS(_res_ptr);
11759         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
11760         FREE((void*)_res);
11761         CResult_NonePeerHandleErrorZ_free(_res_conv);
11762 }
11763
11764 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
11765         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11766         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
11767         return (uintptr_t)ret_conv;
11768 }
11769 intptr_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
11770         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
11771         intptr_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
11772         return ret_val;
11773 }
11774
11775 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
11776         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
11777         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11778         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
11779         return (uintptr_t)ret_conv;
11780 }
11781
11782 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
11783         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11784         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
11785         return (uintptr_t)ret_conv;
11786 }
11787
11788 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
11789         LDKPeerHandleError e_conv;
11790         e_conv.inner = (void*)(e & (~1));
11791         e_conv.is_owned = (e & 1) || (e == 0);
11792         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11793         e_conv = PeerHandleError_clone(&e_conv);
11794         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11795         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
11796         return (uintptr_t)ret_conv;
11797 }
11798
11799 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
11800         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
11801         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
11802         return ret_val;
11803 }
11804
11805 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
11806         if ((_res & 1) != 0) return;
11807         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11808         CHECK_ACCESS(_res_ptr);
11809         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
11810         FREE((void*)_res);
11811         CResult_boolPeerHandleErrorZ_free(_res_conv);
11812 }
11813
11814 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
11815         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11816         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
11817         return (uintptr_t)ret_conv;
11818 }
11819 intptr_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
11820         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
11821         intptr_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
11822         return ret_val;
11823 }
11824
11825 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
11826         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
11827         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11828         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
11829         return (uintptr_t)ret_conv;
11830 }
11831
11832 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
11833         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
11834         CHECK_ACCESS(o_ptr);
11835         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
11836         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
11837         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11838         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
11839         return (uintptr_t)ret_conv;
11840 }
11841
11842 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
11843         LDKAccessError e_conv = LDKAccessError_from_js(e);
11844         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11845         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
11846         return (uintptr_t)ret_conv;
11847 }
11848
11849 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
11850         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
11851         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
11852         return ret_val;
11853 }
11854
11855 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
11856         if ((_res & 1) != 0) return;
11857         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11858         CHECK_ACCESS(_res_ptr);
11859         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
11860         FREE((void*)_res);
11861         CResult_TxOutAccessErrorZ_free(_res_conv);
11862 }
11863
11864 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
11865         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11866         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
11867         return (uintptr_t)ret_conv;
11868 }
11869 intptr_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
11870         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
11871         intptr_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
11872         return ret_val;
11873 }
11874
11875 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
11876         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
11877         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11878         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
11879         return (uintptr_t)ret_conv;
11880 }
11881
11882 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
11883         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11884         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
11885         return (uintptr_t)ret_conv;
11886 }
11887
11888 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
11889         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
11890         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11891         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
11892         return (uintptr_t)ret_conv;
11893 }
11894
11895 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
11896         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
11897         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
11898         return ret_val;
11899 }
11900
11901 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
11902         if ((_res & 1) != 0) return;
11903         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11904         CHECK_ACCESS(_res_ptr);
11905         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
11906         FREE((void*)_res);
11907         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
11908 }
11909
11910 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
11911         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11912         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
11913         return (uintptr_t)ret_conv;
11914 }
11915 intptr_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
11916         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
11917         intptr_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
11918         return ret_val;
11919 }
11920
11921 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
11922         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
11923         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11924         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
11925         return (uintptr_t)ret_conv;
11926 }
11927
11928 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
11929         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
11930         CHECK_ACCESS(o_ptr);
11931         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
11932         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
11933         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11934         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
11935         uintptr_t ret_ref = (uintptr_t)ret_copy;
11936         return ret_ref;
11937 }
11938
11939 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
11940         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11941         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
11942         uintptr_t ret_ref = (uintptr_t)ret_copy;
11943         return ret_ref;
11944 }
11945
11946 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
11947         if ((_res & 1) != 0) return;
11948         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11949         CHECK_ACCESS(_res_ptr);
11950         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
11951         FREE((void*)_res);
11952         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
11953 }
11954
11955 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
11956         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11957         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
11958 uintptr_t ret_ref = (uintptr_t)ret_copy;
11959         return ret_ref;
11960 }
11961 intptr_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
11962         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
11963         intptr_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
11964         return ret_val;
11965 }
11966
11967 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
11968         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
11969         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11970         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
11971         uintptr_t ret_ref = (uintptr_t)ret_copy;
11972         return ret_ref;
11973 }
11974
11975 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
11976         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
11977         CHECK_ACCESS(o_ptr);
11978         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
11979         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
11980         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
11981         *ret_copy = COption_ClosureReasonZ_some(o_conv);
11982         uintptr_t ret_ref = (uintptr_t)ret_copy;
11983         return ret_ref;
11984 }
11985
11986 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
11987         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
11988         *ret_copy = COption_ClosureReasonZ_none();
11989         uintptr_t ret_ref = (uintptr_t)ret_copy;
11990         return ret_ref;
11991 }
11992
11993 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
11994         if ((_res & 1) != 0) return;
11995         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11996         CHECK_ACCESS(_res_ptr);
11997         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
11998         FREE((void*)_res);
11999         COption_ClosureReasonZ_free(_res_conv);
12000 }
12001
12002 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12003         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12004         *ret_copy = COption_ClosureReasonZ_clone(arg);
12005 uintptr_t ret_ref = (uintptr_t)ret_copy;
12006         return ret_ref;
12007 }
12008 intptr_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
12009         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12010         intptr_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
12011         return ret_val;
12012 }
12013
12014 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
12015         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12016         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12017         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12018         uintptr_t ret_ref = (uintptr_t)ret_copy;
12019         return ret_ref;
12020 }
12021
12022 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
12023         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12024         CHECK_ACCESS(o_ptr);
12025         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12026         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
12027         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12028         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12029         return (uintptr_t)ret_conv;
12030 }
12031
12032 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
12033         LDKDecodeError e_conv;
12034         e_conv.inner = (void*)(e & (~1));
12035         e_conv.is_owned = (e & 1) || (e == 0);
12036         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12037         e_conv = DecodeError_clone(&e_conv);
12038         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12039         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12040         return (uintptr_t)ret_conv;
12041 }
12042
12043 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
12044         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12045         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12046         return ret_val;
12047 }
12048
12049 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
12050         if ((_res & 1) != 0) return;
12051         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12052         CHECK_ACCESS(_res_ptr);
12053         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12054         FREE((void*)_res);
12055         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12056 }
12057
12058 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12059         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12060         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12061         return (uintptr_t)ret_conv;
12062 }
12063 intptr_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
12064         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12065         intptr_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12066         return ret_val;
12067 }
12068
12069 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
12070         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12071         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12072         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12073         return (uintptr_t)ret_conv;
12074 }
12075
12076 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
12077         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12078         CHECK_ACCESS(o_ptr);
12079         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12080         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
12081         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12082         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12083         uintptr_t ret_ref = (uintptr_t)ret_copy;
12084         return ret_ref;
12085 }
12086
12087 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
12088         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12089         *ret_copy = COption_NetworkUpdateZ_none();
12090         uintptr_t ret_ref = (uintptr_t)ret_copy;
12091         return ret_ref;
12092 }
12093
12094 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
12095         if ((_res & 1) != 0) return;
12096         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12097         CHECK_ACCESS(_res_ptr);
12098         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12099         FREE((void*)_res);
12100         COption_NetworkUpdateZ_free(_res_conv);
12101 }
12102
12103 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12104         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12105         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12106 uintptr_t ret_ref = (uintptr_t)ret_copy;
12107         return ret_ref;
12108 }
12109 intptr_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
12110         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12111         intptr_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12112         return ret_val;
12113 }
12114
12115 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
12116         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12117         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12118         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12119         uintptr_t ret_ref = (uintptr_t)ret_copy;
12120         return ret_ref;
12121 }
12122
12123 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
12124         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12125         _res_constr.datalen = _res->arr_len;
12126         if (_res_constr.datalen > 0)
12127                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12128         else
12129                 _res_constr.data = NULL;
12130         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12131         for (size_t b = 0; b < _res_constr.datalen; b++) {
12132                 uint32_t _res_conv_27 = _res_vals[b];
12133                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
12134                 CHECK_ACCESS(_res_conv_27_ptr);
12135                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12136                 FREE((void*)_res_conv_27);
12137                 _res_constr.data[b] = _res_conv_27_conv;
12138         }
12139         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12140 }
12141
12142 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
12143         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12144         CHECK_ACCESS(o_ptr);
12145         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12146         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
12147         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12148         *ret_copy = COption_EventZ_some(o_conv);
12149         uintptr_t ret_ref = (uintptr_t)ret_copy;
12150         return ret_ref;
12151 }
12152
12153 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
12154         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12155         *ret_copy = COption_EventZ_none();
12156         uintptr_t ret_ref = (uintptr_t)ret_copy;
12157         return ret_ref;
12158 }
12159
12160 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
12161         if ((_res & 1) != 0) return;
12162         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12163         CHECK_ACCESS(_res_ptr);
12164         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12165         FREE((void*)_res);
12166         COption_EventZ_free(_res_conv);
12167 }
12168
12169 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12170         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12171         *ret_copy = COption_EventZ_clone(arg);
12172 uintptr_t ret_ref = (uintptr_t)ret_copy;
12173         return ret_ref;
12174 }
12175 intptr_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
12176         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12177         intptr_t ret_val = COption_EventZ_clone_ptr(arg_conv);
12178         return ret_val;
12179 }
12180
12181 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
12182         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12183         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12184         *ret_copy = COption_EventZ_clone(orig_conv);
12185         uintptr_t ret_ref = (uintptr_t)ret_copy;
12186         return ret_ref;
12187 }
12188
12189 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
12190         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12191         CHECK_ACCESS(o_ptr);
12192         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12193         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
12194         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12195         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12196         return (uintptr_t)ret_conv;
12197 }
12198
12199 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
12200         LDKDecodeError e_conv;
12201         e_conv.inner = (void*)(e & (~1));
12202         e_conv.is_owned = (e & 1) || (e == 0);
12203         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12204         e_conv = DecodeError_clone(&e_conv);
12205         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12206         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
12207         return (uintptr_t)ret_conv;
12208 }
12209
12210 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
12211         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
12212         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
12213         return ret_val;
12214 }
12215
12216 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
12217         if ((_res & 1) != 0) return;
12218         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12219         CHECK_ACCESS(_res_ptr);
12220         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
12221         FREE((void*)_res);
12222         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
12223 }
12224
12225 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
12226         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12227         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
12228         return (uintptr_t)ret_conv;
12229 }
12230 intptr_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12231         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
12232         intptr_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
12233         return ret_val;
12234 }
12235
12236 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
12237         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
12238         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12239         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
12240         return (uintptr_t)ret_conv;
12241 }
12242
12243 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
12244         LDKNodeId o_conv;
12245         o_conv.inner = (void*)(o & (~1));
12246         o_conv.is_owned = (o & 1) || (o == 0);
12247         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12248         o_conv = NodeId_clone(&o_conv);
12249         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12250         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
12251         return (uintptr_t)ret_conv;
12252 }
12253
12254 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
12255         LDKDecodeError e_conv;
12256         e_conv.inner = (void*)(e & (~1));
12257         e_conv.is_owned = (e & 1) || (e == 0);
12258         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12259         e_conv = DecodeError_clone(&e_conv);
12260         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12261         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
12262         return (uintptr_t)ret_conv;
12263 }
12264
12265 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
12266         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
12267         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
12268         return ret_val;
12269 }
12270
12271 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
12272         if ((_res & 1) != 0) return;
12273         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12274         CHECK_ACCESS(_res_ptr);
12275         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
12276         FREE((void*)_res);
12277         CResult_NodeIdDecodeErrorZ_free(_res_conv);
12278 }
12279
12280 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
12281         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12282         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
12283         return (uintptr_t)ret_conv;
12284 }
12285 intptr_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
12286         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
12287         intptr_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
12288         return ret_val;
12289 }
12290
12291 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
12292         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
12293         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12294         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
12295         return (uintptr_t)ret_conv;
12296 }
12297
12298 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
12299         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12300         CHECK_ACCESS(o_ptr);
12301         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
12302         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
12303         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
12304         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
12305         return (uintptr_t)ret_conv;
12306 }
12307
12308 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
12309         LDKDecodeError e_conv;
12310         e_conv.inner = (void*)(e & (~1));
12311         e_conv.is_owned = (e & 1) || (e == 0);
12312         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12313         e_conv = DecodeError_clone(&e_conv);
12314         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
12315         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
12316         return (uintptr_t)ret_conv;
12317 }
12318
12319 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
12320         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
12321         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
12322         return ret_val;
12323 }
12324
12325 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
12326         if ((_res & 1) != 0) return;
12327         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12328         CHECK_ACCESS(_res_ptr);
12329         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
12330         FREE((void*)_res);
12331         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
12332 }
12333
12334 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
12335         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
12336         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
12337         return (uintptr_t)ret_conv;
12338 }
12339 intptr_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
12340         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
12341         intptr_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
12342         return ret_val;
12343 }
12344
12345 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
12346         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
12347         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
12348         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
12349         return (uintptr_t)ret_conv;
12350 }
12351
12352 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
12353         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12354         CHECK_ACCESS(o_ptr);
12355         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
12356         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
12357         *ret_copy = COption_AccessZ_some(o_conv);
12358         uintptr_t ret_ref = (uintptr_t)ret_copy;
12359         return ret_ref;
12360 }
12361
12362 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
12363         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
12364         *ret_copy = COption_AccessZ_none();
12365         uintptr_t ret_ref = (uintptr_t)ret_copy;
12366         return ret_ref;
12367 }
12368
12369 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
12370         if ((_res & 1) != 0) return;
12371         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12372         CHECK_ACCESS(_res_ptr);
12373         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
12374         FREE((void*)_res);
12375         COption_AccessZ_free(_res_conv);
12376 }
12377
12378 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
12379         LDKDirectionalChannelInfo o_conv;
12380         o_conv.inner = (void*)(o & (~1));
12381         o_conv.is_owned = (o & 1) || (o == 0);
12382         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12383         o_conv = DirectionalChannelInfo_clone(&o_conv);
12384         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12385         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
12386         return (uintptr_t)ret_conv;
12387 }
12388
12389 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_err"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
12390         LDKDecodeError e_conv;
12391         e_conv.inner = (void*)(e & (~1));
12392         e_conv.is_owned = (e & 1) || (e == 0);
12393         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12394         e_conv = DecodeError_clone(&e_conv);
12395         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12396         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
12397         return (uintptr_t)ret_conv;
12398 }
12399
12400 jboolean  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
12401         LDKCResult_DirectionalChannelInfoDecodeErrorZ* o_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(o & ~1);
12402         jboolean ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(o_conv);
12403         return ret_val;
12404 }
12405
12406 void  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_free"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
12407         if ((_res & 1) != 0) return;
12408         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12409         CHECK_ACCESS(_res_ptr);
12410         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
12411         FREE((void*)_res);
12412         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
12413 }
12414
12415 static inline uintptr_t CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
12416         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12417         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(arg);
12418         return (uintptr_t)ret_conv;
12419 }
12420 intptr_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
12421         LDKCResult_DirectionalChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
12422         intptr_t ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
12423         return ret_val;
12424 }
12425
12426 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
12427         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
12428         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12429         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
12430         return (uintptr_t)ret_conv;
12431 }
12432
12433 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
12434         LDKChannelInfo o_conv;
12435         o_conv.inner = (void*)(o & (~1));
12436         o_conv.is_owned = (o & 1) || (o == 0);
12437         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12438         o_conv = ChannelInfo_clone(&o_conv);
12439         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12440         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
12441         return (uintptr_t)ret_conv;
12442 }
12443
12444 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
12445         LDKDecodeError e_conv;
12446         e_conv.inner = (void*)(e & (~1));
12447         e_conv.is_owned = (e & 1) || (e == 0);
12448         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12449         e_conv = DecodeError_clone(&e_conv);
12450         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12451         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
12452         return (uintptr_t)ret_conv;
12453 }
12454
12455 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
12456         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
12457         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
12458         return ret_val;
12459 }
12460
12461 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
12462         if ((_res & 1) != 0) return;
12463         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12464         CHECK_ACCESS(_res_ptr);
12465         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
12466         FREE((void*)_res);
12467         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
12468 }
12469
12470 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
12471         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12472         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
12473         return (uintptr_t)ret_conv;
12474 }
12475 intptr_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
12476         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
12477         intptr_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
12478         return ret_val;
12479 }
12480
12481 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
12482         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
12483         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12484         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
12485         return (uintptr_t)ret_conv;
12486 }
12487
12488 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
12489         LDKRoutingFees o_conv;
12490         o_conv.inner = (void*)(o & (~1));
12491         o_conv.is_owned = (o & 1) || (o == 0);
12492         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12493         o_conv = RoutingFees_clone(&o_conv);
12494         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12495         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
12496         return (uintptr_t)ret_conv;
12497 }
12498
12499 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
12500         LDKDecodeError e_conv;
12501         e_conv.inner = (void*)(e & (~1));
12502         e_conv.is_owned = (e & 1) || (e == 0);
12503         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12504         e_conv = DecodeError_clone(&e_conv);
12505         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12506         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
12507         return (uintptr_t)ret_conv;
12508 }
12509
12510 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
12511         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
12512         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
12513         return ret_val;
12514 }
12515
12516 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
12517         if ((_res & 1) != 0) return;
12518         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12519         CHECK_ACCESS(_res_ptr);
12520         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
12521         FREE((void*)_res);
12522         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
12523 }
12524
12525 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
12526         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12527         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
12528         return (uintptr_t)ret_conv;
12529 }
12530 intptr_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
12531         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
12532         intptr_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
12533         return ret_val;
12534 }
12535
12536 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
12537         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
12538         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12539         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
12540         return (uintptr_t)ret_conv;
12541 }
12542
12543 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
12544         LDKCVec_NetAddressZ _res_constr;
12545         _res_constr.datalen = _res->arr_len;
12546         if (_res_constr.datalen > 0)
12547                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12548         else
12549                 _res_constr.data = NULL;
12550         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12551         for (size_t m = 0; m < _res_constr.datalen; m++) {
12552                 uint32_t _res_conv_12 = _res_vals[m];
12553                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
12554                 CHECK_ACCESS(_res_conv_12_ptr);
12555                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
12556                 FREE((void*)_res_conv_12);
12557                 _res_constr.data[m] = _res_conv_12_conv;
12558         }
12559         CVec_NetAddressZ_free(_res_constr);
12560 }
12561
12562 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
12563         LDKNodeAnnouncementInfo o_conv;
12564         o_conv.inner = (void*)(o & (~1));
12565         o_conv.is_owned = (o & 1) || (o == 0);
12566         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12567         o_conv = NodeAnnouncementInfo_clone(&o_conv);
12568         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12569         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
12570         return (uintptr_t)ret_conv;
12571 }
12572
12573 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
12574         LDKDecodeError e_conv;
12575         e_conv.inner = (void*)(e & (~1));
12576         e_conv.is_owned = (e & 1) || (e == 0);
12577         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12578         e_conv = DecodeError_clone(&e_conv);
12579         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12580         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
12581         return (uintptr_t)ret_conv;
12582 }
12583
12584 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
12585         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
12586         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
12587         return ret_val;
12588 }
12589
12590 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
12591         if ((_res & 1) != 0) return;
12592         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12593         CHECK_ACCESS(_res_ptr);
12594         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
12595         FREE((void*)_res);
12596         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
12597 }
12598
12599 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
12600         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12601         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
12602         return (uintptr_t)ret_conv;
12603 }
12604 intptr_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
12605         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
12606         intptr_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
12607         return ret_val;
12608 }
12609
12610 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
12611         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
12612         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12613         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
12614         return (uintptr_t)ret_conv;
12615 }
12616
12617 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
12618         LDKCVec_u64Z _res_constr;
12619         _res_constr.datalen = _res->arr_len;
12620         if (_res_constr.datalen > 0)
12621                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
12622         else
12623                 _res_constr.data = NULL;
12624         int64_t* _res_vals = _res->elems /* XXX _res leaks */;
12625         for (size_t i = 0; i < _res_constr.datalen; i++) {
12626                 int64_t _res_conv_8 = _res_vals[i];
12627                 _res_constr.data[i] = _res_conv_8;
12628         }
12629         CVec_u64Z_free(_res_constr);
12630 }
12631
12632 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
12633         LDKNodeInfo o_conv;
12634         o_conv.inner = (void*)(o & (~1));
12635         o_conv.is_owned = (o & 1) || (o == 0);
12636         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12637         o_conv = NodeInfo_clone(&o_conv);
12638         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12639         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
12640         return (uintptr_t)ret_conv;
12641 }
12642
12643 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
12644         LDKDecodeError e_conv;
12645         e_conv.inner = (void*)(e & (~1));
12646         e_conv.is_owned = (e & 1) || (e == 0);
12647         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12648         e_conv = DecodeError_clone(&e_conv);
12649         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12650         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
12651         return (uintptr_t)ret_conv;
12652 }
12653
12654 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
12655         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
12656         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
12657         return ret_val;
12658 }
12659
12660 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
12661         if ((_res & 1) != 0) return;
12662         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12663         CHECK_ACCESS(_res_ptr);
12664         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
12665         FREE((void*)_res);
12666         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
12667 }
12668
12669 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
12670         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12671         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
12672         return (uintptr_t)ret_conv;
12673 }
12674 intptr_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
12675         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
12676         intptr_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
12677         return ret_val;
12678 }
12679
12680 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
12681         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
12682         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12683         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
12684         return (uintptr_t)ret_conv;
12685 }
12686
12687 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
12688         LDKNetworkGraph o_conv;
12689         o_conv.inner = (void*)(o & (~1));
12690         o_conv.is_owned = (o & 1) || (o == 0);
12691         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12692         o_conv = NetworkGraph_clone(&o_conv);
12693         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12694         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
12695         return (uintptr_t)ret_conv;
12696 }
12697
12698 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
12699         LDKDecodeError e_conv;
12700         e_conv.inner = (void*)(e & (~1));
12701         e_conv.is_owned = (e & 1) || (e == 0);
12702         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12703         e_conv = DecodeError_clone(&e_conv);
12704         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12705         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
12706         return (uintptr_t)ret_conv;
12707 }
12708
12709 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
12710         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
12711         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
12712         return ret_val;
12713 }
12714
12715 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
12716         if ((_res & 1) != 0) return;
12717         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12718         CHECK_ACCESS(_res_ptr);
12719         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
12720         FREE((void*)_res);
12721         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
12722 }
12723
12724 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
12725         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12726         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
12727         return (uintptr_t)ret_conv;
12728 }
12729 intptr_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr"))) TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr(uint32_t arg) {
12730         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
12731         intptr_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
12732         return ret_val;
12733 }
12734
12735 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
12736         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
12737         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12738         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
12739         return (uintptr_t)ret_conv;
12740 }
12741
12742 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
12743         LDKCVec_NetAddressZ o_constr;
12744         o_constr.datalen = o->arr_len;
12745         if (o_constr.datalen > 0)
12746                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12747         else
12748                 o_constr.data = NULL;
12749         uint32_t* o_vals = o->elems /* XXX o leaks */;
12750         for (size_t m = 0; m < o_constr.datalen; m++) {
12751                 uint32_t o_conv_12 = o_vals[m];
12752                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
12753                 CHECK_ACCESS(o_conv_12_ptr);
12754                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
12755                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
12756                 o_constr.data[m] = o_conv_12_conv;
12757         }
12758         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12759         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
12760         uintptr_t ret_ref = (uintptr_t)ret_copy;
12761         return ret_ref;
12762 }
12763
12764 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
12765         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12766         *ret_copy = COption_CVec_NetAddressZZ_none();
12767         uintptr_t ret_ref = (uintptr_t)ret_copy;
12768         return ret_ref;
12769 }
12770
12771 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
12772         if ((_res & 1) != 0) return;
12773         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12774         CHECK_ACCESS(_res_ptr);
12775         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
12776         FREE((void*)_res);
12777         COption_CVec_NetAddressZZ_free(_res_conv);
12778 }
12779
12780 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
12781         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12782         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
12783 uintptr_t ret_ref = (uintptr_t)ret_copy;
12784         return ret_ref;
12785 }
12786 intptr_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
12787         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
12788         intptr_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
12789         return ret_val;
12790 }
12791
12792 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
12793         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
12794         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12795         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
12796         uintptr_t ret_ref = (uintptr_t)ret_copy;
12797         return ret_ref;
12798 }
12799
12800 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
12801         LDKScoringParameters o_conv;
12802         o_conv.inner = (void*)(o & (~1));
12803         o_conv.is_owned = (o & 1) || (o == 0);
12804         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12805         // Warning: we need a move here but no clone is available for LDKScoringParameters
12806         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12807         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
12808         return (uintptr_t)ret_conv;
12809 }
12810
12811 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_err"))) TS_CResult_ScoringParametersDecodeErrorZ_err(uint32_t e) {
12812         LDKDecodeError e_conv;
12813         e_conv.inner = (void*)(e & (~1));
12814         e_conv.is_owned = (e & 1) || (e == 0);
12815         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12816         e_conv = DecodeError_clone(&e_conv);
12817         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12818         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
12819         return (uintptr_t)ret_conv;
12820 }
12821
12822 jboolean  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_is_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
12823         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
12824         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
12825         return ret_val;
12826 }
12827
12828 void  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_free"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
12829         if ((_res & 1) != 0) return;
12830         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12831         CHECK_ACCESS(_res_ptr);
12832         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
12833         FREE((void*)_res);
12834         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
12835 }
12836
12837 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
12838         LDKInitFeatures o_conv;
12839         o_conv.inner = (void*)(o & (~1));
12840         o_conv.is_owned = (o & 1) || (o == 0);
12841         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12842         o_conv = InitFeatures_clone(&o_conv);
12843         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12844         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
12845         return (uintptr_t)ret_conv;
12846 }
12847
12848 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
12849         LDKDecodeError e_conv;
12850         e_conv.inner = (void*)(e & (~1));
12851         e_conv.is_owned = (e & 1) || (e == 0);
12852         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12853         e_conv = DecodeError_clone(&e_conv);
12854         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12855         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
12856         return (uintptr_t)ret_conv;
12857 }
12858
12859 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12860         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
12861         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
12862         return ret_val;
12863 }
12864
12865 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
12866         if ((_res & 1) != 0) return;
12867         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12868         CHECK_ACCESS(_res_ptr);
12869         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
12870         FREE((void*)_res);
12871         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
12872 }
12873
12874 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
12875         LDKChannelFeatures o_conv;
12876         o_conv.inner = (void*)(o & (~1));
12877         o_conv.is_owned = (o & 1) || (o == 0);
12878         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12879         o_conv = ChannelFeatures_clone(&o_conv);
12880         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12881         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
12882         return (uintptr_t)ret_conv;
12883 }
12884
12885 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
12886         LDKDecodeError e_conv;
12887         e_conv.inner = (void*)(e & (~1));
12888         e_conv.is_owned = (e & 1) || (e == 0);
12889         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12890         e_conv = DecodeError_clone(&e_conv);
12891         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12892         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
12893         return (uintptr_t)ret_conv;
12894 }
12895
12896 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12897         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
12898         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
12899         return ret_val;
12900 }
12901
12902 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
12903         if ((_res & 1) != 0) return;
12904         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12905         CHECK_ACCESS(_res_ptr);
12906         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
12907         FREE((void*)_res);
12908         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
12909 }
12910
12911 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
12912         LDKNodeFeatures o_conv;
12913         o_conv.inner = (void*)(o & (~1));
12914         o_conv.is_owned = (o & 1) || (o == 0);
12915         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12916         o_conv = NodeFeatures_clone(&o_conv);
12917         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12918         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
12919         return (uintptr_t)ret_conv;
12920 }
12921
12922 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
12923         LDKDecodeError e_conv;
12924         e_conv.inner = (void*)(e & (~1));
12925         e_conv.is_owned = (e & 1) || (e == 0);
12926         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12927         e_conv = DecodeError_clone(&e_conv);
12928         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12929         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
12930         return (uintptr_t)ret_conv;
12931 }
12932
12933 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12934         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
12935         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
12936         return ret_val;
12937 }
12938
12939 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
12940         if ((_res & 1) != 0) return;
12941         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12942         CHECK_ACCESS(_res_ptr);
12943         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
12944         FREE((void*)_res);
12945         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
12946 }
12947
12948 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
12949         LDKInvoiceFeatures o_conv;
12950         o_conv.inner = (void*)(o & (~1));
12951         o_conv.is_owned = (o & 1) || (o == 0);
12952         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12953         o_conv = InvoiceFeatures_clone(&o_conv);
12954         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12955         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
12956         return (uintptr_t)ret_conv;
12957 }
12958
12959 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
12960         LDKDecodeError e_conv;
12961         e_conv.inner = (void*)(e & (~1));
12962         e_conv.is_owned = (e & 1) || (e == 0);
12963         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12964         e_conv = DecodeError_clone(&e_conv);
12965         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12966         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
12967         return (uintptr_t)ret_conv;
12968 }
12969
12970 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12971         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
12972         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
12973         return ret_val;
12974 }
12975
12976 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
12977         if ((_res & 1) != 0) return;
12978         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12979         CHECK_ACCESS(_res_ptr);
12980         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
12981         FREE((void*)_res);
12982         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
12983 }
12984
12985 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
12986         LDKChannelTypeFeatures o_conv;
12987         o_conv.inner = (void*)(o & (~1));
12988         o_conv.is_owned = (o & 1) || (o == 0);
12989         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12990         o_conv = ChannelTypeFeatures_clone(&o_conv);
12991         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
12992         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
12993         return (uintptr_t)ret_conv;
12994 }
12995
12996 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
12997         LDKDecodeError e_conv;
12998         e_conv.inner = (void*)(e & (~1));
12999         e_conv.is_owned = (e & 1) || (e == 0);
13000         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13001         e_conv = DecodeError_clone(&e_conv);
13002         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13003         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
13004         return (uintptr_t)ret_conv;
13005 }
13006
13007 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13008         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
13009         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
13010         return ret_val;
13011 }
13012
13013 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
13014         if ((_res & 1) != 0) return;
13015         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13016         CHECK_ACCESS(_res_ptr);
13017         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
13018         FREE((void*)_res);
13019         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
13020 }
13021
13022 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
13023         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13024         CHECK_ACCESS(o_ptr);
13025         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
13026         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
13027         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13028         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
13029         return (uintptr_t)ret_conv;
13030 }
13031
13032 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
13033         LDKDecodeError e_conv;
13034         e_conv.inner = (void*)(e & (~1));
13035         e_conv.is_owned = (e & 1) || (e == 0);
13036         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13037         e_conv = DecodeError_clone(&e_conv);
13038         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13039         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
13040         return (uintptr_t)ret_conv;
13041 }
13042
13043 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
13044         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
13045         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
13046         return ret_val;
13047 }
13048
13049 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
13050         if ((_res & 1) != 0) return;
13051         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13052         CHECK_ACCESS(_res_ptr);
13053         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
13054         FREE((void*)_res);
13055         CResult_NetAddressDecodeErrorZ_free(_res_conv);
13056 }
13057
13058 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
13059         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13060         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
13061         return (uintptr_t)ret_conv;
13062 }
13063 intptr_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
13064         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
13065         intptr_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
13066         return ret_val;
13067 }
13068
13069 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
13070         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
13071         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13072         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
13073         return (uintptr_t)ret_conv;
13074 }
13075
13076 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
13077         LDKCVec_UpdateAddHTLCZ _res_constr;
13078         _res_constr.datalen = _res->arr_len;
13079         if (_res_constr.datalen > 0)
13080                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
13081         else
13082                 _res_constr.data = NULL;
13083         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13084         for (size_t p = 0; p < _res_constr.datalen; p++) {
13085                 uint32_t _res_conv_15 = _res_vals[p];
13086                 LDKUpdateAddHTLC _res_conv_15_conv;
13087                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
13088                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
13089                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
13090                 _res_constr.data[p] = _res_conv_15_conv;
13091         }
13092         CVec_UpdateAddHTLCZ_free(_res_constr);
13093 }
13094
13095 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
13096         LDKCVec_UpdateFulfillHTLCZ _res_constr;
13097         _res_constr.datalen = _res->arr_len;
13098         if (_res_constr.datalen > 0)
13099                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
13100         else
13101                 _res_constr.data = NULL;
13102         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13103         for (size_t t = 0; t < _res_constr.datalen; t++) {
13104                 uint32_t _res_conv_19 = _res_vals[t];
13105                 LDKUpdateFulfillHTLC _res_conv_19_conv;
13106                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
13107                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
13108                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
13109                 _res_constr.data[t] = _res_conv_19_conv;
13110         }
13111         CVec_UpdateFulfillHTLCZ_free(_res_constr);
13112 }
13113
13114 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
13115         LDKCVec_UpdateFailHTLCZ _res_constr;
13116         _res_constr.datalen = _res->arr_len;
13117         if (_res_constr.datalen > 0)
13118                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
13119         else
13120                 _res_constr.data = NULL;
13121         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13122         for (size_t q = 0; q < _res_constr.datalen; q++) {
13123                 uint32_t _res_conv_16 = _res_vals[q];
13124                 LDKUpdateFailHTLC _res_conv_16_conv;
13125                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
13126                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
13127                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
13128                 _res_constr.data[q] = _res_conv_16_conv;
13129         }
13130         CVec_UpdateFailHTLCZ_free(_res_constr);
13131 }
13132
13133 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
13134         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
13135         _res_constr.datalen = _res->arr_len;
13136         if (_res_constr.datalen > 0)
13137                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
13138         else
13139                 _res_constr.data = NULL;
13140         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13141         for (size_t z = 0; z < _res_constr.datalen; z++) {
13142                 uint32_t _res_conv_25 = _res_vals[z];
13143                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
13144                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
13145                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
13146                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
13147                 _res_constr.data[z] = _res_conv_25_conv;
13148         }
13149         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
13150 }
13151
13152 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
13153         LDKAcceptChannel o_conv;
13154         o_conv.inner = (void*)(o & (~1));
13155         o_conv.is_owned = (o & 1) || (o == 0);
13156         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13157         o_conv = AcceptChannel_clone(&o_conv);
13158         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13159         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
13160         return (uintptr_t)ret_conv;
13161 }
13162
13163 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
13164         LDKDecodeError e_conv;
13165         e_conv.inner = (void*)(e & (~1));
13166         e_conv.is_owned = (e & 1) || (e == 0);
13167         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13168         e_conv = DecodeError_clone(&e_conv);
13169         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13170         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
13171         return (uintptr_t)ret_conv;
13172 }
13173
13174 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
13175         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
13176         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
13177         return ret_val;
13178 }
13179
13180 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
13181         if ((_res & 1) != 0) return;
13182         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13183         CHECK_ACCESS(_res_ptr);
13184         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
13185         FREE((void*)_res);
13186         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
13187 }
13188
13189 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
13190         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13191         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
13192         return (uintptr_t)ret_conv;
13193 }
13194 intptr_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
13195         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
13196         intptr_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
13197         return ret_val;
13198 }
13199
13200 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
13201         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
13202         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13203         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
13204         return (uintptr_t)ret_conv;
13205 }
13206
13207 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
13208         LDKAnnouncementSignatures o_conv;
13209         o_conv.inner = (void*)(o & (~1));
13210         o_conv.is_owned = (o & 1) || (o == 0);
13211         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13212         o_conv = AnnouncementSignatures_clone(&o_conv);
13213         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13214         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
13215         return (uintptr_t)ret_conv;
13216 }
13217
13218 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
13219         LDKDecodeError e_conv;
13220         e_conv.inner = (void*)(e & (~1));
13221         e_conv.is_owned = (e & 1) || (e == 0);
13222         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13223         e_conv = DecodeError_clone(&e_conv);
13224         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13225         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
13226         return (uintptr_t)ret_conv;
13227 }
13228
13229 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
13230         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
13231         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
13232         return ret_val;
13233 }
13234
13235 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
13236         if ((_res & 1) != 0) return;
13237         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13238         CHECK_ACCESS(_res_ptr);
13239         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
13240         FREE((void*)_res);
13241         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
13242 }
13243
13244 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
13245         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13246         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
13247         return (uintptr_t)ret_conv;
13248 }
13249 intptr_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13250         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
13251         intptr_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
13252         return ret_val;
13253 }
13254
13255 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
13256         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
13257         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13258         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
13259         return (uintptr_t)ret_conv;
13260 }
13261
13262 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
13263         LDKChannelReestablish o_conv;
13264         o_conv.inner = (void*)(o & (~1));
13265         o_conv.is_owned = (o & 1) || (o == 0);
13266         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13267         o_conv = ChannelReestablish_clone(&o_conv);
13268         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13269         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
13270         return (uintptr_t)ret_conv;
13271 }
13272
13273 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
13274         LDKDecodeError e_conv;
13275         e_conv.inner = (void*)(e & (~1));
13276         e_conv.is_owned = (e & 1) || (e == 0);
13277         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13278         e_conv = DecodeError_clone(&e_conv);
13279         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13280         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
13281         return (uintptr_t)ret_conv;
13282 }
13283
13284 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
13285         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
13286         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
13287         return ret_val;
13288 }
13289
13290 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
13291         if ((_res & 1) != 0) return;
13292         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13293         CHECK_ACCESS(_res_ptr);
13294         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
13295         FREE((void*)_res);
13296         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
13297 }
13298
13299 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
13300         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13301         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
13302         return (uintptr_t)ret_conv;
13303 }
13304 intptr_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
13305         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
13306         intptr_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
13307         return ret_val;
13308 }
13309
13310 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
13311         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
13312         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13313         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
13314         return (uintptr_t)ret_conv;
13315 }
13316
13317 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
13318         LDKClosingSigned o_conv;
13319         o_conv.inner = (void*)(o & (~1));
13320         o_conv.is_owned = (o & 1) || (o == 0);
13321         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13322         o_conv = ClosingSigned_clone(&o_conv);
13323         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13324         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
13325         return (uintptr_t)ret_conv;
13326 }
13327
13328 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
13329         LDKDecodeError e_conv;
13330         e_conv.inner = (void*)(e & (~1));
13331         e_conv.is_owned = (e & 1) || (e == 0);
13332         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13333         e_conv = DecodeError_clone(&e_conv);
13334         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13335         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
13336         return (uintptr_t)ret_conv;
13337 }
13338
13339 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
13340         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
13341         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
13342         return ret_val;
13343 }
13344
13345 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
13346         if ((_res & 1) != 0) return;
13347         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13348         CHECK_ACCESS(_res_ptr);
13349         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
13350         FREE((void*)_res);
13351         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
13352 }
13353
13354 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
13355         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13356         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
13357         return (uintptr_t)ret_conv;
13358 }
13359 intptr_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
13360         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
13361         intptr_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
13362         return ret_val;
13363 }
13364
13365 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
13366         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
13367         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13368         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
13369         return (uintptr_t)ret_conv;
13370 }
13371
13372 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
13373         LDKClosingSignedFeeRange o_conv;
13374         o_conv.inner = (void*)(o & (~1));
13375         o_conv.is_owned = (o & 1) || (o == 0);
13376         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13377         o_conv = ClosingSignedFeeRange_clone(&o_conv);
13378         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13379         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
13380         return (uintptr_t)ret_conv;
13381 }
13382
13383 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
13384         LDKDecodeError e_conv;
13385         e_conv.inner = (void*)(e & (~1));
13386         e_conv.is_owned = (e & 1) || (e == 0);
13387         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13388         e_conv = DecodeError_clone(&e_conv);
13389         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13390         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
13391         return (uintptr_t)ret_conv;
13392 }
13393
13394 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
13395         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
13396         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
13397         return ret_val;
13398 }
13399
13400 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
13401         if ((_res & 1) != 0) return;
13402         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13403         CHECK_ACCESS(_res_ptr);
13404         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
13405         FREE((void*)_res);
13406         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
13407 }
13408
13409 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
13410         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13411         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
13412         return (uintptr_t)ret_conv;
13413 }
13414 intptr_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
13415         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
13416         intptr_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
13417         return ret_val;
13418 }
13419
13420 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
13421         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
13422         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13423         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
13424         return (uintptr_t)ret_conv;
13425 }
13426
13427 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
13428         LDKCommitmentSigned o_conv;
13429         o_conv.inner = (void*)(o & (~1));
13430         o_conv.is_owned = (o & 1) || (o == 0);
13431         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13432         o_conv = CommitmentSigned_clone(&o_conv);
13433         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13434         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
13435         return (uintptr_t)ret_conv;
13436 }
13437
13438 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
13439         LDKDecodeError e_conv;
13440         e_conv.inner = (void*)(e & (~1));
13441         e_conv.is_owned = (e & 1) || (e == 0);
13442         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13443         e_conv = DecodeError_clone(&e_conv);
13444         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13445         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
13446         return (uintptr_t)ret_conv;
13447 }
13448
13449 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
13450         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
13451         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
13452         return ret_val;
13453 }
13454
13455 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
13456         if ((_res & 1) != 0) return;
13457         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13458         CHECK_ACCESS(_res_ptr);
13459         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
13460         FREE((void*)_res);
13461         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
13462 }
13463
13464 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
13465         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13466         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
13467         return (uintptr_t)ret_conv;
13468 }
13469 intptr_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
13470         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
13471         intptr_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
13472         return ret_val;
13473 }
13474
13475 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
13476         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
13477         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13478         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
13479         return (uintptr_t)ret_conv;
13480 }
13481
13482 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
13483         LDKFundingCreated o_conv;
13484         o_conv.inner = (void*)(o & (~1));
13485         o_conv.is_owned = (o & 1) || (o == 0);
13486         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13487         o_conv = FundingCreated_clone(&o_conv);
13488         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13489         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
13490         return (uintptr_t)ret_conv;
13491 }
13492
13493 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
13494         LDKDecodeError e_conv;
13495         e_conv.inner = (void*)(e & (~1));
13496         e_conv.is_owned = (e & 1) || (e == 0);
13497         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13498         e_conv = DecodeError_clone(&e_conv);
13499         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13500         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
13501         return (uintptr_t)ret_conv;
13502 }
13503
13504 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
13505         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
13506         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
13507         return ret_val;
13508 }
13509
13510 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
13511         if ((_res & 1) != 0) return;
13512         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13513         CHECK_ACCESS(_res_ptr);
13514         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
13515         FREE((void*)_res);
13516         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
13517 }
13518
13519 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
13520         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13521         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
13522         return (uintptr_t)ret_conv;
13523 }
13524 intptr_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
13525         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
13526         intptr_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
13527         return ret_val;
13528 }
13529
13530 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
13531         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
13532         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13533         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
13534         return (uintptr_t)ret_conv;
13535 }
13536
13537 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
13538         LDKFundingSigned o_conv;
13539         o_conv.inner = (void*)(o & (~1));
13540         o_conv.is_owned = (o & 1) || (o == 0);
13541         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13542         o_conv = FundingSigned_clone(&o_conv);
13543         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13544         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
13545         return (uintptr_t)ret_conv;
13546 }
13547
13548 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
13549         LDKDecodeError e_conv;
13550         e_conv.inner = (void*)(e & (~1));
13551         e_conv.is_owned = (e & 1) || (e == 0);
13552         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13553         e_conv = DecodeError_clone(&e_conv);
13554         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13555         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
13556         return (uintptr_t)ret_conv;
13557 }
13558
13559 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
13560         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
13561         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
13562         return ret_val;
13563 }
13564
13565 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
13566         if ((_res & 1) != 0) return;
13567         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13568         CHECK_ACCESS(_res_ptr);
13569         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
13570         FREE((void*)_res);
13571         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
13572 }
13573
13574 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
13575         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13576         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
13577         return (uintptr_t)ret_conv;
13578 }
13579 intptr_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
13580         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
13581         intptr_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
13582         return ret_val;
13583 }
13584
13585 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
13586         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
13587         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13588         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
13589         return (uintptr_t)ret_conv;
13590 }
13591
13592 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_ok"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
13593         LDKFundingLocked o_conv;
13594         o_conv.inner = (void*)(o & (~1));
13595         o_conv.is_owned = (o & 1) || (o == 0);
13596         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13597         o_conv = FundingLocked_clone(&o_conv);
13598         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13599         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
13600         return (uintptr_t)ret_conv;
13601 }
13602
13603 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_err"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
13604         LDKDecodeError e_conv;
13605         e_conv.inner = (void*)(e & (~1));
13606         e_conv.is_owned = (e & 1) || (e == 0);
13607         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13608         e_conv = DecodeError_clone(&e_conv);
13609         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13610         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
13611         return (uintptr_t)ret_conv;
13612 }
13613
13614 jboolean  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_is_ok"))) TS_CResult_FundingLockedDecodeErrorZ_is_ok(uint32_t o) {
13615         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
13616         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
13617         return ret_val;
13618 }
13619
13620 void  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_free"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
13621         if ((_res & 1) != 0) return;
13622         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13623         CHECK_ACCESS(_res_ptr);
13624         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
13625         FREE((void*)_res);
13626         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
13627 }
13628
13629 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
13630         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13631         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
13632         return (uintptr_t)ret_conv;
13633 }
13634 intptr_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingLockedDecodeErrorZ_clone_ptr(uint32_t arg) {
13635         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
13636         intptr_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
13637         return ret_val;
13638 }
13639
13640 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
13641         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
13642         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13643         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
13644         return (uintptr_t)ret_conv;
13645 }
13646
13647 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
13648         LDKInit o_conv;
13649         o_conv.inner = (void*)(o & (~1));
13650         o_conv.is_owned = (o & 1) || (o == 0);
13651         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13652         o_conv = Init_clone(&o_conv);
13653         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
13654         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
13655         return (uintptr_t)ret_conv;
13656 }
13657
13658 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
13659         LDKDecodeError e_conv;
13660         e_conv.inner = (void*)(e & (~1));
13661         e_conv.is_owned = (e & 1) || (e == 0);
13662         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13663         e_conv = DecodeError_clone(&e_conv);
13664         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
13665         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
13666         return (uintptr_t)ret_conv;
13667 }
13668
13669 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
13670         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
13671         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
13672         return ret_val;
13673 }
13674
13675 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_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_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
13680         FREE((void*)_res);
13681         CResult_InitDecodeErrorZ_free(_res_conv);
13682 }
13683
13684 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
13685         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
13686         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
13687         return (uintptr_t)ret_conv;
13688 }
13689 intptr_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
13690         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
13691         intptr_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
13692         return ret_val;
13693 }
13694
13695 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
13696         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
13697         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
13698         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
13699         return (uintptr_t)ret_conv;
13700 }
13701
13702 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
13703         LDKOpenChannel 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 = OpenChannel_clone(&o_conv);
13708         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
13709         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
13710         return (uintptr_t)ret_conv;
13711 }
13712
13713 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_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_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
13720         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
13721         return (uintptr_t)ret_conv;
13722 }
13723
13724 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
13725         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
13726         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
13727         return ret_val;
13728 }
13729
13730 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_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_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
13735         FREE((void*)_res);
13736         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
13737 }
13738
13739 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
13740         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
13741         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
13742         return (uintptr_t)ret_conv;
13743 }
13744 intptr_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
13745         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
13746         intptr_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
13747         return ret_val;
13748 }
13749
13750 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
13751         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
13752         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
13753         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
13754         return (uintptr_t)ret_conv;
13755 }
13756
13757 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
13758         LDKRevokeAndACK o_conv;
13759         o_conv.inner = (void*)(o & (~1));
13760         o_conv.is_owned = (o & 1) || (o == 0);
13761         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13762         o_conv = RevokeAndACK_clone(&o_conv);
13763         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
13764         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
13765         return (uintptr_t)ret_conv;
13766 }
13767
13768 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
13769         LDKDecodeError e_conv;
13770         e_conv.inner = (void*)(e & (~1));
13771         e_conv.is_owned = (e & 1) || (e == 0);
13772         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13773         e_conv = DecodeError_clone(&e_conv);
13774         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
13775         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
13776         return (uintptr_t)ret_conv;
13777 }
13778
13779 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
13780         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
13781         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
13782         return ret_val;
13783 }
13784
13785 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
13786         if ((_res & 1) != 0) return;
13787         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13788         CHECK_ACCESS(_res_ptr);
13789         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
13790         FREE((void*)_res);
13791         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
13792 }
13793
13794 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
13795         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
13796         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
13797         return (uintptr_t)ret_conv;
13798 }
13799 intptr_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
13800         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
13801         intptr_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
13802         return ret_val;
13803 }
13804
13805 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
13806         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
13807         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
13808         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
13809         return (uintptr_t)ret_conv;
13810 }
13811
13812 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
13813         LDKShutdown o_conv;
13814         o_conv.inner = (void*)(o & (~1));
13815         o_conv.is_owned = (o & 1) || (o == 0);
13816         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13817         o_conv = Shutdown_clone(&o_conv);
13818         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13819         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
13820         return (uintptr_t)ret_conv;
13821 }
13822
13823 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
13824         LDKDecodeError e_conv;
13825         e_conv.inner = (void*)(e & (~1));
13826         e_conv.is_owned = (e & 1) || (e == 0);
13827         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13828         e_conv = DecodeError_clone(&e_conv);
13829         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13830         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
13831         return (uintptr_t)ret_conv;
13832 }
13833
13834 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
13835         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
13836         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
13837         return ret_val;
13838 }
13839
13840 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
13841         if ((_res & 1) != 0) return;
13842         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13843         CHECK_ACCESS(_res_ptr);
13844         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
13845         FREE((void*)_res);
13846         CResult_ShutdownDecodeErrorZ_free(_res_conv);
13847 }
13848
13849 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
13850         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13851         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
13852         return (uintptr_t)ret_conv;
13853 }
13854 intptr_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
13855         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
13856         intptr_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
13857         return ret_val;
13858 }
13859
13860 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
13861         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
13862         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13863         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
13864         return (uintptr_t)ret_conv;
13865 }
13866
13867 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
13868         LDKUpdateFailHTLC o_conv;
13869         o_conv.inner = (void*)(o & (~1));
13870         o_conv.is_owned = (o & 1) || (o == 0);
13871         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13872         o_conv = UpdateFailHTLC_clone(&o_conv);
13873         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13874         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
13875         return (uintptr_t)ret_conv;
13876 }
13877
13878 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
13879         LDKDecodeError e_conv;
13880         e_conv.inner = (void*)(e & (~1));
13881         e_conv.is_owned = (e & 1) || (e == 0);
13882         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13883         e_conv = DecodeError_clone(&e_conv);
13884         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13885         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
13886         return (uintptr_t)ret_conv;
13887 }
13888
13889 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
13890         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
13891         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
13892         return ret_val;
13893 }
13894
13895 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
13896         if ((_res & 1) != 0) return;
13897         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13898         CHECK_ACCESS(_res_ptr);
13899         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
13900         FREE((void*)_res);
13901         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
13902 }
13903
13904 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
13905         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13906         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
13907         return (uintptr_t)ret_conv;
13908 }
13909 intptr_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
13910         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
13911         intptr_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
13912         return ret_val;
13913 }
13914
13915 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
13916         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
13917         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13918         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
13919         return (uintptr_t)ret_conv;
13920 }
13921
13922 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
13923         LDKUpdateFailMalformedHTLC o_conv;
13924         o_conv.inner = (void*)(o & (~1));
13925         o_conv.is_owned = (o & 1) || (o == 0);
13926         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13927         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
13928         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13929         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
13930         return (uintptr_t)ret_conv;
13931 }
13932
13933 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
13934         LDKDecodeError e_conv;
13935         e_conv.inner = (void*)(e & (~1));
13936         e_conv.is_owned = (e & 1) || (e == 0);
13937         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13938         e_conv = DecodeError_clone(&e_conv);
13939         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13940         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
13941         return (uintptr_t)ret_conv;
13942 }
13943
13944 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
13945         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
13946         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
13947         return ret_val;
13948 }
13949
13950 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
13951         if ((_res & 1) != 0) return;
13952         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13953         CHECK_ACCESS(_res_ptr);
13954         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
13955         FREE((void*)_res);
13956         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
13957 }
13958
13959 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
13960         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13961         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
13962         return (uintptr_t)ret_conv;
13963 }
13964 intptr_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
13965         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
13966         intptr_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
13967         return ret_val;
13968 }
13969
13970 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
13971         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
13972         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13973         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
13974         return (uintptr_t)ret_conv;
13975 }
13976
13977 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
13978         LDKUpdateFee o_conv;
13979         o_conv.inner = (void*)(o & (~1));
13980         o_conv.is_owned = (o & 1) || (o == 0);
13981         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13982         o_conv = UpdateFee_clone(&o_conv);
13983         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
13984         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
13985         return (uintptr_t)ret_conv;
13986 }
13987
13988 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
13989         LDKDecodeError e_conv;
13990         e_conv.inner = (void*)(e & (~1));
13991         e_conv.is_owned = (e & 1) || (e == 0);
13992         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13993         e_conv = DecodeError_clone(&e_conv);
13994         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
13995         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
13996         return (uintptr_t)ret_conv;
13997 }
13998
13999 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
14000         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
14001         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
14002         return ret_val;
14003 }
14004
14005 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
14006         if ((_res & 1) != 0) return;
14007         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14008         CHECK_ACCESS(_res_ptr);
14009         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
14010         FREE((void*)_res);
14011         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
14012 }
14013
14014 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
14015         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14016         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
14017         return (uintptr_t)ret_conv;
14018 }
14019 intptr_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
14020         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
14021         intptr_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
14022         return ret_val;
14023 }
14024
14025 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
14026         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
14027         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14028         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
14029         return (uintptr_t)ret_conv;
14030 }
14031
14032 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
14033         LDKUpdateFulfillHTLC o_conv;
14034         o_conv.inner = (void*)(o & (~1));
14035         o_conv.is_owned = (o & 1) || (o == 0);
14036         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14037         o_conv = UpdateFulfillHTLC_clone(&o_conv);
14038         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14039         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
14040         return (uintptr_t)ret_conv;
14041 }
14042
14043 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
14044         LDKDecodeError e_conv;
14045         e_conv.inner = (void*)(e & (~1));
14046         e_conv.is_owned = (e & 1) || (e == 0);
14047         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14048         e_conv = DecodeError_clone(&e_conv);
14049         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14050         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
14051         return (uintptr_t)ret_conv;
14052 }
14053
14054 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
14055         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
14056         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
14057         return ret_val;
14058 }
14059
14060 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
14061         if ((_res & 1) != 0) return;
14062         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14063         CHECK_ACCESS(_res_ptr);
14064         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
14065         FREE((void*)_res);
14066         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
14067 }
14068
14069 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
14070         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14071         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
14072         return (uintptr_t)ret_conv;
14073 }
14074 intptr_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
14075         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
14076         intptr_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
14077         return ret_val;
14078 }
14079
14080 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
14081         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
14082         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14083         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
14084         return (uintptr_t)ret_conv;
14085 }
14086
14087 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
14088         LDKUpdateAddHTLC o_conv;
14089         o_conv.inner = (void*)(o & (~1));
14090         o_conv.is_owned = (o & 1) || (o == 0);
14091         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14092         o_conv = UpdateAddHTLC_clone(&o_conv);
14093         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14094         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
14095         return (uintptr_t)ret_conv;
14096 }
14097
14098 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
14099         LDKDecodeError e_conv;
14100         e_conv.inner = (void*)(e & (~1));
14101         e_conv.is_owned = (e & 1) || (e == 0);
14102         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14103         e_conv = DecodeError_clone(&e_conv);
14104         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14105         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
14106         return (uintptr_t)ret_conv;
14107 }
14108
14109 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
14110         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
14111         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
14112         return ret_val;
14113 }
14114
14115 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
14116         if ((_res & 1) != 0) return;
14117         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14118         CHECK_ACCESS(_res_ptr);
14119         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
14120         FREE((void*)_res);
14121         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
14122 }
14123
14124 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
14125         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14126         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
14127         return (uintptr_t)ret_conv;
14128 }
14129 intptr_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
14130         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
14131         intptr_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
14132         return ret_val;
14133 }
14134
14135 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
14136         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
14137         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14138         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
14139         return (uintptr_t)ret_conv;
14140 }
14141
14142 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
14143         LDKPing o_conv;
14144         o_conv.inner = (void*)(o & (~1));
14145         o_conv.is_owned = (o & 1) || (o == 0);
14146         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14147         o_conv = Ping_clone(&o_conv);
14148         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14149         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
14150         return (uintptr_t)ret_conv;
14151 }
14152
14153 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
14154         LDKDecodeError e_conv;
14155         e_conv.inner = (void*)(e & (~1));
14156         e_conv.is_owned = (e & 1) || (e == 0);
14157         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14158         e_conv = DecodeError_clone(&e_conv);
14159         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14160         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
14161         return (uintptr_t)ret_conv;
14162 }
14163
14164 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
14165         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
14166         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
14167         return ret_val;
14168 }
14169
14170 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
14171         if ((_res & 1) != 0) return;
14172         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14173         CHECK_ACCESS(_res_ptr);
14174         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
14175         FREE((void*)_res);
14176         CResult_PingDecodeErrorZ_free(_res_conv);
14177 }
14178
14179 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
14180         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14181         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
14182         return (uintptr_t)ret_conv;
14183 }
14184 intptr_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
14185         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
14186         intptr_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
14187         return ret_val;
14188 }
14189
14190 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
14191         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
14192         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14193         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
14194         return (uintptr_t)ret_conv;
14195 }
14196
14197 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
14198         LDKPong o_conv;
14199         o_conv.inner = (void*)(o & (~1));
14200         o_conv.is_owned = (o & 1) || (o == 0);
14201         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14202         o_conv = Pong_clone(&o_conv);
14203         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14204         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
14205         return (uintptr_t)ret_conv;
14206 }
14207
14208 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
14209         LDKDecodeError e_conv;
14210         e_conv.inner = (void*)(e & (~1));
14211         e_conv.is_owned = (e & 1) || (e == 0);
14212         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14213         e_conv = DecodeError_clone(&e_conv);
14214         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14215         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
14216         return (uintptr_t)ret_conv;
14217 }
14218
14219 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
14220         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
14221         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
14222         return ret_val;
14223 }
14224
14225 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
14226         if ((_res & 1) != 0) return;
14227         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14228         CHECK_ACCESS(_res_ptr);
14229         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
14230         FREE((void*)_res);
14231         CResult_PongDecodeErrorZ_free(_res_conv);
14232 }
14233
14234 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
14235         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14236         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
14237         return (uintptr_t)ret_conv;
14238 }
14239 intptr_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
14240         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
14241         intptr_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
14242         return ret_val;
14243 }
14244
14245 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
14246         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
14247         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14248         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
14249         return (uintptr_t)ret_conv;
14250 }
14251
14252 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
14253         LDKUnsignedChannelAnnouncement o_conv;
14254         o_conv.inner = (void*)(o & (~1));
14255         o_conv.is_owned = (o & 1) || (o == 0);
14256         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14257         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
14258         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14259         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
14260         return (uintptr_t)ret_conv;
14261 }
14262
14263 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
14264         LDKDecodeError e_conv;
14265         e_conv.inner = (void*)(e & (~1));
14266         e_conv.is_owned = (e & 1) || (e == 0);
14267         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14268         e_conv = DecodeError_clone(&e_conv);
14269         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14270         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
14271         return (uintptr_t)ret_conv;
14272 }
14273
14274 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
14275         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
14276         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
14277         return ret_val;
14278 }
14279
14280 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
14281         if ((_res & 1) != 0) return;
14282         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14283         CHECK_ACCESS(_res_ptr);
14284         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
14285         FREE((void*)_res);
14286         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
14287 }
14288
14289 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
14290         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14291         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
14292         return (uintptr_t)ret_conv;
14293 }
14294 intptr_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
14295         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
14296         intptr_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
14297         return ret_val;
14298 }
14299
14300 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
14301         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
14302         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14303         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
14304         return (uintptr_t)ret_conv;
14305 }
14306
14307 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
14308         LDKChannelAnnouncement o_conv;
14309         o_conv.inner = (void*)(o & (~1));
14310         o_conv.is_owned = (o & 1) || (o == 0);
14311         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14312         o_conv = ChannelAnnouncement_clone(&o_conv);
14313         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14314         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
14315         return (uintptr_t)ret_conv;
14316 }
14317
14318 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
14319         LDKDecodeError e_conv;
14320         e_conv.inner = (void*)(e & (~1));
14321         e_conv.is_owned = (e & 1) || (e == 0);
14322         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14323         e_conv = DecodeError_clone(&e_conv);
14324         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14325         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
14326         return (uintptr_t)ret_conv;
14327 }
14328
14329 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
14330         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
14331         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
14332         return ret_val;
14333 }
14334
14335 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
14336         if ((_res & 1) != 0) return;
14337         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14338         CHECK_ACCESS(_res_ptr);
14339         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
14340         FREE((void*)_res);
14341         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
14342 }
14343
14344 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
14345         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14346         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
14347         return (uintptr_t)ret_conv;
14348 }
14349 intptr_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
14350         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
14351         intptr_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
14352         return ret_val;
14353 }
14354
14355 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
14356         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
14357         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14358         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
14359         return (uintptr_t)ret_conv;
14360 }
14361
14362 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
14363         LDKUnsignedChannelUpdate o_conv;
14364         o_conv.inner = (void*)(o & (~1));
14365         o_conv.is_owned = (o & 1) || (o == 0);
14366         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14367         o_conv = UnsignedChannelUpdate_clone(&o_conv);
14368         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14369         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
14370         return (uintptr_t)ret_conv;
14371 }
14372
14373 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
14374         LDKDecodeError e_conv;
14375         e_conv.inner = (void*)(e & (~1));
14376         e_conv.is_owned = (e & 1) || (e == 0);
14377         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14378         e_conv = DecodeError_clone(&e_conv);
14379         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14380         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
14381         return (uintptr_t)ret_conv;
14382 }
14383
14384 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
14385         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
14386         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
14387         return ret_val;
14388 }
14389
14390 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
14391         if ((_res & 1) != 0) return;
14392         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14393         CHECK_ACCESS(_res_ptr);
14394         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
14395         FREE((void*)_res);
14396         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
14397 }
14398
14399 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
14400         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14401         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
14402         return (uintptr_t)ret_conv;
14403 }
14404 intptr_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
14405         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
14406         intptr_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
14407         return ret_val;
14408 }
14409
14410 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
14411         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
14412         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14413         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
14414         return (uintptr_t)ret_conv;
14415 }
14416
14417 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
14418         LDKChannelUpdate o_conv;
14419         o_conv.inner = (void*)(o & (~1));
14420         o_conv.is_owned = (o & 1) || (o == 0);
14421         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14422         o_conv = ChannelUpdate_clone(&o_conv);
14423         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14424         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
14425         return (uintptr_t)ret_conv;
14426 }
14427
14428 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
14429         LDKDecodeError e_conv;
14430         e_conv.inner = (void*)(e & (~1));
14431         e_conv.is_owned = (e & 1) || (e == 0);
14432         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14433         e_conv = DecodeError_clone(&e_conv);
14434         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14435         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
14436         return (uintptr_t)ret_conv;
14437 }
14438
14439 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
14440         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
14441         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
14442         return ret_val;
14443 }
14444
14445 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
14446         if ((_res & 1) != 0) return;
14447         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14448         CHECK_ACCESS(_res_ptr);
14449         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
14450         FREE((void*)_res);
14451         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
14452 }
14453
14454 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
14455         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14456         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
14457         return (uintptr_t)ret_conv;
14458 }
14459 intptr_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
14460         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
14461         intptr_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
14462         return ret_val;
14463 }
14464
14465 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
14466         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
14467         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14468         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
14469         return (uintptr_t)ret_conv;
14470 }
14471
14472 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
14473         LDKErrorMessage o_conv;
14474         o_conv.inner = (void*)(o & (~1));
14475         o_conv.is_owned = (o & 1) || (o == 0);
14476         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14477         o_conv = ErrorMessage_clone(&o_conv);
14478         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14479         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
14480         return (uintptr_t)ret_conv;
14481 }
14482
14483 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
14484         LDKDecodeError e_conv;
14485         e_conv.inner = (void*)(e & (~1));
14486         e_conv.is_owned = (e & 1) || (e == 0);
14487         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14488         e_conv = DecodeError_clone(&e_conv);
14489         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14490         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
14491         return (uintptr_t)ret_conv;
14492 }
14493
14494 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
14495         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
14496         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
14497         return ret_val;
14498 }
14499
14500 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
14501         if ((_res & 1) != 0) return;
14502         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14503         CHECK_ACCESS(_res_ptr);
14504         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
14505         FREE((void*)_res);
14506         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
14507 }
14508
14509 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
14510         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14511         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
14512         return (uintptr_t)ret_conv;
14513 }
14514 intptr_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
14515         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
14516         intptr_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
14517         return ret_val;
14518 }
14519
14520 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
14521         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
14522         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14523         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
14524         return (uintptr_t)ret_conv;
14525 }
14526
14527 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
14528         LDKUnsignedNodeAnnouncement o_conv;
14529         o_conv.inner = (void*)(o & (~1));
14530         o_conv.is_owned = (o & 1) || (o == 0);
14531         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14532         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
14533         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14534         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
14535         return (uintptr_t)ret_conv;
14536 }
14537
14538 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
14539         LDKDecodeError e_conv;
14540         e_conv.inner = (void*)(e & (~1));
14541         e_conv.is_owned = (e & 1) || (e == 0);
14542         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14543         e_conv = DecodeError_clone(&e_conv);
14544         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14545         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
14546         return (uintptr_t)ret_conv;
14547 }
14548
14549 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
14550         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
14551         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
14552         return ret_val;
14553 }
14554
14555 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
14556         if ((_res & 1) != 0) return;
14557         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14558         CHECK_ACCESS(_res_ptr);
14559         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
14560         FREE((void*)_res);
14561         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
14562 }
14563
14564 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
14565         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14566         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
14567         return (uintptr_t)ret_conv;
14568 }
14569 intptr_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
14570         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
14571         intptr_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
14572         return ret_val;
14573 }
14574
14575 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
14576         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
14577         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14578         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
14579         return (uintptr_t)ret_conv;
14580 }
14581
14582 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
14583         LDKNodeAnnouncement o_conv;
14584         o_conv.inner = (void*)(o & (~1));
14585         o_conv.is_owned = (o & 1) || (o == 0);
14586         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14587         o_conv = NodeAnnouncement_clone(&o_conv);
14588         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14589         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
14590         return (uintptr_t)ret_conv;
14591 }
14592
14593 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
14594         LDKDecodeError e_conv;
14595         e_conv.inner = (void*)(e & (~1));
14596         e_conv.is_owned = (e & 1) || (e == 0);
14597         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14598         e_conv = DecodeError_clone(&e_conv);
14599         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14600         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
14601         return (uintptr_t)ret_conv;
14602 }
14603
14604 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
14605         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
14606         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
14607         return ret_val;
14608 }
14609
14610 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
14611         if ((_res & 1) != 0) return;
14612         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14613         CHECK_ACCESS(_res_ptr);
14614         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
14615         FREE((void*)_res);
14616         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
14617 }
14618
14619 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
14620         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14621         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
14622         return (uintptr_t)ret_conv;
14623 }
14624 intptr_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
14625         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
14626         intptr_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
14627         return ret_val;
14628 }
14629
14630 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
14631         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
14632         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14633         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
14634         return (uintptr_t)ret_conv;
14635 }
14636
14637 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
14638         LDKQueryShortChannelIds o_conv;
14639         o_conv.inner = (void*)(o & (~1));
14640         o_conv.is_owned = (o & 1) || (o == 0);
14641         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14642         o_conv = QueryShortChannelIds_clone(&o_conv);
14643         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14644         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
14645         return (uintptr_t)ret_conv;
14646 }
14647
14648 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
14649         LDKDecodeError e_conv;
14650         e_conv.inner = (void*)(e & (~1));
14651         e_conv.is_owned = (e & 1) || (e == 0);
14652         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14653         e_conv = DecodeError_clone(&e_conv);
14654         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14655         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
14656         return (uintptr_t)ret_conv;
14657 }
14658
14659 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
14660         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
14661         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
14662         return ret_val;
14663 }
14664
14665 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
14666         if ((_res & 1) != 0) return;
14667         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14668         CHECK_ACCESS(_res_ptr);
14669         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
14670         FREE((void*)_res);
14671         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
14672 }
14673
14674 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
14675         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14676         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
14677         return (uintptr_t)ret_conv;
14678 }
14679 intptr_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
14680         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
14681         intptr_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
14682         return ret_val;
14683 }
14684
14685 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
14686         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
14687         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14688         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
14689         return (uintptr_t)ret_conv;
14690 }
14691
14692 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
14693         LDKReplyShortChannelIdsEnd o_conv;
14694         o_conv.inner = (void*)(o & (~1));
14695         o_conv.is_owned = (o & 1) || (o == 0);
14696         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14697         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
14698         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14699         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
14700         return (uintptr_t)ret_conv;
14701 }
14702
14703 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
14704         LDKDecodeError e_conv;
14705         e_conv.inner = (void*)(e & (~1));
14706         e_conv.is_owned = (e & 1) || (e == 0);
14707         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14708         e_conv = DecodeError_clone(&e_conv);
14709         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14710         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
14711         return (uintptr_t)ret_conv;
14712 }
14713
14714 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
14715         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
14716         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
14717         return ret_val;
14718 }
14719
14720 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
14721         if ((_res & 1) != 0) return;
14722         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14723         CHECK_ACCESS(_res_ptr);
14724         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
14725         FREE((void*)_res);
14726         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
14727 }
14728
14729 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
14730         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14731         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
14732         return (uintptr_t)ret_conv;
14733 }
14734 intptr_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
14735         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
14736         intptr_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
14737         return ret_val;
14738 }
14739
14740 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
14741         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
14742         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14743         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
14744         return (uintptr_t)ret_conv;
14745 }
14746
14747 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
14748         LDKQueryChannelRange o_conv;
14749         o_conv.inner = (void*)(o & (~1));
14750         o_conv.is_owned = (o & 1) || (o == 0);
14751         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14752         o_conv = QueryChannelRange_clone(&o_conv);
14753         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14754         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
14755         return (uintptr_t)ret_conv;
14756 }
14757
14758 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
14759         LDKDecodeError e_conv;
14760         e_conv.inner = (void*)(e & (~1));
14761         e_conv.is_owned = (e & 1) || (e == 0);
14762         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14763         e_conv = DecodeError_clone(&e_conv);
14764         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14765         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
14766         return (uintptr_t)ret_conv;
14767 }
14768
14769 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
14770         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
14771         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
14772         return ret_val;
14773 }
14774
14775 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
14776         if ((_res & 1) != 0) return;
14777         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14778         CHECK_ACCESS(_res_ptr);
14779         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
14780         FREE((void*)_res);
14781         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
14782 }
14783
14784 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
14785         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14786         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
14787         return (uintptr_t)ret_conv;
14788 }
14789 intptr_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
14790         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
14791         intptr_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
14792         return ret_val;
14793 }
14794
14795 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
14796         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
14797         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14798         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
14799         return (uintptr_t)ret_conv;
14800 }
14801
14802 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
14803         LDKReplyChannelRange o_conv;
14804         o_conv.inner = (void*)(o & (~1));
14805         o_conv.is_owned = (o & 1) || (o == 0);
14806         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14807         o_conv = ReplyChannelRange_clone(&o_conv);
14808         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14809         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
14810         return (uintptr_t)ret_conv;
14811 }
14812
14813 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
14814         LDKDecodeError e_conv;
14815         e_conv.inner = (void*)(e & (~1));
14816         e_conv.is_owned = (e & 1) || (e == 0);
14817         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14818         e_conv = DecodeError_clone(&e_conv);
14819         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14820         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
14821         return (uintptr_t)ret_conv;
14822 }
14823
14824 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
14825         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
14826         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
14827         return ret_val;
14828 }
14829
14830 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
14831         if ((_res & 1) != 0) return;
14832         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14833         CHECK_ACCESS(_res_ptr);
14834         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
14835         FREE((void*)_res);
14836         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
14837 }
14838
14839 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
14840         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14841         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
14842         return (uintptr_t)ret_conv;
14843 }
14844 intptr_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
14845         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
14846         intptr_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
14847         return ret_val;
14848 }
14849
14850 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
14851         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
14852         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14853         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
14854         return (uintptr_t)ret_conv;
14855 }
14856
14857 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
14858         LDKGossipTimestampFilter o_conv;
14859         o_conv.inner = (void*)(o & (~1));
14860         o_conv.is_owned = (o & 1) || (o == 0);
14861         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14862         o_conv = GossipTimestampFilter_clone(&o_conv);
14863         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14864         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
14865         return (uintptr_t)ret_conv;
14866 }
14867
14868 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
14869         LDKDecodeError e_conv;
14870         e_conv.inner = (void*)(e & (~1));
14871         e_conv.is_owned = (e & 1) || (e == 0);
14872         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14873         e_conv = DecodeError_clone(&e_conv);
14874         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14875         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
14876         return (uintptr_t)ret_conv;
14877 }
14878
14879 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
14880         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
14881         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
14882         return ret_val;
14883 }
14884
14885 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
14886         if ((_res & 1) != 0) return;
14887         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14888         CHECK_ACCESS(_res_ptr);
14889         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
14890         FREE((void*)_res);
14891         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
14892 }
14893
14894 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
14895         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14896         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
14897         return (uintptr_t)ret_conv;
14898 }
14899 intptr_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
14900         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
14901         intptr_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
14902         return ret_val;
14903 }
14904
14905 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
14906         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
14907         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14908         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
14909         return (uintptr_t)ret_conv;
14910 }
14911
14912 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14913         LDKDelayedPaymentOutputDescriptor o_conv;
14914         o_conv.inner = (void*)(o & (~1));
14915         o_conv.is_owned = (o & 1) || (o == 0);
14916         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14917         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
14918         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14919         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14920         return (uintptr_t)ret_conv;
14921 }
14922
14923 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14924         LDKDecodeError e_conv;
14925         e_conv.inner = (void*)(e & (~1));
14926         e_conv.is_owned = (e & 1) || (e == 0);
14927         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14928         e_conv = DecodeError_clone(&e_conv);
14929         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14930         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14931         return (uintptr_t)ret_conv;
14932 }
14933
14934 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14935         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14936         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14937         return ret_val;
14938 }
14939
14940 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14941         if ((_res & 1) != 0) return;
14942         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14943         CHECK_ACCESS(_res_ptr);
14944         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14945         FREE((void*)_res);
14946         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14947 }
14948
14949 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14950         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14951         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14952         return (uintptr_t)ret_conv;
14953 }
14954 intptr_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14955         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
14956         intptr_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14957         return ret_val;
14958 }
14959
14960 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
14961         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
14962         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14963         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
14964         return (uintptr_t)ret_conv;
14965 }
14966
14967 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14968         LDKStaticPaymentOutputDescriptor o_conv;
14969         o_conv.inner = (void*)(o & (~1));
14970         o_conv.is_owned = (o & 1) || (o == 0);
14971         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14972         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
14973         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14974         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14975         return (uintptr_t)ret_conv;
14976 }
14977
14978 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14979         LDKDecodeError e_conv;
14980         e_conv.inner = (void*)(e & (~1));
14981         e_conv.is_owned = (e & 1) || (e == 0);
14982         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14983         e_conv = DecodeError_clone(&e_conv);
14984         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14985         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14986         return (uintptr_t)ret_conv;
14987 }
14988
14989 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14990         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14991         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14992         return ret_val;
14993 }
14994
14995 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14996         if ((_res & 1) != 0) return;
14997         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14998         CHECK_ACCESS(_res_ptr);
14999         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
15000         FREE((void*)_res);
15001         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
15002 }
15003
15004 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15005         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15006         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
15007         return (uintptr_t)ret_conv;
15008 }
15009 intptr_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
15010         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
15011         intptr_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15012         return ret_val;
15013 }
15014
15015 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15016         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
15017         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15018         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
15019         return (uintptr_t)ret_conv;
15020 }
15021
15022 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
15023         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15024         CHECK_ACCESS(o_ptr);
15025         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
15026         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
15027         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15028         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
15029         return (uintptr_t)ret_conv;
15030 }
15031
15032 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
15033         LDKDecodeError e_conv;
15034         e_conv.inner = (void*)(e & (~1));
15035         e_conv.is_owned = (e & 1) || (e == 0);
15036         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15037         e_conv = DecodeError_clone(&e_conv);
15038         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15039         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
15040         return (uintptr_t)ret_conv;
15041 }
15042
15043 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
15044         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
15045         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
15046         return ret_val;
15047 }
15048
15049 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
15050         if ((_res & 1) != 0) return;
15051         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15052         CHECK_ACCESS(_res_ptr);
15053         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
15054         FREE((void*)_res);
15055         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
15056 }
15057
15058 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15059         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15060         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
15061         return (uintptr_t)ret_conv;
15062 }
15063 intptr_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
15064         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
15065         intptr_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15066         return ret_val;
15067 }
15068
15069 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15070         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
15071         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15072         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
15073         return (uintptr_t)ret_conv;
15074 }
15075
15076 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
15077         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15078         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
15079         return ((uintptr_t)ret_conv);
15080 }
15081 intptr_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
15082         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
15083         intptr_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
15084         return ret_val;
15085 }
15086
15087 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
15088         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
15089         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15090         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
15091         return ((uintptr_t)ret_conv);
15092 }
15093
15094 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
15095         LDKSignature a_ref;
15096         CHECK(a->arr_len == 64);
15097         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
15098         LDKCVec_SignatureZ b_constr;
15099         b_constr.datalen = b->arr_len;
15100         if (b_constr.datalen > 0)
15101                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15102         else
15103                 b_constr.data = NULL;
15104         int8_tArray* b_vals = (void*) b->elems /* XXX b leaks */;
15105         for (size_t m = 0; m < b_constr.datalen; m++) {
15106                 int8_tArray b_conv_12 = b_vals[m];
15107                 LDKSignature b_conv_12_ref;
15108                 CHECK(b_conv_12->arr_len == 64);
15109                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
15110                 b_constr.data[m] = b_conv_12_ref;
15111         }
15112         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15113         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
15114         return ((uintptr_t)ret_conv);
15115 }
15116
15117 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
15118         if ((_res & 1) != 0) return;
15119         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15120         CHECK_ACCESS(_res_ptr);
15121         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
15122         FREE((void*)_res);
15123         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
15124 }
15125
15126 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
15127         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15128         CHECK_ACCESS(o_ptr);
15129         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
15130         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
15131         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15132         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
15133         return (uintptr_t)ret_conv;
15134 }
15135
15136 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
15137         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15138         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
15139         return (uintptr_t)ret_conv;
15140 }
15141
15142 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
15143         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
15144         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
15145         return ret_val;
15146 }
15147
15148 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
15149         if ((_res & 1) != 0) return;
15150         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15151         CHECK_ACCESS(_res_ptr);
15152         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
15153         FREE((void*)_res);
15154         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
15155 }
15156
15157 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
15158         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15159         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
15160         return (uintptr_t)ret_conv;
15161 }
15162 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
15163         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
15164         intptr_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
15165         return ret_val;
15166 }
15167
15168 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
15169         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
15170         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15171         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
15172         return (uintptr_t)ret_conv;
15173 }
15174
15175 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
15176         LDKSignature o_ref;
15177         CHECK(o->arr_len == 64);
15178         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
15179         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15180         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
15181         return (uintptr_t)ret_conv;
15182 }
15183
15184 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
15185         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15186         *ret_conv = CResult_SignatureNoneZ_err();
15187         return (uintptr_t)ret_conv;
15188 }
15189
15190 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
15191         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
15192         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
15193         return ret_val;
15194 }
15195
15196 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
15197         if ((_res & 1) != 0) return;
15198         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15199         CHECK_ACCESS(_res_ptr);
15200         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
15201         FREE((void*)_res);
15202         CResult_SignatureNoneZ_free(_res_conv);
15203 }
15204
15205 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
15206         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15207         *ret_conv = CResult_SignatureNoneZ_clone(arg);
15208         return (uintptr_t)ret_conv;
15209 }
15210 intptr_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
15211         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
15212         intptr_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
15213         return ret_val;
15214 }
15215
15216 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
15217         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
15218         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15219         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
15220         return (uintptr_t)ret_conv;
15221 }
15222
15223 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
15224         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15225         CHECK_ACCESS(o_ptr);
15226         LDKSign o_conv = *(LDKSign*)(o_ptr);
15227         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15228         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
15229         return (uintptr_t)ret_conv;
15230 }
15231
15232 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
15233         LDKDecodeError e_conv;
15234         e_conv.inner = (void*)(e & (~1));
15235         e_conv.is_owned = (e & 1) || (e == 0);
15236         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15237         e_conv = DecodeError_clone(&e_conv);
15238         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15239         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
15240         return (uintptr_t)ret_conv;
15241 }
15242
15243 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
15244         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
15245         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
15246         return ret_val;
15247 }
15248
15249 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
15250         if ((_res & 1) != 0) return;
15251         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15252         CHECK_ACCESS(_res_ptr);
15253         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
15254         FREE((void*)_res);
15255         CResult_SignDecodeErrorZ_free(_res_conv);
15256 }
15257
15258 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
15259         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15260         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
15261         return (uintptr_t)ret_conv;
15262 }
15263 intptr_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
15264         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
15265         intptr_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
15266         return ret_val;
15267 }
15268
15269 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
15270         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
15271         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15272         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
15273         return (uintptr_t)ret_conv;
15274 }
15275
15276 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
15277         LDKRecoverableSignature o_ref;
15278         CHECK(o->arr_len == 68);
15279         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
15280         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15281         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
15282         return (uintptr_t)ret_conv;
15283 }
15284
15285 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
15286         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15287         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
15288         return (uintptr_t)ret_conv;
15289 }
15290
15291 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
15292         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
15293         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
15294         return ret_val;
15295 }
15296
15297 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
15298         if ((_res & 1) != 0) return;
15299         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15300         CHECK_ACCESS(_res_ptr);
15301         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
15302         FREE((void*)_res);
15303         CResult_RecoverableSignatureNoneZ_free(_res_conv);
15304 }
15305
15306 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
15307         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15308         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
15309         return (uintptr_t)ret_conv;
15310 }
15311 intptr_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
15312         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
15313         intptr_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
15314         return ret_val;
15315 }
15316
15317 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
15318         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
15319         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15320         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
15321         return (uintptr_t)ret_conv;
15322 }
15323
15324 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
15325         LDKCVec_CVec_u8ZZ _res_constr;
15326         _res_constr.datalen = _res->arr_len;
15327         if (_res_constr.datalen > 0)
15328                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15329         else
15330                 _res_constr.data = NULL;
15331         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
15332         for (size_t m = 0; m < _res_constr.datalen; m++) {
15333                 int8_tArray _res_conv_12 = _res_vals[m];
15334                 LDKCVec_u8Z _res_conv_12_ref;
15335                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
15336                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15337                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
15338                 _res_constr.data[m] = _res_conv_12_ref;
15339         }
15340         CVec_CVec_u8ZZ_free(_res_constr);
15341 }
15342
15343 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
15344         LDKCVec_CVec_u8ZZ o_constr;
15345         o_constr.datalen = o->arr_len;
15346         if (o_constr.datalen > 0)
15347                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15348         else
15349                 o_constr.data = NULL;
15350         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
15351         for (size_t m = 0; m < o_constr.datalen; m++) {
15352                 int8_tArray o_conv_12 = o_vals[m];
15353                 LDKCVec_u8Z o_conv_12_ref;
15354                 o_conv_12_ref.datalen = o_conv_12->arr_len;
15355                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15356                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
15357                 o_constr.data[m] = o_conv_12_ref;
15358         }
15359         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15360         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
15361         return (uintptr_t)ret_conv;
15362 }
15363
15364 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
15365         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15366         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
15367         return (uintptr_t)ret_conv;
15368 }
15369
15370 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
15371         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
15372         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
15373         return ret_val;
15374 }
15375
15376 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
15377         if ((_res & 1) != 0) return;
15378         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15379         CHECK_ACCESS(_res_ptr);
15380         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
15381         FREE((void*)_res);
15382         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
15383 }
15384
15385 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
15386         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15387         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
15388         return (uintptr_t)ret_conv;
15389 }
15390 intptr_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
15391         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
15392         intptr_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
15393         return ret_val;
15394 }
15395
15396 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
15397         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
15398         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15399         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
15400         return (uintptr_t)ret_conv;
15401 }
15402
15403 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
15404         LDKInMemorySigner o_conv;
15405         o_conv.inner = (void*)(o & (~1));
15406         o_conv.is_owned = (o & 1) || (o == 0);
15407         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15408         o_conv = InMemorySigner_clone(&o_conv);
15409         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15410         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
15411         return (uintptr_t)ret_conv;
15412 }
15413
15414 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
15415         LDKDecodeError e_conv;
15416         e_conv.inner = (void*)(e & (~1));
15417         e_conv.is_owned = (e & 1) || (e == 0);
15418         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15419         e_conv = DecodeError_clone(&e_conv);
15420         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15421         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
15422         return (uintptr_t)ret_conv;
15423 }
15424
15425 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
15426         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
15427         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
15428         return ret_val;
15429 }
15430
15431 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
15432         if ((_res & 1) != 0) return;
15433         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15434         CHECK_ACCESS(_res_ptr);
15435         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
15436         FREE((void*)_res);
15437         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
15438 }
15439
15440 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
15441         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15442         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
15443         return (uintptr_t)ret_conv;
15444 }
15445 intptr_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
15446         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
15447         intptr_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
15448         return ret_val;
15449 }
15450
15451 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
15452         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
15453         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15454         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
15455         return (uintptr_t)ret_conv;
15456 }
15457
15458 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
15459         LDKCVec_TxOutZ _res_constr;
15460         _res_constr.datalen = _res->arr_len;
15461         if (_res_constr.datalen > 0)
15462                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15463         else
15464                 _res_constr.data = NULL;
15465         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15466         for (size_t h = 0; h < _res_constr.datalen; h++) {
15467                 uint32_t _res_conv_7 = _res_vals[h];
15468                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
15469                 CHECK_ACCESS(_res_conv_7_ptr);
15470                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
15471                 FREE((void*)_res_conv_7);
15472                 _res_constr.data[h] = _res_conv_7_conv;
15473         }
15474         CVec_TxOutZ_free(_res_constr);
15475 }
15476
15477 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
15478         LDKTransaction o_ref;
15479         o_ref.datalen = o->arr_len;
15480         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
15481         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
15482         o_ref.data_is_owned = true;
15483         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15484         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
15485         return (uintptr_t)ret_conv;
15486 }
15487
15488 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
15489         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15490         *ret_conv = CResult_TransactionNoneZ_err();
15491         return (uintptr_t)ret_conv;
15492 }
15493
15494 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
15495         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
15496         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
15497         return ret_val;
15498 }
15499
15500 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
15501         if ((_res & 1) != 0) return;
15502         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15503         CHECK_ACCESS(_res_ptr);
15504         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
15505         FREE((void*)_res);
15506         CResult_TransactionNoneZ_free(_res_conv);
15507 }
15508
15509 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
15510         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15511         *ret_conv = CResult_TransactionNoneZ_clone(arg);
15512         return (uintptr_t)ret_conv;
15513 }
15514 intptr_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
15515         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
15516         intptr_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
15517         return ret_val;
15518 }
15519
15520 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
15521         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
15522         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15523         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
15524         return (uintptr_t)ret_conv;
15525 }
15526
15527 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
15528         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15529         CHECK_ACCESS(o_ptr);
15530         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
15531         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
15532         *ret_copy = COption_FilterZ_some(o_conv);
15533         uintptr_t ret_ref = (uintptr_t)ret_copy;
15534         return ret_ref;
15535 }
15536
15537 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
15538         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
15539         *ret_copy = COption_FilterZ_none();
15540         uintptr_t ret_ref = (uintptr_t)ret_copy;
15541         return ret_ref;
15542 }
15543
15544 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
15545         if ((_res & 1) != 0) return;
15546         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15547         CHECK_ACCESS(_res_ptr);
15548         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
15549         FREE((void*)_res);
15550         COption_FilterZ_free(_res_conv);
15551 }
15552
15553 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
15554         LDKLockedChannelMonitor o_conv;
15555         o_conv.inner = (void*)(o & (~1));
15556         o_conv.is_owned = (o & 1) || (o == 0);
15557         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15558         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
15559         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
15560         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
15561         return (uintptr_t)ret_conv;
15562 }
15563
15564 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
15565         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
15566         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
15567         return (uintptr_t)ret_conv;
15568 }
15569
15570 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
15571         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
15572         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
15573         return ret_val;
15574 }
15575
15576 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
15577         if ((_res & 1) != 0) return;
15578         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15579         CHECK_ACCESS(_res_ptr);
15580         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
15581         FREE((void*)_res);
15582         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
15583 }
15584
15585 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
15586         LDKCVec_OutPointZ _res_constr;
15587         _res_constr.datalen = _res->arr_len;
15588         if (_res_constr.datalen > 0)
15589                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
15590         else
15591                 _res_constr.data = NULL;
15592         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15593         for (size_t k = 0; k < _res_constr.datalen; k++) {
15594                 uint32_t _res_conv_10 = _res_vals[k];
15595                 LDKOutPoint _res_conv_10_conv;
15596                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
15597                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
15598                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
15599                 _res_constr.data[k] = _res_conv_10_conv;
15600         }
15601         CVec_OutPointZ_free(_res_constr);
15602 }
15603
15604 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
15605         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15606         *ret_conv = CResult_NoneAPIErrorZ_ok();
15607         return (uintptr_t)ret_conv;
15608 }
15609
15610 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
15611         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15612         CHECK_ACCESS(e_ptr);
15613         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15614         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15615         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15616         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
15617         return (uintptr_t)ret_conv;
15618 }
15619
15620 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
15621         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
15622         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
15623         return ret_val;
15624 }
15625
15626 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
15627         if ((_res & 1) != 0) return;
15628         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15629         CHECK_ACCESS(_res_ptr);
15630         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
15631         FREE((void*)_res);
15632         CResult_NoneAPIErrorZ_free(_res_conv);
15633 }
15634
15635 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
15636         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15637         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
15638         return (uintptr_t)ret_conv;
15639 }
15640 intptr_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
15641         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
15642         intptr_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
15643         return ret_val;
15644 }
15645
15646 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
15647         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
15648         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15649         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
15650         return (uintptr_t)ret_conv;
15651 }
15652
15653 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
15654         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15655         *ret_copy = COption_u16Z_some(o);
15656         uintptr_t ret_ref = (uintptr_t)ret_copy;
15657         return ret_ref;
15658 }
15659
15660 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
15661         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15662         *ret_copy = COption_u16Z_none();
15663         uintptr_t ret_ref = (uintptr_t)ret_copy;
15664         return ret_ref;
15665 }
15666
15667 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
15668         if ((_res & 1) != 0) return;
15669         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15670         CHECK_ACCESS(_res_ptr);
15671         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
15672         FREE((void*)_res);
15673         COption_u16Z_free(_res_conv);
15674 }
15675
15676 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
15677         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15678         *ret_copy = COption_u16Z_clone(arg);
15679 uintptr_t ret_ref = (uintptr_t)ret_copy;
15680         return ret_ref;
15681 }
15682 intptr_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
15683         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
15684         intptr_t ret_val = COption_u16Z_clone_ptr(arg_conv);
15685         return ret_val;
15686 }
15687
15688 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
15689         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
15690         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15691         *ret_copy = COption_u16Z_clone(orig_conv);
15692         uintptr_t ret_ref = (uintptr_t)ret_copy;
15693         return ret_ref;
15694 }
15695
15696 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
15697         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
15698         _res_constr.datalen = _res->arr_len;
15699         if (_res_constr.datalen > 0)
15700                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15701         else
15702                 _res_constr.data = NULL;
15703         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15704         for (size_t w = 0; w < _res_constr.datalen; w++) {
15705                 uint32_t _res_conv_22 = _res_vals[w];
15706                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
15707                 CHECK_ACCESS(_res_conv_22_ptr);
15708                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
15709                 FREE((void*)_res_conv_22);
15710                 _res_constr.data[w] = _res_conv_22_conv;
15711         }
15712         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
15713 }
15714
15715 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
15716         LDKCVec_APIErrorZ _res_constr;
15717         _res_constr.datalen = _res->arr_len;
15718         if (_res_constr.datalen > 0)
15719                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15720         else
15721                 _res_constr.data = NULL;
15722         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15723         for (size_t k = 0; k < _res_constr.datalen; k++) {
15724                 uint32_t _res_conv_10 = _res_vals[k];
15725                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
15726                 CHECK_ACCESS(_res_conv_10_ptr);
15727                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
15728                 FREE((void*)_res_conv_10);
15729                 _res_constr.data[k] = _res_conv_10_conv;
15730         }
15731         CVec_APIErrorZ_free(_res_constr);
15732 }
15733
15734 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
15735         LDKThirtyTwoBytes o_ref;
15736         CHECK(o->arr_len == 32);
15737         memcpy(o_ref.data, o->elems, 32); FREE(o);
15738         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15739         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
15740         return (uintptr_t)ret_conv;
15741 }
15742
15743 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
15744         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15745         CHECK_ACCESS(e_ptr);
15746         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15747         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15748         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15749         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
15750         return (uintptr_t)ret_conv;
15751 }
15752
15753 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
15754         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
15755         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
15756         return ret_val;
15757 }
15758
15759 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_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__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
15764         FREE((void*)_res);
15765         CResult__u832APIErrorZ_free(_res_conv);
15766 }
15767
15768 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
15769         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15770         *ret_conv = CResult__u832APIErrorZ_clone(arg);
15771         return (uintptr_t)ret_conv;
15772 }
15773 intptr_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
15774         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
15775         intptr_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
15776         return ret_val;
15777 }
15778
15779 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
15780         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
15781         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15782         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
15783         return (uintptr_t)ret_conv;
15784 }
15785
15786 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
15787         LDKThirtyTwoBytes o_ref;
15788         CHECK(o->arr_len == 32);
15789         memcpy(o_ref.data, o->elems, 32); FREE(o);
15790         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15791         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
15792         return (uintptr_t)ret_conv;
15793 }
15794
15795 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
15796         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15797         CHECK_ACCESS(e_ptr);
15798         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15799         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15800         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15801         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
15802         return (uintptr_t)ret_conv;
15803 }
15804
15805 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
15806         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
15807         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
15808         return ret_val;
15809 }
15810
15811 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
15812         if ((_res & 1) != 0) return;
15813         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15814         CHECK_ACCESS(_res_ptr);
15815         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
15816         FREE((void*)_res);
15817         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
15818 }
15819
15820 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
15821         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15822         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
15823         return (uintptr_t)ret_conv;
15824 }
15825 intptr_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15826         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
15827         intptr_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
15828         return ret_val;
15829 }
15830
15831 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
15832         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
15833         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15834         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
15835         return (uintptr_t)ret_conv;
15836 }
15837
15838 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
15839         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15840         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
15841         return (uintptr_t)ret_conv;
15842 }
15843
15844 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
15845         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15846         CHECK_ACCESS(e_ptr);
15847         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15848         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15849         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15850         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
15851         return (uintptr_t)ret_conv;
15852 }
15853
15854 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
15855         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
15856         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
15857         return ret_val;
15858 }
15859
15860 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
15861         if ((_res & 1) != 0) return;
15862         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15863         CHECK_ACCESS(_res_ptr);
15864         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
15865         FREE((void*)_res);
15866         CResult_NonePaymentSendFailureZ_free(_res_conv);
15867 }
15868
15869 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
15870         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15871         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
15872         return (uintptr_t)ret_conv;
15873 }
15874 intptr_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
15875         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
15876         intptr_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
15877         return ret_val;
15878 }
15879
15880 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
15881         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
15882         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15883         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
15884         return (uintptr_t)ret_conv;
15885 }
15886
15887 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
15888         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15889         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
15890         return ((uintptr_t)ret_conv);
15891 }
15892 intptr_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
15893         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
15894         intptr_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
15895         return ret_val;
15896 }
15897
15898 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
15899         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
15900         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15901         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
15902         return ((uintptr_t)ret_conv);
15903 }
15904
15905 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
15906         LDKThirtyTwoBytes a_ref;
15907         CHECK(a->arr_len == 32);
15908         memcpy(a_ref.data, a->elems, 32); FREE(a);
15909         LDKThirtyTwoBytes b_ref;
15910         CHECK(b->arr_len == 32);
15911         memcpy(b_ref.data, b->elems, 32); FREE(b);
15912         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15913         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
15914         return ((uintptr_t)ret_conv);
15915 }
15916
15917 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
15918         if ((_res & 1) != 0) return;
15919         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15920         CHECK_ACCESS(_res_ptr);
15921         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
15922         FREE((void*)_res);
15923         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
15924 }
15925
15926 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
15927         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15928         CHECK_ACCESS(o_ptr);
15929         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
15930         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
15931         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15932         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
15933         return (uintptr_t)ret_conv;
15934 }
15935
15936 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
15937         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15938         CHECK_ACCESS(e_ptr);
15939         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15940         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15941         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15942         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
15943         return (uintptr_t)ret_conv;
15944 }
15945
15946 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
15947         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
15948         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
15949         return ret_val;
15950 }
15951
15952 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
15953         if ((_res & 1) != 0) return;
15954         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15955         CHECK_ACCESS(_res_ptr);
15956         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
15957         FREE((void*)_res);
15958         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
15959 }
15960
15961 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
15962         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15963         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
15964         return (uintptr_t)ret_conv;
15965 }
15966 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15967         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
15968         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
15969         return ret_val;
15970 }
15971
15972 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
15973         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
15974         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15975         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
15976         return (uintptr_t)ret_conv;
15977 }
15978
15979 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
15980         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15981         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
15982         return ((uintptr_t)ret_conv);
15983 }
15984 intptr_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
15985         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
15986         intptr_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
15987         return ret_val;
15988 }
15989
15990 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
15991         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
15992         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15993         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
15994         return ((uintptr_t)ret_conv);
15995 }
15996
15997 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
15998         LDKThirtyTwoBytes a_ref;
15999         CHECK(a->arr_len == 32);
16000         memcpy(a_ref.data, a->elems, 32); FREE(a);
16001         LDKThirtyTwoBytes b_ref;
16002         CHECK(b->arr_len == 32);
16003         memcpy(b_ref.data, b->elems, 32); FREE(b);
16004         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16005         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
16006         return ((uintptr_t)ret_conv);
16007 }
16008
16009 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
16010         if ((_res & 1) != 0) return;
16011         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16012         CHECK_ACCESS(_res_ptr);
16013         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
16014         FREE((void*)_res);
16015         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
16016 }
16017
16018 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
16019         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16020         CHECK_ACCESS(o_ptr);
16021         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16022         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
16023         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16024         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
16025         return (uintptr_t)ret_conv;
16026 }
16027
16028 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
16029         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16030         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
16031         return (uintptr_t)ret_conv;
16032 }
16033
16034 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
16035         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
16036         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
16037         return ret_val;
16038 }
16039
16040 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
16041         if ((_res & 1) != 0) return;
16042         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16043         CHECK_ACCESS(_res_ptr);
16044         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
16045         FREE((void*)_res);
16046         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
16047 }
16048
16049 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
16050         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16051         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
16052         return (uintptr_t)ret_conv;
16053 }
16054 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
16055         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
16056         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
16057         return ret_val;
16058 }
16059
16060 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
16061         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
16062         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16063         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
16064         return (uintptr_t)ret_conv;
16065 }
16066
16067 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
16068         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16069         CHECK_ACCESS(o_ptr);
16070         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16071         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
16072         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16073         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
16074         return (uintptr_t)ret_conv;
16075 }
16076
16077 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
16078         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16079         CHECK_ACCESS(e_ptr);
16080         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16081         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16082         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16083         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
16084         return (uintptr_t)ret_conv;
16085 }
16086
16087 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
16088         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
16089         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
16090         return ret_val;
16091 }
16092
16093 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
16094         if ((_res & 1) != 0) return;
16095         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16096         CHECK_ACCESS(_res_ptr);
16097         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
16098         FREE((void*)_res);
16099         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
16100 }
16101
16102 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
16103         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16104         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
16105         return (uintptr_t)ret_conv;
16106 }
16107 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
16108         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
16109         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
16110         return ret_val;
16111 }
16112
16113 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
16114         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
16115         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16116         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
16117         return (uintptr_t)ret_conv;
16118 }
16119
16120 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
16121         LDKThirtyTwoBytes o_ref;
16122         CHECK(o->arr_len == 32);
16123         memcpy(o_ref.data, o->elems, 32); FREE(o);
16124         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16125         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
16126         return (uintptr_t)ret_conv;
16127 }
16128
16129 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
16130         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16131         *ret_conv = CResult_PaymentSecretNoneZ_err();
16132         return (uintptr_t)ret_conv;
16133 }
16134
16135 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
16136         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
16137         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
16138         return ret_val;
16139 }
16140
16141 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
16142         if ((_res & 1) != 0) return;
16143         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16144         CHECK_ACCESS(_res_ptr);
16145         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
16146         FREE((void*)_res);
16147         CResult_PaymentSecretNoneZ_free(_res_conv);
16148 }
16149
16150 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
16151         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16152         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
16153         return (uintptr_t)ret_conv;
16154 }
16155 intptr_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
16156         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
16157         intptr_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
16158         return ret_val;
16159 }
16160
16161 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
16162         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
16163         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16164         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
16165         return (uintptr_t)ret_conv;
16166 }
16167
16168 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
16169         LDKThirtyTwoBytes o_ref;
16170         CHECK(o->arr_len == 32);
16171         memcpy(o_ref.data, o->elems, 32); FREE(o);
16172         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16173         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
16174         return (uintptr_t)ret_conv;
16175 }
16176
16177 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
16178         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16179         CHECK_ACCESS(e_ptr);
16180         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16181         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16182         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16183         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
16184         return (uintptr_t)ret_conv;
16185 }
16186
16187 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
16188         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
16189         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
16190         return ret_val;
16191 }
16192
16193 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
16194         if ((_res & 1) != 0) return;
16195         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16196         CHECK_ACCESS(_res_ptr);
16197         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
16198         FREE((void*)_res);
16199         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
16200 }
16201
16202 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
16203         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16204         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
16205         return (uintptr_t)ret_conv;
16206 }
16207 intptr_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
16208         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
16209         intptr_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
16210         return ret_val;
16211 }
16212
16213 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
16214         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
16215         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16216         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
16217         return (uintptr_t)ret_conv;
16218 }
16219
16220 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
16221         LDKThirtyTwoBytes o_ref;
16222         CHECK(o->arr_len == 32);
16223         memcpy(o_ref.data, o->elems, 32); FREE(o);
16224         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16225         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
16226         return (uintptr_t)ret_conv;
16227 }
16228
16229 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
16230         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16231         CHECK_ACCESS(e_ptr);
16232         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16233         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16234         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16235         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
16236         return (uintptr_t)ret_conv;
16237 }
16238
16239 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
16240         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
16241         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
16242         return ret_val;
16243 }
16244
16245 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
16246         if ((_res & 1) != 0) return;
16247         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16248         CHECK_ACCESS(_res_ptr);
16249         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
16250         FREE((void*)_res);
16251         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
16252 }
16253
16254 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
16255         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16256         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
16257         return (uintptr_t)ret_conv;
16258 }
16259 intptr_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
16260         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
16261         intptr_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
16262         return ret_val;
16263 }
16264
16265 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
16266         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
16267         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16268         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
16269         return (uintptr_t)ret_conv;
16270 }
16271
16272 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
16273         LDKCVec_ChannelMonitorZ _res_constr;
16274         _res_constr.datalen = _res->arr_len;
16275         if (_res_constr.datalen > 0)
16276                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16277         else
16278                 _res_constr.data = NULL;
16279         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16280         for (size_t q = 0; q < _res_constr.datalen; q++) {
16281                 uint32_t _res_conv_16 = _res_vals[q];
16282                 LDKChannelMonitor _res_conv_16_conv;
16283                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16284                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16285                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16286                 _res_constr.data[q] = _res_conv_16_conv;
16287         }
16288         CVec_ChannelMonitorZ_free(_res_constr);
16289 }
16290
16291 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
16292         LDKThirtyTwoBytes a_ref;
16293         CHECK(a->arr_len == 32);
16294         memcpy(a_ref.data, a->elems, 32); FREE(a);
16295         LDKChannelManager b_conv;
16296         b_conv.inner = (void*)(b & (~1));
16297         b_conv.is_owned = (b & 1) || (b == 0);
16298         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16299         // Warning: we need a move here but no clone is available for LDKChannelManager
16300         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
16301         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
16302         return ((uintptr_t)ret_conv);
16303 }
16304
16305 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
16306         if ((_res & 1) != 0) return;
16307         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16308         CHECK_ACCESS(_res_ptr);
16309         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
16310         FREE((void*)_res);
16311         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
16312 }
16313
16314 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
16315         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16316         CHECK_ACCESS(o_ptr);
16317         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
16318         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
16319         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16320         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
16321         return (uintptr_t)ret_conv;
16322 }
16323
16324 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
16325         LDKDecodeError e_conv;
16326         e_conv.inner = (void*)(e & (~1));
16327         e_conv.is_owned = (e & 1) || (e == 0);
16328         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16329         e_conv = DecodeError_clone(&e_conv);
16330         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16331         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
16332         return (uintptr_t)ret_conv;
16333 }
16334
16335 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
16336         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
16337         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
16338         return ret_val;
16339 }
16340
16341 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
16342         if ((_res & 1) != 0) return;
16343         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16344         CHECK_ACCESS(_res_ptr);
16345         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
16346         FREE((void*)_res);
16347         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
16348 }
16349
16350 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
16351         if ((this_ptr & 1) != 0) return;
16352         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
16353         CHECK_ACCESS(this_ptr_ptr);
16354         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
16355         FREE((void*)this_ptr);
16356         PaymentPurpose_free(this_ptr_conv);
16357 }
16358
16359 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
16360         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16361         *ret_copy = PaymentPurpose_clone(arg);
16362 uintptr_t ret_ref = (uintptr_t)ret_copy;
16363         return ret_ref;
16364 }
16365 intptr_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
16366         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
16367         intptr_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
16368         return ret_val;
16369 }
16370
16371 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
16372         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
16373         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16374         *ret_copy = PaymentPurpose_clone(orig_conv);
16375         uintptr_t ret_ref = (uintptr_t)ret_copy;
16376         return ret_ref;
16377 }
16378
16379 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
16380         LDKThirtyTwoBytes payment_preimage_ref;
16381         CHECK(payment_preimage->arr_len == 32);
16382         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
16383         LDKThirtyTwoBytes payment_secret_ref;
16384         CHECK(payment_secret->arr_len == 32);
16385         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
16386         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16387         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
16388         uintptr_t ret_ref = (uintptr_t)ret_copy;
16389         return ret_ref;
16390 }
16391
16392 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
16393         LDKThirtyTwoBytes a_ref;
16394         CHECK(a->arr_len == 32);
16395         memcpy(a_ref.data, a->elems, 32); FREE(a);
16396         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16397         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
16398         uintptr_t ret_ref = (uintptr_t)ret_copy;
16399         return ret_ref;
16400 }
16401
16402 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
16403         if ((this_ptr & 1) != 0) return;
16404         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
16405         CHECK_ACCESS(this_ptr_ptr);
16406         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
16407         FREE((void*)this_ptr);
16408         ClosureReason_free(this_ptr_conv);
16409 }
16410
16411 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
16412         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16413         *ret_copy = ClosureReason_clone(arg);
16414 uintptr_t ret_ref = (uintptr_t)ret_copy;
16415         return ret_ref;
16416 }
16417 intptr_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
16418         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
16419         intptr_t ret_val = ClosureReason_clone_ptr(arg_conv);
16420         return ret_val;
16421 }
16422
16423 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
16424         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
16425         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16426         *ret_copy = ClosureReason_clone(orig_conv);
16427         uintptr_t ret_ref = (uintptr_t)ret_copy;
16428         return ret_ref;
16429 }
16430
16431 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
16432         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
16433         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16434         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
16435         uintptr_t ret_ref = (uintptr_t)ret_copy;
16436         return ret_ref;
16437 }
16438
16439 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
16440         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16441         *ret_copy = ClosureReason_holder_force_closed();
16442         uintptr_t ret_ref = (uintptr_t)ret_copy;
16443         return ret_ref;
16444 }
16445
16446 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
16447         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16448         *ret_copy = ClosureReason_cooperative_closure();
16449         uintptr_t ret_ref = (uintptr_t)ret_copy;
16450         return ret_ref;
16451 }
16452
16453 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
16454         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16455         *ret_copy = ClosureReason_commitment_tx_confirmed();
16456         uintptr_t ret_ref = (uintptr_t)ret_copy;
16457         return ret_ref;
16458 }
16459
16460 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
16461         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16462         *ret_copy = ClosureReason_funding_timed_out();
16463         uintptr_t ret_ref = (uintptr_t)ret_copy;
16464         return ret_ref;
16465 }
16466
16467 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
16468         LDKStr err_conv = str_ref_to_owned_c(err);
16469         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16470         *ret_copy = ClosureReason_processing_error(err_conv);
16471         uintptr_t ret_ref = (uintptr_t)ret_copy;
16472         return ret_ref;
16473 }
16474
16475 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
16476         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16477         *ret_copy = ClosureReason_disconnected_peer();
16478         uintptr_t ret_ref = (uintptr_t)ret_copy;
16479         return ret_ref;
16480 }
16481
16482 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
16483         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16484         *ret_copy = ClosureReason_outdated_channel_manager();
16485         uintptr_t ret_ref = (uintptr_t)ret_copy;
16486         return ret_ref;
16487 }
16488
16489 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
16490         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
16491         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
16492         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
16493         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
16494         CVec_u8Z_free(ret_var);
16495         return ret_arr;
16496 }
16497
16498 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
16499         LDKu8slice ser_ref;
16500         ser_ref.datalen = ser->arr_len;
16501         ser_ref.data = ser->elems /* XXX ser leaks */;
16502         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16503         *ret_conv = ClosureReason_read(ser_ref);
16504         return (uintptr_t)ret_conv;
16505 }
16506
16507 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
16508         if ((this_ptr & 1) != 0) return;
16509         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
16510         CHECK_ACCESS(this_ptr_ptr);
16511         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
16512         FREE((void*)this_ptr);
16513         Event_free(this_ptr_conv);
16514 }
16515
16516 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
16517         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16518         *ret_copy = Event_clone(arg);
16519 uintptr_t ret_ref = (uintptr_t)ret_copy;
16520         return ret_ref;
16521 }
16522 intptr_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
16523         LDKEvent* arg_conv = (LDKEvent*)arg;
16524         intptr_t ret_val = Event_clone_ptr(arg_conv);
16525         return ret_val;
16526 }
16527
16528 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
16529         LDKEvent* orig_conv = (LDKEvent*)orig;
16530         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16531         *ret_copy = Event_clone(orig_conv);
16532         uintptr_t ret_ref = (uintptr_t)ret_copy;
16533         return ret_ref;
16534 }
16535
16536 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) {
16537         LDKThirtyTwoBytes temporary_channel_id_ref;
16538         CHECK(temporary_channel_id->arr_len == 32);
16539         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
16540         LDKCVec_u8Z output_script_ref;
16541         output_script_ref.datalen = output_script->arr_len;
16542         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
16543         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
16544         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16545         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
16546         uintptr_t ret_ref = (uintptr_t)ret_copy;
16547         return ret_ref;
16548 }
16549
16550 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
16551         LDKThirtyTwoBytes payment_hash_ref;
16552         CHECK(payment_hash->arr_len == 32);
16553         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
16554         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
16555         CHECK_ACCESS(purpose_ptr);
16556         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
16557         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
16558         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16559         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
16560         uintptr_t ret_ref = (uintptr_t)ret_copy;
16561         return ret_ref;
16562 }
16563
16564 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) {
16565         LDKThirtyTwoBytes payment_id_ref;
16566         CHECK(payment_id->arr_len == 32);
16567         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
16568         LDKThirtyTwoBytes payment_preimage_ref;
16569         CHECK(payment_preimage->arr_len == 32);
16570         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
16571         LDKThirtyTwoBytes payment_hash_ref;
16572         CHECK(payment_hash->arr_len == 32);
16573         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
16574         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
16575         CHECK_ACCESS(fee_paid_msat_ptr);
16576         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
16577         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
16578         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16579         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
16580         uintptr_t ret_ref = (uintptr_t)ret_copy;
16581         return ret_ref;
16582 }
16583
16584 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) {
16585         LDKThirtyTwoBytes payment_id_ref;
16586         CHECK(payment_id->arr_len == 32);
16587         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
16588         LDKThirtyTwoBytes payment_hash_ref;
16589         CHECK(payment_hash->arr_len == 32);
16590         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
16591         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
16592         CHECK_ACCESS(network_update_ptr);
16593         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
16594         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
16595         LDKCVec_RouteHopZ path_constr;
16596         path_constr.datalen = path->arr_len;
16597         if (path_constr.datalen > 0)
16598                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16599         else
16600                 path_constr.data = NULL;
16601         uint32_t* path_vals = path->elems /* XXX path leaks */;
16602         for (size_t k = 0; k < path_constr.datalen; k++) {
16603                 uint32_t path_conv_10 = path_vals[k];
16604                 LDKRouteHop path_conv_10_conv;
16605                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
16606                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
16607                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
16608                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
16609                 path_constr.data[k] = path_conv_10_conv;
16610         }
16611         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
16612         CHECK_ACCESS(short_channel_id_ptr);
16613         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
16614         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
16615         LDKRouteParameters retry_conv;
16616         retry_conv.inner = (void*)(retry & (~1));
16617         retry_conv.is_owned = (retry & 1) || (retry == 0);
16618         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
16619         retry_conv = RouteParameters_clone(&retry_conv);
16620         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16621         *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);
16622         uintptr_t ret_ref = (uintptr_t)ret_copy;
16623         return ret_ref;
16624 }
16625
16626 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
16627         LDKThirtyTwoBytes payment_id_ref;
16628         CHECK(payment_id->arr_len == 32);
16629         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
16630         LDKThirtyTwoBytes payment_hash_ref;
16631         CHECK(payment_hash->arr_len == 32);
16632         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
16633         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16634         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
16635         uintptr_t ret_ref = (uintptr_t)ret_copy;
16636         return ret_ref;
16637 }
16638
16639 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
16640         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16641         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
16642         uintptr_t ret_ref = (uintptr_t)ret_copy;
16643         return ret_ref;
16644 }
16645
16646 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
16647         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
16648         outputs_constr.datalen = outputs->arr_len;
16649         if (outputs_constr.datalen > 0)
16650                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16651         else
16652                 outputs_constr.data = NULL;
16653         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
16654         for (size_t b = 0; b < outputs_constr.datalen; b++) {
16655                 uint32_t outputs_conv_27 = outputs_vals[b];
16656                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
16657                 CHECK_ACCESS(outputs_conv_27_ptr);
16658                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
16659                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
16660                 outputs_constr.data[b] = outputs_conv_27_conv;
16661         }
16662         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16663         *ret_copy = Event_spendable_outputs(outputs_constr);
16664         uintptr_t ret_ref = (uintptr_t)ret_copy;
16665         return ret_ref;
16666 }
16667
16668 uint32_t  __attribute__((export_name("TS_Event_payment_forwarded"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
16669         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
16670         CHECK_ACCESS(fee_earned_msat_ptr);
16671         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
16672         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
16673         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16674         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
16675         uintptr_t ret_ref = (uintptr_t)ret_copy;
16676         return ret_ref;
16677 }
16678
16679 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) {
16680         LDKThirtyTwoBytes channel_id_ref;
16681         CHECK(channel_id->arr_len == 32);
16682         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
16683         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
16684         CHECK_ACCESS(reason_ptr);
16685         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
16686         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
16687         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16688         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
16689         uintptr_t ret_ref = (uintptr_t)ret_copy;
16690         return ret_ref;
16691 }
16692
16693 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
16694         LDKThirtyTwoBytes channel_id_ref;
16695         CHECK(channel_id->arr_len == 32);
16696         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
16697         LDKTransaction transaction_ref;
16698         transaction_ref.datalen = transaction->arr_len;
16699         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
16700         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
16701         transaction_ref.data_is_owned = true;
16702         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16703         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
16704         uintptr_t ret_ref = (uintptr_t)ret_copy;
16705         return ret_ref;
16706 }
16707
16708 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) {
16709         LDKThirtyTwoBytes payment_id_ref;
16710         CHECK(payment_id->arr_len == 32);
16711         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
16712         LDKThirtyTwoBytes payment_hash_ref;
16713         CHECK(payment_hash->arr_len == 32);
16714         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
16715         LDKCVec_RouteHopZ path_constr;
16716         path_constr.datalen = path->arr_len;
16717         if (path_constr.datalen > 0)
16718                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16719         else
16720                 path_constr.data = NULL;
16721         uint32_t* path_vals = path->elems /* XXX path leaks */;
16722         for (size_t k = 0; k < path_constr.datalen; k++) {
16723                 uint32_t path_conv_10 = path_vals[k];
16724                 LDKRouteHop path_conv_10_conv;
16725                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
16726                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
16727                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
16728                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
16729                 path_constr.data[k] = path_conv_10_conv;
16730         }
16731         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16732         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
16733         uintptr_t ret_ref = (uintptr_t)ret_copy;
16734         return ret_ref;
16735 }
16736
16737 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
16738         LDKEvent* obj_conv = (LDKEvent*)obj;
16739         LDKCVec_u8Z ret_var = Event_write(obj_conv);
16740         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
16741         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
16742         CVec_u8Z_free(ret_var);
16743         return ret_arr;
16744 }
16745
16746 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
16747         LDKu8slice ser_ref;
16748         ser_ref.datalen = ser->arr_len;
16749         ser_ref.data = ser->elems /* XXX ser leaks */;
16750         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16751         *ret_conv = Event_read(ser_ref);
16752         return (uintptr_t)ret_conv;
16753 }
16754
16755 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
16756         if ((this_ptr & 1) != 0) return;
16757         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
16758         CHECK_ACCESS(this_ptr_ptr);
16759         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
16760         FREE((void*)this_ptr);
16761         MessageSendEvent_free(this_ptr_conv);
16762 }
16763
16764 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
16765         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16766         *ret_copy = MessageSendEvent_clone(arg);
16767 uintptr_t ret_ref = (uintptr_t)ret_copy;
16768         return ret_ref;
16769 }
16770 intptr_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
16771         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
16772         intptr_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
16773         return ret_val;
16774 }
16775
16776 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
16777         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
16778         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16779         *ret_copy = MessageSendEvent_clone(orig_conv);
16780         uintptr_t ret_ref = (uintptr_t)ret_copy;
16781         return ret_ref;
16782 }
16783
16784 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
16785         LDKPublicKey node_id_ref;
16786         CHECK(node_id->arr_len == 33);
16787         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16788         LDKAcceptChannel msg_conv;
16789         msg_conv.inner = (void*)(msg & (~1));
16790         msg_conv.is_owned = (msg & 1) || (msg == 0);
16791         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16792         msg_conv = AcceptChannel_clone(&msg_conv);
16793         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16794         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
16795         uintptr_t ret_ref = (uintptr_t)ret_copy;
16796         return ret_ref;
16797 }
16798
16799 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
16800         LDKPublicKey node_id_ref;
16801         CHECK(node_id->arr_len == 33);
16802         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16803         LDKOpenChannel msg_conv;
16804         msg_conv.inner = (void*)(msg & (~1));
16805         msg_conv.is_owned = (msg & 1) || (msg == 0);
16806         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16807         msg_conv = OpenChannel_clone(&msg_conv);
16808         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16809         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
16810         uintptr_t ret_ref = (uintptr_t)ret_copy;
16811         return ret_ref;
16812 }
16813
16814 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
16815         LDKPublicKey node_id_ref;
16816         CHECK(node_id->arr_len == 33);
16817         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16818         LDKFundingCreated msg_conv;
16819         msg_conv.inner = (void*)(msg & (~1));
16820         msg_conv.is_owned = (msg & 1) || (msg == 0);
16821         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16822         msg_conv = FundingCreated_clone(&msg_conv);
16823         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16824         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
16825         uintptr_t ret_ref = (uintptr_t)ret_copy;
16826         return ret_ref;
16827 }
16828
16829 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
16830         LDKPublicKey node_id_ref;
16831         CHECK(node_id->arr_len == 33);
16832         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16833         LDKFundingSigned msg_conv;
16834         msg_conv.inner = (void*)(msg & (~1));
16835         msg_conv.is_owned = (msg & 1) || (msg == 0);
16836         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16837         msg_conv = FundingSigned_clone(&msg_conv);
16838         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16839         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
16840         uintptr_t ret_ref = (uintptr_t)ret_copy;
16841         return ret_ref;
16842 }
16843
16844 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_locked"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
16845         LDKPublicKey node_id_ref;
16846         CHECK(node_id->arr_len == 33);
16847         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16848         LDKFundingLocked msg_conv;
16849         msg_conv.inner = (void*)(msg & (~1));
16850         msg_conv.is_owned = (msg & 1) || (msg == 0);
16851         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16852         msg_conv = FundingLocked_clone(&msg_conv);
16853         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16854         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
16855         uintptr_t ret_ref = (uintptr_t)ret_copy;
16856         return ret_ref;
16857 }
16858
16859 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
16860         LDKPublicKey node_id_ref;
16861         CHECK(node_id->arr_len == 33);
16862         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16863         LDKAnnouncementSignatures msg_conv;
16864         msg_conv.inner = (void*)(msg & (~1));
16865         msg_conv.is_owned = (msg & 1) || (msg == 0);
16866         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16867         msg_conv = AnnouncementSignatures_clone(&msg_conv);
16868         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16869         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
16870         uintptr_t ret_ref = (uintptr_t)ret_copy;
16871         return ret_ref;
16872 }
16873
16874 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
16875         LDKPublicKey node_id_ref;
16876         CHECK(node_id->arr_len == 33);
16877         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16878         LDKCommitmentUpdate updates_conv;
16879         updates_conv.inner = (void*)(updates & (~1));
16880         updates_conv.is_owned = (updates & 1) || (updates == 0);
16881         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
16882         updates_conv = CommitmentUpdate_clone(&updates_conv);
16883         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16884         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
16885         uintptr_t ret_ref = (uintptr_t)ret_copy;
16886         return ret_ref;
16887 }
16888
16889 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
16890         LDKPublicKey node_id_ref;
16891         CHECK(node_id->arr_len == 33);
16892         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16893         LDKRevokeAndACK msg_conv;
16894         msg_conv.inner = (void*)(msg & (~1));
16895         msg_conv.is_owned = (msg & 1) || (msg == 0);
16896         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16897         msg_conv = RevokeAndACK_clone(&msg_conv);
16898         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16899         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
16900         uintptr_t ret_ref = (uintptr_t)ret_copy;
16901         return ret_ref;
16902 }
16903
16904 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
16905         LDKPublicKey node_id_ref;
16906         CHECK(node_id->arr_len == 33);
16907         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16908         LDKClosingSigned msg_conv;
16909         msg_conv.inner = (void*)(msg & (~1));
16910         msg_conv.is_owned = (msg & 1) || (msg == 0);
16911         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16912         msg_conv = ClosingSigned_clone(&msg_conv);
16913         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16914         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
16915         uintptr_t ret_ref = (uintptr_t)ret_copy;
16916         return ret_ref;
16917 }
16918
16919 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
16920         LDKPublicKey node_id_ref;
16921         CHECK(node_id->arr_len == 33);
16922         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16923         LDKShutdown msg_conv;
16924         msg_conv.inner = (void*)(msg & (~1));
16925         msg_conv.is_owned = (msg & 1) || (msg == 0);
16926         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16927         msg_conv = Shutdown_clone(&msg_conv);
16928         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16929         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
16930         uintptr_t ret_ref = (uintptr_t)ret_copy;
16931         return ret_ref;
16932 }
16933
16934 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
16935         LDKPublicKey node_id_ref;
16936         CHECK(node_id->arr_len == 33);
16937         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16938         LDKChannelReestablish msg_conv;
16939         msg_conv.inner = (void*)(msg & (~1));
16940         msg_conv.is_owned = (msg & 1) || (msg == 0);
16941         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16942         msg_conv = ChannelReestablish_clone(&msg_conv);
16943         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16944         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
16945         uintptr_t ret_ref = (uintptr_t)ret_copy;
16946         return ret_ref;
16947 }
16948
16949 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
16950         LDKChannelAnnouncement msg_conv;
16951         msg_conv.inner = (void*)(msg & (~1));
16952         msg_conv.is_owned = (msg & 1) || (msg == 0);
16953         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16954         msg_conv = ChannelAnnouncement_clone(&msg_conv);
16955         LDKChannelUpdate update_msg_conv;
16956         update_msg_conv.inner = (void*)(update_msg & (~1));
16957         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
16958         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
16959         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
16960         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16961         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
16962         uintptr_t ret_ref = (uintptr_t)ret_copy;
16963         return ret_ref;
16964 }
16965
16966 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
16967         LDKNodeAnnouncement msg_conv;
16968         msg_conv.inner = (void*)(msg & (~1));
16969         msg_conv.is_owned = (msg & 1) || (msg == 0);
16970         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16971         msg_conv = NodeAnnouncement_clone(&msg_conv);
16972         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16973         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
16974         uintptr_t ret_ref = (uintptr_t)ret_copy;
16975         return ret_ref;
16976 }
16977
16978 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
16979         LDKChannelUpdate msg_conv;
16980         msg_conv.inner = (void*)(msg & (~1));
16981         msg_conv.is_owned = (msg & 1) || (msg == 0);
16982         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16983         msg_conv = ChannelUpdate_clone(&msg_conv);
16984         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16985         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
16986         uintptr_t ret_ref = (uintptr_t)ret_copy;
16987         return ret_ref;
16988 }
16989
16990 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
16991         LDKPublicKey node_id_ref;
16992         CHECK(node_id->arr_len == 33);
16993         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16994         LDKChannelUpdate msg_conv;
16995         msg_conv.inner = (void*)(msg & (~1));
16996         msg_conv.is_owned = (msg & 1) || (msg == 0);
16997         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16998         msg_conv = ChannelUpdate_clone(&msg_conv);
16999         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17000         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
17001         uintptr_t ret_ref = (uintptr_t)ret_copy;
17002         return ret_ref;
17003 }
17004
17005 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
17006         LDKPublicKey node_id_ref;
17007         CHECK(node_id->arr_len == 33);
17008         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
17009         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
17010         CHECK_ACCESS(action_ptr);
17011         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
17012         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
17013         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17014         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
17015         uintptr_t ret_ref = (uintptr_t)ret_copy;
17016         return ret_ref;
17017 }
17018
17019 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
17020         LDKPublicKey node_id_ref;
17021         CHECK(node_id->arr_len == 33);
17022         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
17023         LDKQueryChannelRange msg_conv;
17024         msg_conv.inner = (void*)(msg & (~1));
17025         msg_conv.is_owned = (msg & 1) || (msg == 0);
17026         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17027         msg_conv = QueryChannelRange_clone(&msg_conv);
17028         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17029         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
17030         uintptr_t ret_ref = (uintptr_t)ret_copy;
17031         return ret_ref;
17032 }
17033
17034 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
17035         LDKPublicKey node_id_ref;
17036         CHECK(node_id->arr_len == 33);
17037         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
17038         LDKQueryShortChannelIds msg_conv;
17039         msg_conv.inner = (void*)(msg & (~1));
17040         msg_conv.is_owned = (msg & 1) || (msg == 0);
17041         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17042         msg_conv = QueryShortChannelIds_clone(&msg_conv);
17043         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17044         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
17045         uintptr_t ret_ref = (uintptr_t)ret_copy;
17046         return ret_ref;
17047 }
17048
17049 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
17050         LDKPublicKey node_id_ref;
17051         CHECK(node_id->arr_len == 33);
17052         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
17053         LDKReplyChannelRange msg_conv;
17054         msg_conv.inner = (void*)(msg & (~1));
17055         msg_conv.is_owned = (msg & 1) || (msg == 0);
17056         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17057         msg_conv = ReplyChannelRange_clone(&msg_conv);
17058         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17059         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
17060         uintptr_t ret_ref = (uintptr_t)ret_copy;
17061         return ret_ref;
17062 }
17063
17064 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
17065         if ((this_ptr & 1) != 0) return;
17066         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
17067         CHECK_ACCESS(this_ptr_ptr);
17068         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
17069         FREE((void*)this_ptr);
17070         MessageSendEventsProvider_free(this_ptr_conv);
17071 }
17072
17073 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
17074         if ((this_ptr & 1) != 0) return;
17075         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
17076         CHECK_ACCESS(this_ptr_ptr);
17077         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
17078         FREE((void*)this_ptr);
17079         EventsProvider_free(this_ptr_conv);
17080 }
17081
17082 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
17083         if ((this_ptr & 1) != 0) return;
17084         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
17085         CHECK_ACCESS(this_ptr_ptr);
17086         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
17087         FREE((void*)this_ptr);
17088         EventHandler_free(this_ptr_conv);
17089 }
17090
17091 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
17092         if ((this_ptr & 1) != 0) return;
17093         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
17094         CHECK_ACCESS(this_ptr_ptr);
17095         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
17096         FREE((void*)this_ptr);
17097         APIError_free(this_ptr_conv);
17098 }
17099
17100 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
17101         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17102         *ret_copy = APIError_clone(arg);
17103 uintptr_t ret_ref = (uintptr_t)ret_copy;
17104         return ret_ref;
17105 }
17106 intptr_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
17107         LDKAPIError* arg_conv = (LDKAPIError*)arg;
17108         intptr_t ret_val = APIError_clone_ptr(arg_conv);
17109         return ret_val;
17110 }
17111
17112 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
17113         LDKAPIError* orig_conv = (LDKAPIError*)orig;
17114         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17115         *ret_copy = APIError_clone(orig_conv);
17116         uintptr_t ret_ref = (uintptr_t)ret_copy;
17117         return ret_ref;
17118 }
17119
17120 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
17121         LDKStr err_conv = str_ref_to_owned_c(err);
17122         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17123         *ret_copy = APIError_apimisuse_error(err_conv);
17124         uintptr_t ret_ref = (uintptr_t)ret_copy;
17125         return ret_ref;
17126 }
17127
17128 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
17129         LDKStr err_conv = str_ref_to_owned_c(err);
17130         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17131         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
17132         uintptr_t ret_ref = (uintptr_t)ret_copy;
17133         return ret_ref;
17134 }
17135
17136 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
17137         LDKStr err_conv = str_ref_to_owned_c(err);
17138         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17139         *ret_copy = APIError_route_error(err_conv);
17140         uintptr_t ret_ref = (uintptr_t)ret_copy;
17141         return ret_ref;
17142 }
17143
17144 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
17145         LDKStr err_conv = str_ref_to_owned_c(err);
17146         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17147         *ret_copy = APIError_channel_unavailable(err_conv);
17148         uintptr_t ret_ref = (uintptr_t)ret_copy;
17149         return ret_ref;
17150 }
17151
17152 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
17153         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17154         *ret_copy = APIError_monitor_update_failed();
17155         uintptr_t ret_ref = (uintptr_t)ret_copy;
17156         return ret_ref;
17157 }
17158
17159 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
17160         LDKShutdownScript script_conv;
17161         script_conv.inner = (void*)(script & (~1));
17162         script_conv.is_owned = (script & 1) || (script == 0);
17163         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
17164         script_conv = ShutdownScript_clone(&script_conv);
17165         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17166         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
17167         uintptr_t ret_ref = (uintptr_t)ret_copy;
17168         return ret_ref;
17169 }
17170
17171 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
17172         LDKu8slice msg_ref;
17173         msg_ref.datalen = msg->arr_len;
17174         msg_ref.data = msg->elems /* XXX msg leaks */;
17175         unsigned char sk_arr[32];
17176         CHECK(sk->arr_len == 32);
17177         memcpy(sk_arr, sk->elems, 32); FREE(sk);
17178         unsigned char (*sk_ref)[32] = &sk_arr;
17179         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17180         *ret_conv = sign(msg_ref, sk_ref);
17181         return (uintptr_t)ret_conv;
17182 }
17183
17184 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
17185         LDKu8slice msg_ref;
17186         msg_ref.datalen = msg->arr_len;
17187         msg_ref.data = msg->elems /* XXX msg leaks */;
17188         LDKStr sig_conv = str_ref_to_owned_c(sig);
17189         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
17190         *ret_conv = recover_pk(msg_ref, sig_conv);
17191         return (uintptr_t)ret_conv;
17192 }
17193
17194 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
17195         LDKu8slice msg_ref;
17196         msg_ref.datalen = msg->arr_len;
17197         msg_ref.data = msg->elems /* XXX msg leaks */;
17198         LDKStr sig_conv = str_ref_to_owned_c(sig);
17199         LDKPublicKey pk_ref;
17200         CHECK(pk->arr_len == 33);
17201         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
17202         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
17203         return ret_val;
17204 }
17205
17206 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
17207         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
17208         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
17209         return ret_conv;
17210 }
17211
17212 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
17213         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
17214         return ret_conv;
17215 }
17216
17217 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
17218         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
17219         return ret_conv;
17220 }
17221
17222 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
17223         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
17224         return ret_conv;
17225 }
17226
17227 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
17228         uint32_t ret_conv = LDKLevel_to_js(Level_info());
17229         return ret_conv;
17230 }
17231
17232 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
17233         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
17234         return ret_conv;
17235 }
17236
17237 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
17238         uint32_t ret_conv = LDKLevel_to_js(Level_error());
17239         return ret_conv;
17240 }
17241
17242 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
17243         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
17244         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
17245         jboolean ret_val = Level_eq(a_conv, b_conv);
17246         return ret_val;
17247 }
17248
17249 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
17250         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
17251         int64_t ret_val = Level_hash(o_conv);
17252         return ret_val;
17253 }
17254
17255 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
17256         uint32_t ret_conv = LDKLevel_to_js(Level_max());
17257         return ret_conv;
17258 }
17259
17260 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
17261         LDKRecord this_obj_conv;
17262         this_obj_conv.inner = (void*)(this_obj & (~1));
17263         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17265         Record_free(this_obj_conv);
17266 }
17267
17268 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
17269         LDKRecord this_ptr_conv;
17270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17271         this_ptr_conv.is_owned = false;
17272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17273         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
17274         return ret_conv;
17275 }
17276
17277 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
17278         LDKRecord this_ptr_conv;
17279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17280         this_ptr_conv.is_owned = false;
17281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17282         LDKLevel val_conv = LDKLevel_from_js(val);
17283         Record_set_level(&this_ptr_conv, val_conv);
17284 }
17285
17286 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
17287         LDKRecord this_ptr_conv;
17288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17289         this_ptr_conv.is_owned = false;
17290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17291         LDKStr ret_str = Record_get_args(&this_ptr_conv);
17292         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17293         Str_free(ret_str);
17294         return ret_conv;
17295 }
17296
17297 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
17298         LDKRecord this_ptr_conv;
17299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17300         this_ptr_conv.is_owned = false;
17301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17302         LDKStr val_conv = str_ref_to_owned_c(val);
17303         Record_set_args(&this_ptr_conv, val_conv);
17304 }
17305
17306 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
17307         LDKRecord this_ptr_conv;
17308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17309         this_ptr_conv.is_owned = false;
17310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17311         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
17312         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17313         Str_free(ret_str);
17314         return ret_conv;
17315 }
17316
17317 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
17318         LDKRecord this_ptr_conv;
17319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17320         this_ptr_conv.is_owned = false;
17321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17322         LDKStr val_conv = str_ref_to_owned_c(val);
17323         Record_set_module_path(&this_ptr_conv, val_conv);
17324 }
17325
17326 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
17327         LDKRecord this_ptr_conv;
17328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17329         this_ptr_conv.is_owned = false;
17330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17331         LDKStr ret_str = Record_get_file(&this_ptr_conv);
17332         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17333         Str_free(ret_str);
17334         return ret_conv;
17335 }
17336
17337 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
17338         LDKRecord this_ptr_conv;
17339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17340         this_ptr_conv.is_owned = false;
17341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17342         LDKStr val_conv = str_ref_to_owned_c(val);
17343         Record_set_file(&this_ptr_conv, val_conv);
17344 }
17345
17346 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
17347         LDKRecord this_ptr_conv;
17348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17349         this_ptr_conv.is_owned = false;
17350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17351         int32_t ret_val = Record_get_line(&this_ptr_conv);
17352         return ret_val;
17353 }
17354
17355 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
17356         LDKRecord this_ptr_conv;
17357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17358         this_ptr_conv.is_owned = false;
17359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17360         Record_set_line(&this_ptr_conv, val);
17361 }
17362
17363 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
17364         LDKRecord ret_var = Record_clone(arg);
17365 uintptr_t ret_ref = 0;
17366 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17367 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17368 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17369 ret_ref = (uintptr_t)ret_var.inner;
17370 if (ret_var.is_owned) {
17371         ret_ref |= 1;
17372 }
17373         return ret_ref;
17374 }
17375 intptr_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
17376         LDKRecord arg_conv;
17377         arg_conv.inner = (void*)(arg & (~1));
17378         arg_conv.is_owned = false;
17379         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17380         intptr_t ret_val = Record_clone_ptr(&arg_conv);
17381         return ret_val;
17382 }
17383
17384 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
17385         LDKRecord orig_conv;
17386         orig_conv.inner = (void*)(orig & (~1));
17387         orig_conv.is_owned = false;
17388         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17389         LDKRecord ret_var = Record_clone(&orig_conv);
17390         uintptr_t ret_ref = 0;
17391         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17392         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17394         ret_ref = (uintptr_t)ret_var.inner;
17395         if (ret_var.is_owned) {
17396                 ret_ref |= 1;
17397         }
17398         return ret_ref;
17399 }
17400
17401 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
17402         if ((this_ptr & 1) != 0) return;
17403         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
17404         CHECK_ACCESS(this_ptr_ptr);
17405         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
17406         FREE((void*)this_ptr);
17407         Logger_free(this_ptr_conv);
17408 }
17409
17410 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
17411         LDKChannelHandshakeConfig this_obj_conv;
17412         this_obj_conv.inner = (void*)(this_obj & (~1));
17413         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17415         ChannelHandshakeConfig_free(this_obj_conv);
17416 }
17417
17418 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
17419         LDKChannelHandshakeConfig this_ptr_conv;
17420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17421         this_ptr_conv.is_owned = false;
17422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17423         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
17424         return ret_val;
17425 }
17426
17427 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
17428         LDKChannelHandshakeConfig this_ptr_conv;
17429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17430         this_ptr_conv.is_owned = false;
17431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17432         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
17433 }
17434
17435 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
17436         LDKChannelHandshakeConfig this_ptr_conv;
17437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17438         this_ptr_conv.is_owned = false;
17439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17440         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
17441         return ret_val;
17442 }
17443
17444 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) {
17445         LDKChannelHandshakeConfig this_ptr_conv;
17446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17447         this_ptr_conv.is_owned = false;
17448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17449         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
17450 }
17451
17452 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
17453         LDKChannelHandshakeConfig this_ptr_conv;
17454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17455         this_ptr_conv.is_owned = false;
17456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17457         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
17458         return ret_val;
17459 }
17460
17461 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) {
17462         LDKChannelHandshakeConfig this_ptr_conv;
17463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17464         this_ptr_conv.is_owned = false;
17465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17466         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
17467 }
17468
17469 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) {
17470         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
17471         uintptr_t ret_ref = 0;
17472         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17473         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17475         ret_ref = (uintptr_t)ret_var.inner;
17476         if (ret_var.is_owned) {
17477                 ret_ref |= 1;
17478         }
17479         return ret_ref;
17480 }
17481
17482 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
17483         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
17484 uintptr_t ret_ref = 0;
17485 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17486 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17487 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17488 ret_ref = (uintptr_t)ret_var.inner;
17489 if (ret_var.is_owned) {
17490         ret_ref |= 1;
17491 }
17492         return ret_ref;
17493 }
17494 intptr_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
17495         LDKChannelHandshakeConfig arg_conv;
17496         arg_conv.inner = (void*)(arg & (~1));
17497         arg_conv.is_owned = false;
17498         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17499         intptr_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
17500         return ret_val;
17501 }
17502
17503 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
17504         LDKChannelHandshakeConfig orig_conv;
17505         orig_conv.inner = (void*)(orig & (~1));
17506         orig_conv.is_owned = false;
17507         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17508         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
17509         uintptr_t ret_ref = 0;
17510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17513         ret_ref = (uintptr_t)ret_var.inner;
17514         if (ret_var.is_owned) {
17515                 ret_ref |= 1;
17516         }
17517         return ret_ref;
17518 }
17519
17520 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
17521         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
17522         uintptr_t ret_ref = 0;
17523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17526         ret_ref = (uintptr_t)ret_var.inner;
17527         if (ret_var.is_owned) {
17528                 ret_ref |= 1;
17529         }
17530         return ret_ref;
17531 }
17532
17533 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
17534         LDKChannelHandshakeLimits this_obj_conv;
17535         this_obj_conv.inner = (void*)(this_obj & (~1));
17536         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17538         ChannelHandshakeLimits_free(this_obj_conv);
17539 }
17540
17541 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
17542         LDKChannelHandshakeLimits this_ptr_conv;
17543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17544         this_ptr_conv.is_owned = false;
17545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17546         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
17547         return ret_val;
17548 }
17549
17550 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
17551         LDKChannelHandshakeLimits this_ptr_conv;
17552         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17553         this_ptr_conv.is_owned = false;
17554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17555         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
17556 }
17557
17558 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
17559         LDKChannelHandshakeLimits this_ptr_conv;
17560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17561         this_ptr_conv.is_owned = false;
17562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17563         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
17564         return ret_val;
17565 }
17566
17567 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) {
17568         LDKChannelHandshakeLimits this_ptr_conv;
17569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17570         this_ptr_conv.is_owned = false;
17571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17572         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
17573 }
17574
17575 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) {
17576         LDKChannelHandshakeLimits this_ptr_conv;
17577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17578         this_ptr_conv.is_owned = false;
17579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17580         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
17581         return ret_val;
17582 }
17583
17584 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) {
17585         LDKChannelHandshakeLimits this_ptr_conv;
17586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17587         this_ptr_conv.is_owned = false;
17588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17589         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17590 }
17591
17592 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
17593         LDKChannelHandshakeLimits this_ptr_conv;
17594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17595         this_ptr_conv.is_owned = false;
17596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17597         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
17598         return ret_val;
17599 }
17600
17601 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) {
17602         LDKChannelHandshakeLimits this_ptr_conv;
17603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17604         this_ptr_conv.is_owned = false;
17605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17606         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
17607 }
17608
17609 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
17610         LDKChannelHandshakeLimits this_ptr_conv;
17611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17612         this_ptr_conv.is_owned = false;
17613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17614         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
17615         return ret_val;
17616 }
17617
17618 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) {
17619         LDKChannelHandshakeLimits this_ptr_conv;
17620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17621         this_ptr_conv.is_owned = false;
17622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17623         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
17624 }
17625
17626 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
17627         LDKChannelHandshakeLimits this_ptr_conv;
17628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17629         this_ptr_conv.is_owned = false;
17630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17631         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
17632         return ret_val;
17633 }
17634
17635 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
17636         LDKChannelHandshakeLimits this_ptr_conv;
17637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17638         this_ptr_conv.is_owned = false;
17639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17640         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
17641 }
17642
17643 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
17644         LDKChannelHandshakeLimits this_ptr_conv;
17645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17646         this_ptr_conv.is_owned = false;
17647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17648         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
17649         return ret_val;
17650 }
17651
17652 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
17653         LDKChannelHandshakeLimits this_ptr_conv;
17654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17655         this_ptr_conv.is_owned = false;
17656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17657         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
17658 }
17659
17660 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
17661         LDKChannelHandshakeLimits this_ptr_conv;
17662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17663         this_ptr_conv.is_owned = false;
17664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17665         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
17666         return ret_val;
17667 }
17668
17669 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) {
17670         LDKChannelHandshakeLimits this_ptr_conv;
17671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17672         this_ptr_conv.is_owned = false;
17673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17674         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
17675 }
17676
17677 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) {
17678         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);
17679         uintptr_t ret_ref = 0;
17680         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17681         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17683         ret_ref = (uintptr_t)ret_var.inner;
17684         if (ret_var.is_owned) {
17685                 ret_ref |= 1;
17686         }
17687         return ret_ref;
17688 }
17689
17690 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
17691         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
17692 uintptr_t ret_ref = 0;
17693 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17694 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17695 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17696 ret_ref = (uintptr_t)ret_var.inner;
17697 if (ret_var.is_owned) {
17698         ret_ref |= 1;
17699 }
17700         return ret_ref;
17701 }
17702 intptr_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
17703         LDKChannelHandshakeLimits arg_conv;
17704         arg_conv.inner = (void*)(arg & (~1));
17705         arg_conv.is_owned = false;
17706         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17707         intptr_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
17708         return ret_val;
17709 }
17710
17711 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
17712         LDKChannelHandshakeLimits orig_conv;
17713         orig_conv.inner = (void*)(orig & (~1));
17714         orig_conv.is_owned = false;
17715         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17716         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
17717         uintptr_t ret_ref = 0;
17718         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17719         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17721         ret_ref = (uintptr_t)ret_var.inner;
17722         if (ret_var.is_owned) {
17723                 ret_ref |= 1;
17724         }
17725         return ret_ref;
17726 }
17727
17728 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
17729         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
17730         uintptr_t ret_ref = 0;
17731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17734         ret_ref = (uintptr_t)ret_var.inner;
17735         if (ret_var.is_owned) {
17736                 ret_ref |= 1;
17737         }
17738         return ret_ref;
17739 }
17740
17741 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
17742         LDKChannelConfig this_obj_conv;
17743         this_obj_conv.inner = (void*)(this_obj & (~1));
17744         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17746         ChannelConfig_free(this_obj_conv);
17747 }
17748
17749 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
17750         LDKChannelConfig this_ptr_conv;
17751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17752         this_ptr_conv.is_owned = false;
17753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17754         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
17755         return ret_val;
17756 }
17757
17758 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) {
17759         LDKChannelConfig this_ptr_conv;
17760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17761         this_ptr_conv.is_owned = false;
17762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17763         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
17764 }
17765
17766 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
17767         LDKChannelConfig this_ptr_conv;
17768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17769         this_ptr_conv.is_owned = false;
17770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17771         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
17772         return ret_val;
17773 }
17774
17775 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) {
17776         LDKChannelConfig this_ptr_conv;
17777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17778         this_ptr_conv.is_owned = false;
17779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17780         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
17781 }
17782
17783 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
17784         LDKChannelConfig this_ptr_conv;
17785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17786         this_ptr_conv.is_owned = false;
17787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17788         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
17789         return ret_val;
17790 }
17791
17792 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
17793         LDKChannelConfig this_ptr_conv;
17794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17795         this_ptr_conv.is_owned = false;
17796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17797         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
17798 }
17799
17800 jboolean  __attribute__((export_name("TS_ChannelConfig_get_announced_channel"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
17801         LDKChannelConfig this_ptr_conv;
17802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17803         this_ptr_conv.is_owned = false;
17804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17805         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
17806         return ret_val;
17807 }
17808
17809 void  __attribute__((export_name("TS_ChannelConfig_set_announced_channel"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
17810         LDKChannelConfig this_ptr_conv;
17811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17812         this_ptr_conv.is_owned = false;
17813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17814         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
17815 }
17816
17817 jboolean  __attribute__((export_name("TS_ChannelConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
17818         LDKChannelConfig this_ptr_conv;
17819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17820         this_ptr_conv.is_owned = false;
17821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17822         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
17823         return ret_val;
17824 }
17825
17826 void  __attribute__((export_name("TS_ChannelConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
17827         LDKChannelConfig this_ptr_conv;
17828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17829         this_ptr_conv.is_owned = false;
17830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17831         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
17832 }
17833
17834 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) {
17835         LDKChannelConfig this_ptr_conv;
17836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17837         this_ptr_conv.is_owned = false;
17838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17839         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
17840         return ret_val;
17841 }
17842
17843 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) {
17844         LDKChannelConfig this_ptr_conv;
17845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17846         this_ptr_conv.is_owned = false;
17847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17848         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
17849 }
17850
17851 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) {
17852         LDKChannelConfig this_ptr_conv;
17853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17854         this_ptr_conv.is_owned = false;
17855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17856         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
17857         return ret_val;
17858 }
17859
17860 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) {
17861         LDKChannelConfig this_ptr_conv;
17862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17863         this_ptr_conv.is_owned = false;
17864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17865         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
17866 }
17867
17868 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) {
17869         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);
17870         uintptr_t ret_ref = 0;
17871         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17872         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17874         ret_ref = (uintptr_t)ret_var.inner;
17875         if (ret_var.is_owned) {
17876                 ret_ref |= 1;
17877         }
17878         return ret_ref;
17879 }
17880
17881 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
17882         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
17883 uintptr_t ret_ref = 0;
17884 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17885 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17886 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17887 ret_ref = (uintptr_t)ret_var.inner;
17888 if (ret_var.is_owned) {
17889         ret_ref |= 1;
17890 }
17891         return ret_ref;
17892 }
17893 intptr_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
17894         LDKChannelConfig arg_conv;
17895         arg_conv.inner = (void*)(arg & (~1));
17896         arg_conv.is_owned = false;
17897         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17898         intptr_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
17899         return ret_val;
17900 }
17901
17902 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
17903         LDKChannelConfig orig_conv;
17904         orig_conv.inner = (void*)(orig & (~1));
17905         orig_conv.is_owned = false;
17906         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17907         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
17908         uintptr_t ret_ref = 0;
17909         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17910         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17912         ret_ref = (uintptr_t)ret_var.inner;
17913         if (ret_var.is_owned) {
17914                 ret_ref |= 1;
17915         }
17916         return ret_ref;
17917 }
17918
17919 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
17920         LDKChannelConfig ret_var = ChannelConfig_default();
17921         uintptr_t ret_ref = 0;
17922         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17923         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17925         ret_ref = (uintptr_t)ret_var.inner;
17926         if (ret_var.is_owned) {
17927                 ret_ref |= 1;
17928         }
17929         return ret_ref;
17930 }
17931
17932 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
17933         LDKChannelConfig obj_conv;
17934         obj_conv.inner = (void*)(obj & (~1));
17935         obj_conv.is_owned = false;
17936         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
17937         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
17938         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
17939         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
17940         CVec_u8Z_free(ret_var);
17941         return ret_arr;
17942 }
17943
17944 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
17945         LDKu8slice ser_ref;
17946         ser_ref.datalen = ser->arr_len;
17947         ser_ref.data = ser->elems /* XXX ser leaks */;
17948         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
17949         *ret_conv = ChannelConfig_read(ser_ref);
17950         return (uintptr_t)ret_conv;
17951 }
17952
17953 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
17954         LDKUserConfig this_obj_conv;
17955         this_obj_conv.inner = (void*)(this_obj & (~1));
17956         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17958         UserConfig_free(this_obj_conv);
17959 }
17960
17961 uint32_t  __attribute__((export_name("TS_UserConfig_get_own_channel_config"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
17962         LDKUserConfig this_ptr_conv;
17963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17964         this_ptr_conv.is_owned = false;
17965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17966         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
17967         uintptr_t ret_ref = 0;
17968         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17969         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17970         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17971         ret_ref = (uintptr_t)ret_var.inner;
17972         if (ret_var.is_owned) {
17973                 ret_ref |= 1;
17974         }
17975         return ret_ref;
17976 }
17977
17978 void  __attribute__((export_name("TS_UserConfig_set_own_channel_config"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
17979         LDKUserConfig this_ptr_conv;
17980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17981         this_ptr_conv.is_owned = false;
17982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17983         LDKChannelHandshakeConfig val_conv;
17984         val_conv.inner = (void*)(val & (~1));
17985         val_conv.is_owned = (val & 1) || (val == 0);
17986         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
17987         val_conv = ChannelHandshakeConfig_clone(&val_conv);
17988         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
17989 }
17990
17991 uint32_t  __attribute__((export_name("TS_UserConfig_get_peer_channel_config_limits"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
17992         LDKUserConfig this_ptr_conv;
17993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17994         this_ptr_conv.is_owned = false;
17995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17996         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
17997         uintptr_t ret_ref = 0;
17998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18001         ret_ref = (uintptr_t)ret_var.inner;
18002         if (ret_var.is_owned) {
18003                 ret_ref |= 1;
18004         }
18005         return ret_ref;
18006 }
18007
18008 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) {
18009         LDKUserConfig this_ptr_conv;
18010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18011         this_ptr_conv.is_owned = false;
18012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18013         LDKChannelHandshakeLimits val_conv;
18014         val_conv.inner = (void*)(val & (~1));
18015         val_conv.is_owned = (val & 1) || (val == 0);
18016         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
18017         val_conv = ChannelHandshakeLimits_clone(&val_conv);
18018         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
18019 }
18020
18021 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_options"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
18022         LDKUserConfig this_ptr_conv;
18023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18024         this_ptr_conv.is_owned = false;
18025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18026         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
18027         uintptr_t ret_ref = 0;
18028         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18029         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18031         ret_ref = (uintptr_t)ret_var.inner;
18032         if (ret_var.is_owned) {
18033                 ret_ref |= 1;
18034         }
18035         return ret_ref;
18036 }
18037
18038 void  __attribute__((export_name("TS_UserConfig_set_channel_options"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
18039         LDKUserConfig this_ptr_conv;
18040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18041         this_ptr_conv.is_owned = false;
18042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18043         LDKChannelConfig val_conv;
18044         val_conv.inner = (void*)(val & (~1));
18045         val_conv.is_owned = (val & 1) || (val == 0);
18046         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
18047         val_conv = ChannelConfig_clone(&val_conv);
18048         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
18049 }
18050
18051 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
18052         LDKUserConfig this_ptr_conv;
18053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18054         this_ptr_conv.is_owned = false;
18055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18056         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
18057         return ret_val;
18058 }
18059
18060 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) {
18061         LDKUserConfig this_ptr_conv;
18062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18063         this_ptr_conv.is_owned = false;
18064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18065         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
18066 }
18067
18068 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
18069         LDKUserConfig this_ptr_conv;
18070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18071         this_ptr_conv.is_owned = false;
18072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18073         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
18074         return ret_val;
18075 }
18076
18077 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
18078         LDKUserConfig this_ptr_conv;
18079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18080         this_ptr_conv.is_owned = false;
18081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18082         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
18083 }
18084
18085 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) {
18086         LDKChannelHandshakeConfig own_channel_config_arg_conv;
18087         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
18088         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
18089         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
18090         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
18091         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
18092         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
18093         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
18094         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
18095         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
18096         LDKChannelConfig channel_options_arg_conv;
18097         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
18098         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
18099         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
18100         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
18101         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);
18102         uintptr_t ret_ref = 0;
18103         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18104         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18106         ret_ref = (uintptr_t)ret_var.inner;
18107         if (ret_var.is_owned) {
18108                 ret_ref |= 1;
18109         }
18110         return ret_ref;
18111 }
18112
18113 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
18114         LDKUserConfig ret_var = UserConfig_clone(arg);
18115 uintptr_t ret_ref = 0;
18116 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18117 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18118 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18119 ret_ref = (uintptr_t)ret_var.inner;
18120 if (ret_var.is_owned) {
18121         ret_ref |= 1;
18122 }
18123         return ret_ref;
18124 }
18125 intptr_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
18126         LDKUserConfig arg_conv;
18127         arg_conv.inner = (void*)(arg & (~1));
18128         arg_conv.is_owned = false;
18129         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18130         intptr_t ret_val = UserConfig_clone_ptr(&arg_conv);
18131         return ret_val;
18132 }
18133
18134 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
18135         LDKUserConfig orig_conv;
18136         orig_conv.inner = (void*)(orig & (~1));
18137         orig_conv.is_owned = false;
18138         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18139         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
18140         uintptr_t ret_ref = 0;
18141         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18142         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18144         ret_ref = (uintptr_t)ret_var.inner;
18145         if (ret_var.is_owned) {
18146                 ret_ref |= 1;
18147         }
18148         return ret_ref;
18149 }
18150
18151 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
18152         LDKUserConfig ret_var = UserConfig_default();
18153         uintptr_t ret_ref = 0;
18154         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18155         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18157         ret_ref = (uintptr_t)ret_var.inner;
18158         if (ret_var.is_owned) {
18159                 ret_ref |= 1;
18160         }
18161         return ret_ref;
18162 }
18163
18164 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
18165         LDKBestBlock this_obj_conv;
18166         this_obj_conv.inner = (void*)(this_obj & (~1));
18167         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18169         BestBlock_free(this_obj_conv);
18170 }
18171
18172 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
18173         LDKBestBlock ret_var = BestBlock_clone(arg);
18174 uintptr_t ret_ref = 0;
18175 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18176 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18177 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18178 ret_ref = (uintptr_t)ret_var.inner;
18179 if (ret_var.is_owned) {
18180         ret_ref |= 1;
18181 }
18182         return ret_ref;
18183 }
18184 intptr_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
18185         LDKBestBlock arg_conv;
18186         arg_conv.inner = (void*)(arg & (~1));
18187         arg_conv.is_owned = false;
18188         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18189         intptr_t ret_val = BestBlock_clone_ptr(&arg_conv);
18190         return ret_val;
18191 }
18192
18193 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
18194         LDKBestBlock orig_conv;
18195         orig_conv.inner = (void*)(orig & (~1));
18196         orig_conv.is_owned = false;
18197         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18198         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
18199         uintptr_t ret_ref = 0;
18200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18203         ret_ref = (uintptr_t)ret_var.inner;
18204         if (ret_var.is_owned) {
18205                 ret_ref |= 1;
18206         }
18207         return ret_ref;
18208 }
18209
18210 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
18211         LDKNetwork network_conv = LDKNetwork_from_js(network);
18212         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
18213         uintptr_t ret_ref = 0;
18214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18217         ret_ref = (uintptr_t)ret_var.inner;
18218         if (ret_var.is_owned) {
18219                 ret_ref |= 1;
18220         }
18221         return ret_ref;
18222 }
18223
18224 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
18225         LDKThirtyTwoBytes block_hash_ref;
18226         CHECK(block_hash->arr_len == 32);
18227         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
18228         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
18229         uintptr_t ret_ref = 0;
18230         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18231         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18233         ret_ref = (uintptr_t)ret_var.inner;
18234         if (ret_var.is_owned) {
18235                 ret_ref |= 1;
18236         }
18237         return ret_ref;
18238 }
18239
18240 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
18241         LDKBestBlock this_arg_conv;
18242         this_arg_conv.inner = (void*)(this_arg & (~1));
18243         this_arg_conv.is_owned = false;
18244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18245         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
18246         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
18247         return ret_arr;
18248 }
18249
18250 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
18251         LDKBestBlock this_arg_conv;
18252         this_arg_conv.inner = (void*)(this_arg & (~1));
18253         this_arg_conv.is_owned = false;
18254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18255         int32_t ret_val = BestBlock_height(&this_arg_conv);
18256         return ret_val;
18257 }
18258
18259 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
18260         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
18261         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
18262         return ret_conv;
18263 }
18264
18265 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
18266         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
18267         return ret_conv;
18268 }
18269
18270 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
18271         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
18272         return ret_conv;
18273 }
18274
18275 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
18276         if ((this_ptr & 1) != 0) return;
18277         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18278         CHECK_ACCESS(this_ptr_ptr);
18279         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
18280         FREE((void*)this_ptr);
18281         Access_free(this_ptr_conv);
18282 }
18283
18284 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
18285         if ((this_ptr & 1) != 0) return;
18286         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18287         CHECK_ACCESS(this_ptr_ptr);
18288         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
18289         FREE((void*)this_ptr);
18290         Listen_free(this_ptr_conv);
18291 }
18292
18293 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
18294         if ((this_ptr & 1) != 0) return;
18295         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18296         CHECK_ACCESS(this_ptr_ptr);
18297         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
18298         FREE((void*)this_ptr);
18299         Confirm_free(this_ptr_conv);
18300 }
18301
18302 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
18303         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
18304         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
18305         return ret_conv;
18306 }
18307
18308 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
18309         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
18310         return ret_conv;
18311 }
18312
18313 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
18314         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
18315         return ret_conv;
18316 }
18317
18318 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
18319         if ((this_ptr & 1) != 0) return;
18320         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18321         CHECK_ACCESS(this_ptr_ptr);
18322         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
18323         FREE((void*)this_ptr);
18324         Watch_free(this_ptr_conv);
18325 }
18326
18327 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
18328         if ((this_ptr & 1) != 0) return;
18329         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18330         CHECK_ACCESS(this_ptr_ptr);
18331         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
18332         FREE((void*)this_ptr);
18333         Filter_free(this_ptr_conv);
18334 }
18335
18336 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
18337         LDKWatchedOutput this_obj_conv;
18338         this_obj_conv.inner = (void*)(this_obj & (~1));
18339         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18341         WatchedOutput_free(this_obj_conv);
18342 }
18343
18344 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
18345         LDKWatchedOutput this_ptr_conv;
18346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18347         this_ptr_conv.is_owned = false;
18348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18349         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
18350         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
18351         return ret_arr;
18352 }
18353
18354 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
18355         LDKWatchedOutput this_ptr_conv;
18356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18357         this_ptr_conv.is_owned = false;
18358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18359         LDKThirtyTwoBytes val_ref;
18360         CHECK(val->arr_len == 32);
18361         memcpy(val_ref.data, val->elems, 32); FREE(val);
18362         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
18363 }
18364
18365 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
18366         LDKWatchedOutput this_ptr_conv;
18367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18368         this_ptr_conv.is_owned = false;
18369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18370         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
18371         uintptr_t ret_ref = 0;
18372         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18373         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18375         ret_ref = (uintptr_t)ret_var.inner;
18376         if (ret_var.is_owned) {
18377                 ret_ref |= 1;
18378         }
18379         return ret_ref;
18380 }
18381
18382 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
18383         LDKWatchedOutput this_ptr_conv;
18384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18385         this_ptr_conv.is_owned = false;
18386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18387         LDKOutPoint val_conv;
18388         val_conv.inner = (void*)(val & (~1));
18389         val_conv.is_owned = (val & 1) || (val == 0);
18390         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
18391         val_conv = OutPoint_clone(&val_conv);
18392         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
18393 }
18394
18395 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
18396         LDKWatchedOutput this_ptr_conv;
18397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18398         this_ptr_conv.is_owned = false;
18399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18400         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
18401         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
18402         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
18403         return ret_arr;
18404 }
18405
18406 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
18407         LDKWatchedOutput this_ptr_conv;
18408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18409         this_ptr_conv.is_owned = false;
18410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18411         LDKCVec_u8Z val_ref;
18412         val_ref.datalen = val->arr_len;
18413         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
18414         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
18415         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
18416 }
18417
18418 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) {
18419         LDKThirtyTwoBytes block_hash_arg_ref;
18420         CHECK(block_hash_arg->arr_len == 32);
18421         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
18422         LDKOutPoint outpoint_arg_conv;
18423         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
18424         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
18425         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
18426         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
18427         LDKCVec_u8Z script_pubkey_arg_ref;
18428         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
18429         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
18430         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
18431         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
18432         uintptr_t ret_ref = 0;
18433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18436         ret_ref = (uintptr_t)ret_var.inner;
18437         if (ret_var.is_owned) {
18438                 ret_ref |= 1;
18439         }
18440         return ret_ref;
18441 }
18442
18443 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
18444         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
18445 uintptr_t ret_ref = 0;
18446 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18447 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18448 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18449 ret_ref = (uintptr_t)ret_var.inner;
18450 if (ret_var.is_owned) {
18451         ret_ref |= 1;
18452 }
18453         return ret_ref;
18454 }
18455 intptr_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
18456         LDKWatchedOutput arg_conv;
18457         arg_conv.inner = (void*)(arg & (~1));
18458         arg_conv.is_owned = false;
18459         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18460         intptr_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
18461         return ret_val;
18462 }
18463
18464 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
18465         LDKWatchedOutput orig_conv;
18466         orig_conv.inner = (void*)(orig & (~1));
18467         orig_conv.is_owned = false;
18468         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18469         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
18470         uintptr_t ret_ref = 0;
18471         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18472         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18474         ret_ref = (uintptr_t)ret_var.inner;
18475         if (ret_var.is_owned) {
18476                 ret_ref |= 1;
18477         }
18478         return ret_ref;
18479 }
18480
18481 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
18482         LDKWatchedOutput o_conv;
18483         o_conv.inner = (void*)(o & (~1));
18484         o_conv.is_owned = false;
18485         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18486         int64_t ret_val = WatchedOutput_hash(&o_conv);
18487         return ret_val;
18488 }
18489
18490 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
18491         if ((this_ptr & 1) != 0) return;
18492         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18493         CHECK_ACCESS(this_ptr_ptr);
18494         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
18495         FREE((void*)this_ptr);
18496         BroadcasterInterface_free(this_ptr_conv);
18497 }
18498
18499 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
18500         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
18501         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
18502         return ret_conv;
18503 }
18504
18505 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
18506         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
18507         return ret_conv;
18508 }
18509
18510 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
18511         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
18512         return ret_conv;
18513 }
18514
18515 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
18516         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
18517         return ret_conv;
18518 }
18519
18520 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
18521         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
18522         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
18523         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
18524         return ret_val;
18525 }
18526
18527 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
18528         if ((this_ptr & 1) != 0) return;
18529         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18530         CHECK_ACCESS(this_ptr_ptr);
18531         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
18532         FREE((void*)this_ptr);
18533         FeeEstimator_free(this_ptr_conv);
18534 }
18535
18536 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
18537         LDKMonitorUpdateId this_obj_conv;
18538         this_obj_conv.inner = (void*)(this_obj & (~1));
18539         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18541         MonitorUpdateId_free(this_obj_conv);
18542 }
18543
18544 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
18545         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
18546 uintptr_t ret_ref = 0;
18547 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18548 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18549 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18550 ret_ref = (uintptr_t)ret_var.inner;
18551 if (ret_var.is_owned) {
18552         ret_ref |= 1;
18553 }
18554         return ret_ref;
18555 }
18556 intptr_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
18557         LDKMonitorUpdateId arg_conv;
18558         arg_conv.inner = (void*)(arg & (~1));
18559         arg_conv.is_owned = false;
18560         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18561         intptr_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
18562         return ret_val;
18563 }
18564
18565 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
18566         LDKMonitorUpdateId orig_conv;
18567         orig_conv.inner = (void*)(orig & (~1));
18568         orig_conv.is_owned = false;
18569         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18570         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
18571         uintptr_t ret_ref = 0;
18572         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18573         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18575         ret_ref = (uintptr_t)ret_var.inner;
18576         if (ret_var.is_owned) {
18577                 ret_ref |= 1;
18578         }
18579         return ret_ref;
18580 }
18581
18582 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
18583         LDKMonitorUpdateId o_conv;
18584         o_conv.inner = (void*)(o & (~1));
18585         o_conv.is_owned = false;
18586         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18587         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
18588         return ret_val;
18589 }
18590
18591 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
18592         LDKMonitorUpdateId a_conv;
18593         a_conv.inner = (void*)(a & (~1));
18594         a_conv.is_owned = false;
18595         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18596         LDKMonitorUpdateId b_conv;
18597         b_conv.inner = (void*)(b & (~1));
18598         b_conv.is_owned = false;
18599         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18600         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
18601         return ret_val;
18602 }
18603
18604 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
18605         if ((this_ptr & 1) != 0) return;
18606         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18607         CHECK_ACCESS(this_ptr_ptr);
18608         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
18609         FREE((void*)this_ptr);
18610         Persist_free(this_ptr_conv);
18611 }
18612
18613 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
18614         LDKLockedChannelMonitor this_obj_conv;
18615         this_obj_conv.inner = (void*)(this_obj & (~1));
18616         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18618         LockedChannelMonitor_free(this_obj_conv);
18619 }
18620
18621 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
18622         LDKChainMonitor this_obj_conv;
18623         this_obj_conv.inner = (void*)(this_obj & (~1));
18624         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18626         ChainMonitor_free(this_obj_conv);
18627 }
18628
18629 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) {
18630         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
18631         CHECK_ACCESS(chain_source_ptr);
18632         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
18633         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
18634         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
18635                 // Manually implement clone for Java trait instances
18636         }
18637         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
18638         CHECK_ACCESS(broadcaster_ptr);
18639         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
18640         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
18641         CHECK_ACCESS(logger_ptr);
18642         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18643         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
18644         CHECK_ACCESS(feeest_ptr);
18645         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
18646         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
18647         CHECK_ACCESS(persister_ptr);
18648         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
18649         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
18650         uintptr_t ret_ref = 0;
18651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18654         ret_ref = (uintptr_t)ret_var.inner;
18655         if (ret_var.is_owned) {
18656                 ret_ref |= 1;
18657         }
18658         return ret_ref;
18659 }
18660
18661 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
18662         LDKChainMonitor this_arg_conv;
18663         this_arg_conv.inner = (void*)(this_arg & (~1));
18664         this_arg_conv.is_owned = false;
18665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18666         LDKCVec_ChannelDetailsZ ignored_channels_constr;
18667         ignored_channels_constr.datalen = ignored_channels->arr_len;
18668         if (ignored_channels_constr.datalen > 0)
18669                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
18670         else
18671                 ignored_channels_constr.data = NULL;
18672         uint32_t* ignored_channels_vals = ignored_channels->elems /* XXX ignored_channels leaks */;
18673         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
18674                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
18675                 LDKChannelDetails ignored_channels_conv_16_conv;
18676                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
18677                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
18678                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
18679                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
18680                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
18681         }
18682         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
18683         uint32_tArray ret_arr = NULL;
18684         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
18685         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
18686         for (size_t j = 0; j < ret_var.datalen; j++) {
18687                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
18688                 *ret_conv_9_copy = ret_var.data[j];
18689                 uintptr_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
18690                 ret_arr_ptr[j] = ret_conv_9_ref;
18691         }
18692         
18693         FREE(ret_var.data);
18694         return ret_arr;
18695 }
18696
18697 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
18698         LDKChainMonitor this_arg_conv;
18699         this_arg_conv.inner = (void*)(this_arg & (~1));
18700         this_arg_conv.is_owned = false;
18701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18702         LDKOutPoint funding_txo_conv;
18703         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18704         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18705         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18706         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18707         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
18708         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
18709         return (uintptr_t)ret_conv;
18710 }
18711
18712 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
18713         LDKChainMonitor this_arg_conv;
18714         this_arg_conv.inner = (void*)(this_arg & (~1));
18715         this_arg_conv.is_owned = false;
18716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18717         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
18718         uint32_tArray ret_arr = NULL;
18719         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
18720         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
18721         for (size_t k = 0; k < ret_var.datalen; k++) {
18722                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
18723                 uintptr_t ret_conv_10_ref = 0;
18724                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18725                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18726                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
18727                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
18728                 if (ret_conv_10_var.is_owned) {
18729                         ret_conv_10_ref |= 1;
18730                 }
18731                 ret_arr_ptr[k] = ret_conv_10_ref;
18732         }
18733         
18734         FREE(ret_var.data);
18735         return ret_arr;
18736 }
18737
18738 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) {
18739         LDKChainMonitor this_arg_conv;
18740         this_arg_conv.inner = (void*)(this_arg & (~1));
18741         this_arg_conv.is_owned = false;
18742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18743         LDKOutPoint funding_txo_conv;
18744         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18745         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18746         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18747         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18748         LDKMonitorUpdateId completed_update_id_conv;
18749         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
18750         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
18751         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
18752         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
18753         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18754         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
18755         return (uintptr_t)ret_conv;
18756 }
18757
18758 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
18759         LDKChainMonitor this_arg_conv;
18760         this_arg_conv.inner = (void*)(this_arg & (~1));
18761         this_arg_conv.is_owned = false;
18762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18763         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
18764         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
18765         return (uintptr_t)ret_ret;
18766 }
18767
18768 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
18769         LDKChainMonitor this_arg_conv;
18770         this_arg_conv.inner = (void*)(this_arg & (~1));
18771         this_arg_conv.is_owned = false;
18772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18773         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
18774         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
18775         return (uintptr_t)ret_ret;
18776 }
18777
18778 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
18779         LDKChainMonitor this_arg_conv;
18780         this_arg_conv.inner = (void*)(this_arg & (~1));
18781         this_arg_conv.is_owned = false;
18782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18783         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
18784         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
18785         return (uintptr_t)ret_ret;
18786 }
18787
18788 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
18789         LDKChainMonitor this_arg_conv;
18790         this_arg_conv.inner = (void*)(this_arg & (~1));
18791         this_arg_conv.is_owned = false;
18792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18793         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
18794         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
18795         return (uintptr_t)ret_ret;
18796 }
18797
18798 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
18799         LDKChannelMonitorUpdate this_obj_conv;
18800         this_obj_conv.inner = (void*)(this_obj & (~1));
18801         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18803         ChannelMonitorUpdate_free(this_obj_conv);
18804 }
18805
18806 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
18807         LDKChannelMonitorUpdate this_ptr_conv;
18808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18809         this_ptr_conv.is_owned = false;
18810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18811         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
18812         return ret_val;
18813 }
18814
18815 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
18816         LDKChannelMonitorUpdate this_ptr_conv;
18817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18818         this_ptr_conv.is_owned = false;
18819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18820         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
18821 }
18822
18823 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
18824         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
18825 uintptr_t ret_ref = 0;
18826 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18827 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18828 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18829 ret_ref = (uintptr_t)ret_var.inner;
18830 if (ret_var.is_owned) {
18831         ret_ref |= 1;
18832 }
18833         return ret_ref;
18834 }
18835 intptr_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
18836         LDKChannelMonitorUpdate arg_conv;
18837         arg_conv.inner = (void*)(arg & (~1));
18838         arg_conv.is_owned = false;
18839         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18840         intptr_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
18841         return ret_val;
18842 }
18843
18844 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
18845         LDKChannelMonitorUpdate orig_conv;
18846         orig_conv.inner = (void*)(orig & (~1));
18847         orig_conv.is_owned = false;
18848         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18849         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
18850         uintptr_t ret_ref = 0;
18851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18854         ret_ref = (uintptr_t)ret_var.inner;
18855         if (ret_var.is_owned) {
18856                 ret_ref |= 1;
18857         }
18858         return ret_ref;
18859 }
18860
18861 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
18862         LDKChannelMonitorUpdate obj_conv;
18863         obj_conv.inner = (void*)(obj & (~1));
18864         obj_conv.is_owned = false;
18865         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
18866         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
18867         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
18868         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
18869         CVec_u8Z_free(ret_var);
18870         return ret_arr;
18871 }
18872
18873 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
18874         LDKu8slice ser_ref;
18875         ser_ref.datalen = ser->arr_len;
18876         ser_ref.data = ser->elems /* XXX ser leaks */;
18877         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
18878         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
18879         return (uintptr_t)ret_conv;
18880 }
18881
18882 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
18883         if ((this_ptr & 1) != 0) return;
18884         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18885         CHECK_ACCESS(this_ptr_ptr);
18886         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
18887         FREE((void*)this_ptr);
18888         MonitorEvent_free(this_ptr_conv);
18889 }
18890
18891 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
18892         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18893         *ret_copy = MonitorEvent_clone(arg);
18894 uintptr_t ret_ref = (uintptr_t)ret_copy;
18895         return ret_ref;
18896 }
18897 intptr_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
18898         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
18899         intptr_t ret_val = MonitorEvent_clone_ptr(arg_conv);
18900         return ret_val;
18901 }
18902
18903 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
18904         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
18905         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18906         *ret_copy = MonitorEvent_clone(orig_conv);
18907         uintptr_t ret_ref = (uintptr_t)ret_copy;
18908         return ret_ref;
18909 }
18910
18911 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
18912         LDKHTLCUpdate a_conv;
18913         a_conv.inner = (void*)(a & (~1));
18914         a_conv.is_owned = (a & 1) || (a == 0);
18915         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18916         a_conv = HTLCUpdate_clone(&a_conv);
18917         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18918         *ret_copy = MonitorEvent_htlcevent(a_conv);
18919         uintptr_t ret_ref = (uintptr_t)ret_copy;
18920         return ret_ref;
18921 }
18922
18923 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
18924         LDKOutPoint a_conv;
18925         a_conv.inner = (void*)(a & (~1));
18926         a_conv.is_owned = (a & 1) || (a == 0);
18927         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18928         a_conv = OutPoint_clone(&a_conv);
18929         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18930         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
18931         uintptr_t ret_ref = (uintptr_t)ret_copy;
18932         return ret_ref;
18933 }
18934
18935 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
18936         LDKOutPoint funding_txo_conv;
18937         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18938         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18939         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18940         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18941         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18942         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
18943         uintptr_t ret_ref = (uintptr_t)ret_copy;
18944         return ret_ref;
18945 }
18946
18947 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
18948         LDKOutPoint a_conv;
18949         a_conv.inner = (void*)(a & (~1));
18950         a_conv.is_owned = (a & 1) || (a == 0);
18951         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18952         a_conv = OutPoint_clone(&a_conv);
18953         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18954         *ret_copy = MonitorEvent_update_failed(a_conv);
18955         uintptr_t ret_ref = (uintptr_t)ret_copy;
18956         return ret_ref;
18957 }
18958
18959 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
18960         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
18961         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
18962         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
18963         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
18964         CVec_u8Z_free(ret_var);
18965         return ret_arr;
18966 }
18967
18968 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
18969         LDKu8slice ser_ref;
18970         ser_ref.datalen = ser->arr_len;
18971         ser_ref.data = ser->elems /* XXX ser leaks */;
18972         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
18973         *ret_conv = MonitorEvent_read(ser_ref);
18974         return (uintptr_t)ret_conv;
18975 }
18976
18977 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
18978         LDKHTLCUpdate this_obj_conv;
18979         this_obj_conv.inner = (void*)(this_obj & (~1));
18980         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18982         HTLCUpdate_free(this_obj_conv);
18983 }
18984
18985 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
18986         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
18987 uintptr_t ret_ref = 0;
18988 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18989 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18990 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18991 ret_ref = (uintptr_t)ret_var.inner;
18992 if (ret_var.is_owned) {
18993         ret_ref |= 1;
18994 }
18995         return ret_ref;
18996 }
18997 intptr_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
18998         LDKHTLCUpdate arg_conv;
18999         arg_conv.inner = (void*)(arg & (~1));
19000         arg_conv.is_owned = false;
19001         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19002         intptr_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
19003         return ret_val;
19004 }
19005
19006 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
19007         LDKHTLCUpdate orig_conv;
19008         orig_conv.inner = (void*)(orig & (~1));
19009         orig_conv.is_owned = false;
19010         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19011         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
19012         uintptr_t ret_ref = 0;
19013         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19014         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19016         ret_ref = (uintptr_t)ret_var.inner;
19017         if (ret_var.is_owned) {
19018                 ret_ref |= 1;
19019         }
19020         return ret_ref;
19021 }
19022
19023 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
19024         LDKHTLCUpdate obj_conv;
19025         obj_conv.inner = (void*)(obj & (~1));
19026         obj_conv.is_owned = false;
19027         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19028         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
19029         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19030         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19031         CVec_u8Z_free(ret_var);
19032         return ret_arr;
19033 }
19034
19035 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
19036         LDKu8slice ser_ref;
19037         ser_ref.datalen = ser->arr_len;
19038         ser_ref.data = ser->elems /* XXX ser leaks */;
19039         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19040         *ret_conv = HTLCUpdate_read(ser_ref);
19041         return (uintptr_t)ret_conv;
19042 }
19043
19044 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
19045         if ((this_ptr & 1) != 0) return;
19046         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19047         CHECK_ACCESS(this_ptr_ptr);
19048         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
19049         FREE((void*)this_ptr);
19050         Balance_free(this_ptr_conv);
19051 }
19052
19053 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
19054         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19055         *ret_copy = Balance_clone(arg);
19056 uintptr_t ret_ref = (uintptr_t)ret_copy;
19057         return ret_ref;
19058 }
19059 intptr_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
19060         LDKBalance* arg_conv = (LDKBalance*)arg;
19061         intptr_t ret_val = Balance_clone_ptr(arg_conv);
19062         return ret_val;
19063 }
19064
19065 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
19066         LDKBalance* orig_conv = (LDKBalance*)orig;
19067         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19068         *ret_copy = Balance_clone(orig_conv);
19069         uintptr_t ret_ref = (uintptr_t)ret_copy;
19070         return ret_ref;
19071 }
19072
19073 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
19074         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19075         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
19076         uintptr_t ret_ref = (uintptr_t)ret_copy;
19077         return ret_ref;
19078 }
19079
19080 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
19081         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19082         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
19083         uintptr_t ret_ref = (uintptr_t)ret_copy;
19084         return ret_ref;
19085 }
19086
19087 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
19088         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19089         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
19090         uintptr_t ret_ref = (uintptr_t)ret_copy;
19091         return ret_ref;
19092 }
19093
19094 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) {
19095         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19096         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
19097         uintptr_t ret_ref = (uintptr_t)ret_copy;
19098         return ret_ref;
19099 }
19100
19101 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
19102         LDKBalance* a_conv = (LDKBalance*)a;
19103         LDKBalance* b_conv = (LDKBalance*)b;
19104         jboolean ret_val = Balance_eq(a_conv, b_conv);
19105         return ret_val;
19106 }
19107
19108 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
19109         LDKChannelMonitor this_obj_conv;
19110         this_obj_conv.inner = (void*)(this_obj & (~1));
19111         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19113         ChannelMonitor_free(this_obj_conv);
19114 }
19115
19116 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
19117         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
19118 uintptr_t ret_ref = 0;
19119 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19120 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19121 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19122 ret_ref = (uintptr_t)ret_var.inner;
19123 if (ret_var.is_owned) {
19124         ret_ref |= 1;
19125 }
19126         return ret_ref;
19127 }
19128 intptr_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
19129         LDKChannelMonitor arg_conv;
19130         arg_conv.inner = (void*)(arg & (~1));
19131         arg_conv.is_owned = false;
19132         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19133         intptr_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
19134         return ret_val;
19135 }
19136
19137 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
19138         LDKChannelMonitor orig_conv;
19139         orig_conv.inner = (void*)(orig & (~1));
19140         orig_conv.is_owned = false;
19141         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19142         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
19143         uintptr_t ret_ref = 0;
19144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19147         ret_ref = (uintptr_t)ret_var.inner;
19148         if (ret_var.is_owned) {
19149                 ret_ref |= 1;
19150         }
19151         return ret_ref;
19152 }
19153
19154 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
19155         LDKChannelMonitor obj_conv;
19156         obj_conv.inner = (void*)(obj & (~1));
19157         obj_conv.is_owned = false;
19158         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19159         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
19160         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19161         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19162         CVec_u8Z_free(ret_var);
19163         return ret_arr;
19164 }
19165
19166 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) {
19167         LDKChannelMonitor this_arg_conv;
19168         this_arg_conv.inner = (void*)(this_arg & (~1));
19169         this_arg_conv.is_owned = false;
19170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19171         LDKChannelMonitorUpdate updates_conv;
19172         updates_conv.inner = (void*)(updates & (~1));
19173         updates_conv.is_owned = false;
19174         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
19175         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
19176         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
19177         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
19178         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
19179         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
19180         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
19181         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19182         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
19183         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
19184         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
19185         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
19186         return (uintptr_t)ret_conv;
19187 }
19188
19189 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
19190         LDKChannelMonitor this_arg_conv;
19191         this_arg_conv.inner = (void*)(this_arg & (~1));
19192         this_arg_conv.is_owned = false;
19193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19194         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
19195         return ret_val;
19196 }
19197
19198 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
19199         LDKChannelMonitor this_arg_conv;
19200         this_arg_conv.inner = (void*)(this_arg & (~1));
19201         this_arg_conv.is_owned = false;
19202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19203         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19204         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
19205         return ((uintptr_t)ret_conv);
19206 }
19207
19208 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
19209         LDKChannelMonitor this_arg_conv;
19210         this_arg_conv.inner = (void*)(this_arg & (~1));
19211         this_arg_conv.is_owned = false;
19212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19213         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
19214         uint32_tArray ret_arr = NULL;
19215         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19216         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19217         for (size_t o = 0; o < ret_var.datalen; o++) {
19218                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19219                 *ret_conv_40_conv = ret_var.data[o];
19220                 ret_arr_ptr[o] = ((uintptr_t)ret_conv_40_conv);
19221         }
19222         
19223         FREE(ret_var.data);
19224         return ret_arr;
19225 }
19226
19227 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
19228         LDKChannelMonitor this_arg_conv;
19229         this_arg_conv.inner = (void*)(this_arg & (~1));
19230         this_arg_conv.is_owned = false;
19231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19232         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
19233         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
19234         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
19235         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
19236 }
19237
19238 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) {
19239         LDKChannelMonitor this_arg_conv;
19240         this_arg_conv.inner = (void*)(this_arg & (~1));
19241         this_arg_conv.is_owned = false;
19242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19243         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
19244         uint32_tArray ret_arr = NULL;
19245         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19246         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19247         for (size_t o = 0; o < ret_var.datalen; o++) {
19248                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19249                 *ret_conv_14_copy = ret_var.data[o];
19250                 uintptr_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
19251                 ret_arr_ptr[o] = ret_conv_14_ref;
19252         }
19253         
19254         FREE(ret_var.data);
19255         return ret_arr;
19256 }
19257
19258 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
19259         LDKChannelMonitor this_arg_conv;
19260         this_arg_conv.inner = (void*)(this_arg & (~1));
19261         this_arg_conv.is_owned = false;
19262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19263         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
19264         uint32_tArray ret_arr = NULL;
19265         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19266         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19267         for (size_t h = 0; h < ret_var.datalen; h++) {
19268                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19269                 *ret_conv_7_copy = ret_var.data[h];
19270                 uintptr_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
19271                 ret_arr_ptr[h] = ret_conv_7_ref;
19272         }
19273         
19274         FREE(ret_var.data);
19275         return ret_arr;
19276 }
19277
19278 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) {
19279         LDKChannelMonitor this_arg_conv;
19280         this_arg_conv.inner = (void*)(this_arg & (~1));
19281         this_arg_conv.is_owned = false;
19282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19283         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19284         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
19285         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
19286         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
19287         ptrArray ret_arr = NULL;
19288         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
19289         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
19290         for (size_t m = 0; m < ret_var.datalen; m++) {
19291                 LDKTransaction ret_conv_12_var = ret_var.data[m];
19292                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
19293                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
19294                 Transaction_free(ret_conv_12_var);
19295                 ret_arr_ptr[m] = ret_conv_12_arr;
19296         }
19297         
19298         FREE(ret_var.data);
19299         return ret_arr;
19300 }
19301
19302 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) {
19303         LDKChannelMonitor this_arg_conv;
19304         this_arg_conv.inner = (void*)(this_arg & (~1));
19305         this_arg_conv.is_owned = false;
19306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19307         unsigned char header_arr[80];
19308         CHECK(header->arr_len == 80);
19309         memcpy(header_arr, header->elems, 80); FREE(header);
19310         unsigned char (*header_ref)[80] = &header_arr;
19311         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
19312         txdata_constr.datalen = txdata->arr_len;
19313         if (txdata_constr.datalen > 0)
19314                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
19315         else
19316                 txdata_constr.data = NULL;
19317         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
19318         for (size_t c = 0; c < txdata_constr.datalen; c++) {
19319                 uint32_t txdata_conv_28 = txdata_vals[c];
19320                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
19321                 CHECK_ACCESS(txdata_conv_28_ptr);
19322                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
19323                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
19324                 txdata_constr.data[c] = txdata_conv_28_conv;
19325         }
19326         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
19327         CHECK_ACCESS(broadcaster_ptr);
19328         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19329         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
19330         CHECK_ACCESS(fee_estimator_ptr);
19331         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19332         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19333         CHECK_ACCESS(logger_ptr);
19334         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19335         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);
19336         uint32_tArray ret_arr = NULL;
19337         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19338         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19339         for (size_t n = 0; n < ret_var.datalen; n++) {
19340                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19341                 *ret_conv_39_conv = ret_var.data[n];
19342                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
19343         }
19344         
19345         FREE(ret_var.data);
19346         return ret_arr;
19347 }
19348
19349 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) {
19350         LDKChannelMonitor this_arg_conv;
19351         this_arg_conv.inner = (void*)(this_arg & (~1));
19352         this_arg_conv.is_owned = false;
19353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19354         unsigned char header_arr[80];
19355         CHECK(header->arr_len == 80);
19356         memcpy(header_arr, header->elems, 80); FREE(header);
19357         unsigned char (*header_ref)[80] = &header_arr;
19358         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
19359         CHECK_ACCESS(broadcaster_ptr);
19360         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19361         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
19362         CHECK_ACCESS(fee_estimator_ptr);
19363         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19364         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19365         CHECK_ACCESS(logger_ptr);
19366         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19367         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
19368 }
19369
19370 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) {
19371         LDKChannelMonitor this_arg_conv;
19372         this_arg_conv.inner = (void*)(this_arg & (~1));
19373         this_arg_conv.is_owned = false;
19374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19375         unsigned char header_arr[80];
19376         CHECK(header->arr_len == 80);
19377         memcpy(header_arr, header->elems, 80); FREE(header);
19378         unsigned char (*header_ref)[80] = &header_arr;
19379         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
19380         txdata_constr.datalen = txdata->arr_len;
19381         if (txdata_constr.datalen > 0)
19382                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
19383         else
19384                 txdata_constr.data = NULL;
19385         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
19386         for (size_t c = 0; c < txdata_constr.datalen; c++) {
19387                 uint32_t txdata_conv_28 = txdata_vals[c];
19388                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
19389                 CHECK_ACCESS(txdata_conv_28_ptr);
19390                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
19391                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
19392                 txdata_constr.data[c] = txdata_conv_28_conv;
19393         }
19394         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
19395         CHECK_ACCESS(broadcaster_ptr);
19396         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19397         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
19398         CHECK_ACCESS(fee_estimator_ptr);
19399         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19400         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19401         CHECK_ACCESS(logger_ptr);
19402         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19403         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);
19404         uint32_tArray ret_arr = NULL;
19405         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19406         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19407         for (size_t n = 0; n < ret_var.datalen; n++) {
19408                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19409                 *ret_conv_39_conv = ret_var.data[n];
19410                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
19411         }
19412         
19413         FREE(ret_var.data);
19414         return ret_arr;
19415 }
19416
19417 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) {
19418         LDKChannelMonitor this_arg_conv;
19419         this_arg_conv.inner = (void*)(this_arg & (~1));
19420         this_arg_conv.is_owned = false;
19421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19422         unsigned char txid_arr[32];
19423         CHECK(txid->arr_len == 32);
19424         memcpy(txid_arr, txid->elems, 32); FREE(txid);
19425         unsigned char (*txid_ref)[32] = &txid_arr;
19426         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
19427         CHECK_ACCESS(broadcaster_ptr);
19428         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19429         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
19430         CHECK_ACCESS(fee_estimator_ptr);
19431         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19432         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19433         CHECK_ACCESS(logger_ptr);
19434         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19435         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
19436 }
19437
19438 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) {
19439         LDKChannelMonitor this_arg_conv;
19440         this_arg_conv.inner = (void*)(this_arg & (~1));
19441         this_arg_conv.is_owned = false;
19442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19443         unsigned char header_arr[80];
19444         CHECK(header->arr_len == 80);
19445         memcpy(header_arr, header->elems, 80); FREE(header);
19446         unsigned char (*header_ref)[80] = &header_arr;
19447         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
19448         CHECK_ACCESS(broadcaster_ptr);
19449         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19450         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
19451         CHECK_ACCESS(fee_estimator_ptr);
19452         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19453         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19454         CHECK_ACCESS(logger_ptr);
19455         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19456         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
19457         uint32_tArray ret_arr = NULL;
19458         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19459         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19460         for (size_t n = 0; n < ret_var.datalen; n++) {
19461                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19462                 *ret_conv_39_conv = ret_var.data[n];
19463                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
19464         }
19465         
19466         FREE(ret_var.data);
19467         return ret_arr;
19468 }
19469
19470 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
19471         LDKChannelMonitor this_arg_conv;
19472         this_arg_conv.inner = (void*)(this_arg & (~1));
19473         this_arg_conv.is_owned = false;
19474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19475         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
19476         ptrArray ret_arr = NULL;
19477         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
19478         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
19479         for (size_t m = 0; m < ret_var.datalen; m++) {
19480                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
19481                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
19482                 ret_arr_ptr[m] = ret_conv_12_arr;
19483         }
19484         
19485         FREE(ret_var.data);
19486         return ret_arr;
19487 }
19488
19489 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
19490         LDKChannelMonitor this_arg_conv;
19491         this_arg_conv.inner = (void*)(this_arg & (~1));
19492         this_arg_conv.is_owned = false;
19493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19494         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
19495         uintptr_t ret_ref = 0;
19496         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19497         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19499         ret_ref = (uintptr_t)ret_var.inner;
19500         if (ret_var.is_owned) {
19501                 ret_ref |= 1;
19502         }
19503         return ret_ref;
19504 }
19505
19506 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
19507         LDKChannelMonitor this_arg_conv;
19508         this_arg_conv.inner = (void*)(this_arg & (~1));
19509         this_arg_conv.is_owned = false;
19510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19511         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
19512         uint32_tArray ret_arr = NULL;
19513         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19514         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19515         for (size_t j = 0; j < ret_var.datalen; j++) {
19516                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19517                 *ret_conv_9_copy = ret_var.data[j];
19518                 uintptr_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
19519                 ret_arr_ptr[j] = ret_conv_9_ref;
19520         }
19521         
19522         FREE(ret_var.data);
19523         return ret_arr;
19524 }
19525
19526 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
19527         LDKu8slice ser_ref;
19528         ser_ref.datalen = ser->arr_len;
19529         ser_ref.data = ser->elems /* XXX ser leaks */;
19530         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
19531         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
19532         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
19533         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19534         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
19535         return (uintptr_t)ret_conv;
19536 }
19537
19538 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
19539         LDKOutPoint this_obj_conv;
19540         this_obj_conv.inner = (void*)(this_obj & (~1));
19541         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19543         OutPoint_free(this_obj_conv);
19544 }
19545
19546 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
19547         LDKOutPoint this_ptr_conv;
19548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19549         this_ptr_conv.is_owned = false;
19550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19551         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
19552         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
19553         return ret_arr;
19554 }
19555
19556 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
19557         LDKOutPoint this_ptr_conv;
19558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19559         this_ptr_conv.is_owned = false;
19560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19561         LDKThirtyTwoBytes val_ref;
19562         CHECK(val->arr_len == 32);
19563         memcpy(val_ref.data, val->elems, 32); FREE(val);
19564         OutPoint_set_txid(&this_ptr_conv, val_ref);
19565 }
19566
19567 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
19568         LDKOutPoint this_ptr_conv;
19569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19570         this_ptr_conv.is_owned = false;
19571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19572         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
19573         return ret_val;
19574 }
19575
19576 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
19577         LDKOutPoint this_ptr_conv;
19578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19579         this_ptr_conv.is_owned = false;
19580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19581         OutPoint_set_index(&this_ptr_conv, val);
19582 }
19583
19584 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
19585         LDKThirtyTwoBytes txid_arg_ref;
19586         CHECK(txid_arg->arr_len == 32);
19587         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
19588         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
19589         uintptr_t ret_ref = 0;
19590         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19591         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19593         ret_ref = (uintptr_t)ret_var.inner;
19594         if (ret_var.is_owned) {
19595                 ret_ref |= 1;
19596         }
19597         return ret_ref;
19598 }
19599
19600 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
19601         LDKOutPoint ret_var = OutPoint_clone(arg);
19602 uintptr_t ret_ref = 0;
19603 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19604 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19605 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19606 ret_ref = (uintptr_t)ret_var.inner;
19607 if (ret_var.is_owned) {
19608         ret_ref |= 1;
19609 }
19610         return ret_ref;
19611 }
19612 intptr_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
19613         LDKOutPoint arg_conv;
19614         arg_conv.inner = (void*)(arg & (~1));
19615         arg_conv.is_owned = false;
19616         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19617         intptr_t ret_val = OutPoint_clone_ptr(&arg_conv);
19618         return ret_val;
19619 }
19620
19621 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
19622         LDKOutPoint orig_conv;
19623         orig_conv.inner = (void*)(orig & (~1));
19624         orig_conv.is_owned = false;
19625         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19626         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
19627         uintptr_t ret_ref = 0;
19628         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19629         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19631         ret_ref = (uintptr_t)ret_var.inner;
19632         if (ret_var.is_owned) {
19633                 ret_ref |= 1;
19634         }
19635         return ret_ref;
19636 }
19637
19638 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
19639         LDKOutPoint a_conv;
19640         a_conv.inner = (void*)(a & (~1));
19641         a_conv.is_owned = false;
19642         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19643         LDKOutPoint b_conv;
19644         b_conv.inner = (void*)(b & (~1));
19645         b_conv.is_owned = false;
19646         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19647         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
19648         return ret_val;
19649 }
19650
19651 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
19652         LDKOutPoint o_conv;
19653         o_conv.inner = (void*)(o & (~1));
19654         o_conv.is_owned = false;
19655         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19656         int64_t ret_val = OutPoint_hash(&o_conv);
19657         return ret_val;
19658 }
19659
19660 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
19661         LDKOutPoint this_arg_conv;
19662         this_arg_conv.inner = (void*)(this_arg & (~1));
19663         this_arg_conv.is_owned = false;
19664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19665         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
19666         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
19667         return ret_arr;
19668 }
19669
19670 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
19671         LDKOutPoint obj_conv;
19672         obj_conv.inner = (void*)(obj & (~1));
19673         obj_conv.is_owned = false;
19674         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19675         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
19676         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19677         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19678         CVec_u8Z_free(ret_var);
19679         return ret_arr;
19680 }
19681
19682 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
19683         LDKu8slice ser_ref;
19684         ser_ref.datalen = ser->arr_len;
19685         ser_ref.data = ser->elems /* XXX ser leaks */;
19686         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19687         *ret_conv = OutPoint_read(ser_ref);
19688         return (uintptr_t)ret_conv;
19689 }
19690
19691 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
19692         LDKDelayedPaymentOutputDescriptor this_obj_conv;
19693         this_obj_conv.inner = (void*)(this_obj & (~1));
19694         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19696         DelayedPaymentOutputDescriptor_free(this_obj_conv);
19697 }
19698
19699 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
19700         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19702         this_ptr_conv.is_owned = false;
19703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19704         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
19705         uintptr_t ret_ref = 0;
19706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19709         ret_ref = (uintptr_t)ret_var.inner;
19710         if (ret_var.is_owned) {
19711                 ret_ref |= 1;
19712         }
19713         return ret_ref;
19714 }
19715
19716 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
19717         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19719         this_ptr_conv.is_owned = false;
19720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19721         LDKOutPoint val_conv;
19722         val_conv.inner = (void*)(val & (~1));
19723         val_conv.is_owned = (val & 1) || (val == 0);
19724         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
19725         val_conv = OutPoint_clone(&val_conv);
19726         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
19727 }
19728
19729 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
19730         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19732         this_ptr_conv.is_owned = false;
19733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19734         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
19735         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
19736         return ret_arr;
19737 }
19738
19739 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
19740         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19742         this_ptr_conv.is_owned = false;
19743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19744         LDKPublicKey val_ref;
19745         CHECK(val->arr_len == 33);
19746         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
19747         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
19748 }
19749
19750 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
19751         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19753         this_ptr_conv.is_owned = false;
19754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19755         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
19756         return ret_val;
19757 }
19758
19759 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
19760         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19762         this_ptr_conv.is_owned = false;
19763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19764         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
19765 }
19766
19767 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
19768         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19770         this_ptr_conv.is_owned = false;
19771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19772         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
19773         CHECK_ACCESS(val_ptr);
19774         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
19775         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
19776         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
19777 }
19778
19779 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
19780         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19782         this_ptr_conv.is_owned = false;
19783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19784         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
19785         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
19786         return ret_arr;
19787 }
19788
19789 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
19790         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19792         this_ptr_conv.is_owned = false;
19793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19794         LDKPublicKey val_ref;
19795         CHECK(val->arr_len == 33);
19796         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
19797         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
19798 }
19799
19800 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
19801         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19803         this_ptr_conv.is_owned = false;
19804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19805         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
19806         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
19807         return ret_arr;
19808 }
19809
19810 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
19811         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19813         this_ptr_conv.is_owned = false;
19814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19815         LDKThirtyTwoBytes val_ref;
19816         CHECK(val->arr_len == 32);
19817         memcpy(val_ref.data, val->elems, 32); FREE(val);
19818         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
19819 }
19820
19821 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
19822         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19824         this_ptr_conv.is_owned = false;
19825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19826         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
19827         return ret_val;
19828 }
19829
19830 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
19831         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19833         this_ptr_conv.is_owned = false;
19834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19835         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
19836 }
19837
19838 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) {
19839         LDKOutPoint outpoint_arg_conv;
19840         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
19841         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
19842         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
19843         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
19844         LDKPublicKey per_commitment_point_arg_ref;
19845         CHECK(per_commitment_point_arg->arr_len == 33);
19846         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
19847         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
19848         CHECK_ACCESS(output_arg_ptr);
19849         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
19850         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
19851         LDKPublicKey revocation_pubkey_arg_ref;
19852         CHECK(revocation_pubkey_arg->arr_len == 33);
19853         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
19854         LDKThirtyTwoBytes channel_keys_id_arg_ref;
19855         CHECK(channel_keys_id_arg->arr_len == 32);
19856         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
19857         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);
19858         uintptr_t ret_ref = 0;
19859         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19860         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19862         ret_ref = (uintptr_t)ret_var.inner;
19863         if (ret_var.is_owned) {
19864                 ret_ref |= 1;
19865         }
19866         return ret_ref;
19867 }
19868
19869 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
19870         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
19871 uintptr_t ret_ref = 0;
19872 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19873 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19874 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19875 ret_ref = (uintptr_t)ret_var.inner;
19876 if (ret_var.is_owned) {
19877         ret_ref |= 1;
19878 }
19879         return ret_ref;
19880 }
19881 intptr_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
19882         LDKDelayedPaymentOutputDescriptor arg_conv;
19883         arg_conv.inner = (void*)(arg & (~1));
19884         arg_conv.is_owned = false;
19885         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19886         intptr_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
19887         return ret_val;
19888 }
19889
19890 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
19891         LDKDelayedPaymentOutputDescriptor orig_conv;
19892         orig_conv.inner = (void*)(orig & (~1));
19893         orig_conv.is_owned = false;
19894         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19895         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
19896         uintptr_t ret_ref = 0;
19897         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19898         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19900         ret_ref = (uintptr_t)ret_var.inner;
19901         if (ret_var.is_owned) {
19902                 ret_ref |= 1;
19903         }
19904         return ret_ref;
19905 }
19906
19907 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
19908         LDKDelayedPaymentOutputDescriptor obj_conv;
19909         obj_conv.inner = (void*)(obj & (~1));
19910         obj_conv.is_owned = false;
19911         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19912         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
19913         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19914         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19915         CVec_u8Z_free(ret_var);
19916         return ret_arr;
19917 }
19918
19919 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
19920         LDKu8slice ser_ref;
19921         ser_ref.datalen = ser->arr_len;
19922         ser_ref.data = ser->elems /* XXX ser leaks */;
19923         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19924         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
19925         return (uintptr_t)ret_conv;
19926 }
19927
19928 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
19929         LDKStaticPaymentOutputDescriptor this_obj_conv;
19930         this_obj_conv.inner = (void*)(this_obj & (~1));
19931         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19933         StaticPaymentOutputDescriptor_free(this_obj_conv);
19934 }
19935
19936 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
19937         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19939         this_ptr_conv.is_owned = false;
19940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19941         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
19942         uintptr_t ret_ref = 0;
19943         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19944         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19946         ret_ref = (uintptr_t)ret_var.inner;
19947         if (ret_var.is_owned) {
19948                 ret_ref |= 1;
19949         }
19950         return ret_ref;
19951 }
19952
19953 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
19954         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19956         this_ptr_conv.is_owned = false;
19957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19958         LDKOutPoint val_conv;
19959         val_conv.inner = (void*)(val & (~1));
19960         val_conv.is_owned = (val & 1) || (val == 0);
19961         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
19962         val_conv = OutPoint_clone(&val_conv);
19963         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
19964 }
19965
19966 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
19967         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19969         this_ptr_conv.is_owned = false;
19970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19971         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
19972         CHECK_ACCESS(val_ptr);
19973         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
19974         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
19975         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
19976 }
19977
19978 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
19979         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19981         this_ptr_conv.is_owned = false;
19982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19983         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
19984         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
19985         return ret_arr;
19986 }
19987
19988 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
19989         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19991         this_ptr_conv.is_owned = false;
19992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19993         LDKThirtyTwoBytes val_ref;
19994         CHECK(val->arr_len == 32);
19995         memcpy(val_ref.data, val->elems, 32); FREE(val);
19996         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
19997 }
19998
19999 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
20000         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20002         this_ptr_conv.is_owned = false;
20003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20004         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
20005         return ret_val;
20006 }
20007
20008 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
20009         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20011         this_ptr_conv.is_owned = false;
20012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20013         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
20014 }
20015
20016 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) {
20017         LDKOutPoint outpoint_arg_conv;
20018         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
20019         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
20020         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
20021         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
20022         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
20023         CHECK_ACCESS(output_arg_ptr);
20024         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
20025         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
20026         LDKThirtyTwoBytes channel_keys_id_arg_ref;
20027         CHECK(channel_keys_id_arg->arr_len == 32);
20028         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
20029         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
20030         uintptr_t ret_ref = 0;
20031         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20032         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20034         ret_ref = (uintptr_t)ret_var.inner;
20035         if (ret_var.is_owned) {
20036                 ret_ref |= 1;
20037         }
20038         return ret_ref;
20039 }
20040
20041 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
20042         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
20043 uintptr_t ret_ref = 0;
20044 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20045 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20046 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20047 ret_ref = (uintptr_t)ret_var.inner;
20048 if (ret_var.is_owned) {
20049         ret_ref |= 1;
20050 }
20051         return ret_ref;
20052 }
20053 intptr_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
20054         LDKStaticPaymentOutputDescriptor arg_conv;
20055         arg_conv.inner = (void*)(arg & (~1));
20056         arg_conv.is_owned = false;
20057         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20058         intptr_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
20059         return ret_val;
20060 }
20061
20062 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
20063         LDKStaticPaymentOutputDescriptor orig_conv;
20064         orig_conv.inner = (void*)(orig & (~1));
20065         orig_conv.is_owned = false;
20066         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20067         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
20068         uintptr_t ret_ref = 0;
20069         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20070         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20072         ret_ref = (uintptr_t)ret_var.inner;
20073         if (ret_var.is_owned) {
20074                 ret_ref |= 1;
20075         }
20076         return ret_ref;
20077 }
20078
20079 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
20080         LDKStaticPaymentOutputDescriptor obj_conv;
20081         obj_conv.inner = (void*)(obj & (~1));
20082         obj_conv.is_owned = false;
20083         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20084         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
20085         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20086         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20087         CVec_u8Z_free(ret_var);
20088         return ret_arr;
20089 }
20090
20091 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
20092         LDKu8slice ser_ref;
20093         ser_ref.datalen = ser->arr_len;
20094         ser_ref.data = ser->elems /* XXX ser leaks */;
20095         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
20096         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
20097         return (uintptr_t)ret_conv;
20098 }
20099
20100 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
20101         if ((this_ptr & 1) != 0) return;
20102         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20103         CHECK_ACCESS(this_ptr_ptr);
20104         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
20105         FREE((void*)this_ptr);
20106         SpendableOutputDescriptor_free(this_ptr_conv);
20107 }
20108
20109 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
20110         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20111         *ret_copy = SpendableOutputDescriptor_clone(arg);
20112 uintptr_t ret_ref = (uintptr_t)ret_copy;
20113         return ret_ref;
20114 }
20115 intptr_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
20116         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
20117         intptr_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
20118         return ret_val;
20119 }
20120
20121 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
20122         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
20123         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20124         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
20125         uintptr_t ret_ref = (uintptr_t)ret_copy;
20126         return ret_ref;
20127 }
20128
20129 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
20130         LDKOutPoint outpoint_conv;
20131         outpoint_conv.inner = (void*)(outpoint & (~1));
20132         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
20133         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
20134         outpoint_conv = OutPoint_clone(&outpoint_conv);
20135         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
20136         CHECK_ACCESS(output_ptr);
20137         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
20138         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
20139         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20140         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
20141         uintptr_t ret_ref = (uintptr_t)ret_copy;
20142         return ret_ref;
20143 }
20144
20145 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
20146         LDKDelayedPaymentOutputDescriptor a_conv;
20147         a_conv.inner = (void*)(a & (~1));
20148         a_conv.is_owned = (a & 1) || (a == 0);
20149         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20150         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
20151         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20152         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
20153         uintptr_t ret_ref = (uintptr_t)ret_copy;
20154         return ret_ref;
20155 }
20156
20157 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
20158         LDKStaticPaymentOutputDescriptor a_conv;
20159         a_conv.inner = (void*)(a & (~1));
20160         a_conv.is_owned = (a & 1) || (a == 0);
20161         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20162         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
20163         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20164         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
20165         uintptr_t ret_ref = (uintptr_t)ret_copy;
20166         return ret_ref;
20167 }
20168
20169 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
20170         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
20171         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
20172         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20173         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20174         CVec_u8Z_free(ret_var);
20175         return ret_arr;
20176 }
20177
20178 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
20179         LDKu8slice ser_ref;
20180         ser_ref.datalen = ser->arr_len;
20181         ser_ref.data = ser->elems /* XXX ser leaks */;
20182         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20183         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
20184         return (uintptr_t)ret_conv;
20185 }
20186
20187 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
20188         if ((this_ptr & 1) != 0) return;
20189         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20190         CHECK_ACCESS(this_ptr_ptr);
20191         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
20192         FREE((void*)this_ptr);
20193         BaseSign_free(this_ptr_conv);
20194 }
20195
20196 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
20197         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20198         *ret_ret = Sign_clone(arg);
20199         return (uintptr_t)ret_ret;
20200 }
20201 intptr_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
20202         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
20203         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
20204         LDKSign* arg_conv = (LDKSign*)arg_ptr;
20205         intptr_t ret_val = Sign_clone_ptr(arg_conv);
20206         return ret_val;
20207 }
20208
20209 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
20210         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
20211         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
20212         LDKSign* orig_conv = (LDKSign*)orig_ptr;
20213         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20214         *ret_ret = Sign_clone(orig_conv);
20215         return (uintptr_t)ret_ret;
20216 }
20217
20218 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
20219         if ((this_ptr & 1) != 0) return;
20220         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20221         CHECK_ACCESS(this_ptr_ptr);
20222         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
20223         FREE((void*)this_ptr);
20224         Sign_free(this_ptr_conv);
20225 }
20226
20227 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
20228         if ((this_ptr & 1) != 0) return;
20229         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20230         CHECK_ACCESS(this_ptr_ptr);
20231         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
20232         FREE((void*)this_ptr);
20233         KeysInterface_free(this_ptr_conv);
20234 }
20235
20236 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
20237         LDKInMemorySigner this_obj_conv;
20238         this_obj_conv.inner = (void*)(this_obj & (~1));
20239         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20241         InMemorySigner_free(this_obj_conv);
20242 }
20243
20244 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
20245         LDKInMemorySigner this_ptr_conv;
20246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20247         this_ptr_conv.is_owned = false;
20248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20249         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
20250         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
20251         return ret_arr;
20252 }
20253
20254 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
20255         LDKInMemorySigner this_ptr_conv;
20256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20257         this_ptr_conv.is_owned = false;
20258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20259         LDKSecretKey val_ref;
20260         CHECK(val->arr_len == 32);
20261         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
20262         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
20263 }
20264
20265 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
20266         LDKInMemorySigner this_ptr_conv;
20267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20268         this_ptr_conv.is_owned = false;
20269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20270         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
20271         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
20272         return ret_arr;
20273 }
20274
20275 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
20276         LDKInMemorySigner this_ptr_conv;
20277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20278         this_ptr_conv.is_owned = false;
20279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20280         LDKSecretKey val_ref;
20281         CHECK(val->arr_len == 32);
20282         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
20283         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
20284 }
20285
20286 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
20287         LDKInMemorySigner this_ptr_conv;
20288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20289         this_ptr_conv.is_owned = false;
20290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20291         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
20292         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
20293         return ret_arr;
20294 }
20295
20296 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
20297         LDKInMemorySigner this_ptr_conv;
20298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20299         this_ptr_conv.is_owned = false;
20300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20301         LDKSecretKey val_ref;
20302         CHECK(val->arr_len == 32);
20303         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
20304         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
20305 }
20306
20307 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
20308         LDKInMemorySigner this_ptr_conv;
20309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20310         this_ptr_conv.is_owned = false;
20311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20312         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
20313         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
20314         return ret_arr;
20315 }
20316
20317 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) {
20318         LDKInMemorySigner this_ptr_conv;
20319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20320         this_ptr_conv.is_owned = false;
20321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20322         LDKSecretKey val_ref;
20323         CHECK(val->arr_len == 32);
20324         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
20325         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
20326 }
20327
20328 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
20329         LDKInMemorySigner this_ptr_conv;
20330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20331         this_ptr_conv.is_owned = false;
20332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20333         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
20334         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
20335         return ret_arr;
20336 }
20337
20338 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
20339         LDKInMemorySigner this_ptr_conv;
20340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20341         this_ptr_conv.is_owned = false;
20342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20343         LDKSecretKey val_ref;
20344         CHECK(val->arr_len == 32);
20345         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
20346         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
20347 }
20348
20349 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
20350         LDKInMemorySigner this_ptr_conv;
20351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20352         this_ptr_conv.is_owned = false;
20353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20354         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
20355         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
20356         return ret_arr;
20357 }
20358
20359 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
20360         LDKInMemorySigner this_ptr_conv;
20361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20362         this_ptr_conv.is_owned = false;
20363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20364         LDKThirtyTwoBytes val_ref;
20365         CHECK(val->arr_len == 32);
20366         memcpy(val_ref.data, val->elems, 32); FREE(val);
20367         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
20368 }
20369
20370 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
20371         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
20372 uintptr_t ret_ref = 0;
20373 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20374 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20375 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20376 ret_ref = (uintptr_t)ret_var.inner;
20377 if (ret_var.is_owned) {
20378         ret_ref |= 1;
20379 }
20380         return ret_ref;
20381 }
20382 intptr_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
20383         LDKInMemorySigner arg_conv;
20384         arg_conv.inner = (void*)(arg & (~1));
20385         arg_conv.is_owned = false;
20386         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20387         intptr_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
20388         return ret_val;
20389 }
20390
20391 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
20392         LDKInMemorySigner orig_conv;
20393         orig_conv.inner = (void*)(orig & (~1));
20394         orig_conv.is_owned = false;
20395         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20396         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
20397         uintptr_t ret_ref = 0;
20398         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20399         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20401         ret_ref = (uintptr_t)ret_var.inner;
20402         if (ret_var.is_owned) {
20403                 ret_ref |= 1;
20404         }
20405         return ret_ref;
20406 }
20407
20408 uint32_t  __attribute__((export_name("TS_InMemorySigner_new"))) TS_InMemorySigner_new(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) {
20409         LDKSecretKey funding_key_ref;
20410         CHECK(funding_key->arr_len == 32);
20411         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
20412         LDKSecretKey revocation_base_key_ref;
20413         CHECK(revocation_base_key->arr_len == 32);
20414         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
20415         LDKSecretKey payment_key_ref;
20416         CHECK(payment_key->arr_len == 32);
20417         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
20418         LDKSecretKey delayed_payment_base_key_ref;
20419         CHECK(delayed_payment_base_key->arr_len == 32);
20420         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
20421         LDKSecretKey htlc_base_key_ref;
20422         CHECK(htlc_base_key->arr_len == 32);
20423         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
20424         LDKThirtyTwoBytes commitment_seed_ref;
20425         CHECK(commitment_seed->arr_len == 32);
20426         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
20427         LDKThirtyTwoBytes channel_keys_id_ref;
20428         CHECK(channel_keys_id->arr_len == 32);
20429         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
20430         LDKInMemorySigner ret_var = InMemorySigner_new(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);
20431         uintptr_t ret_ref = 0;
20432         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20433         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20435         ret_ref = (uintptr_t)ret_var.inner;
20436         if (ret_var.is_owned) {
20437                 ret_ref |= 1;
20438         }
20439         return ret_ref;
20440 }
20441
20442 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
20443         LDKInMemorySigner this_arg_conv;
20444         this_arg_conv.inner = (void*)(this_arg & (~1));
20445         this_arg_conv.is_owned = false;
20446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20447         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
20448         uintptr_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
20459 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
20460         LDKInMemorySigner this_arg_conv;
20461         this_arg_conv.inner = (void*)(this_arg & (~1));
20462         this_arg_conv.is_owned = false;
20463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20464         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
20465         return ret_val;
20466 }
20467
20468 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
20469         LDKInMemorySigner this_arg_conv;
20470         this_arg_conv.inner = (void*)(this_arg & (~1));
20471         this_arg_conv.is_owned = false;
20472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20473         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
20474         return ret_val;
20475 }
20476
20477 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
20478         LDKInMemorySigner this_arg_conv;
20479         this_arg_conv.inner = (void*)(this_arg & (~1));
20480         this_arg_conv.is_owned = false;
20481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20482         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
20483         return ret_val;
20484 }
20485
20486 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
20487         LDKInMemorySigner this_arg_conv;
20488         this_arg_conv.inner = (void*)(this_arg & (~1));
20489         this_arg_conv.is_owned = false;
20490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20491         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
20492         uintptr_t ret_ref = 0;
20493         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20494         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20496         ret_ref = (uintptr_t)ret_var.inner;
20497         if (ret_var.is_owned) {
20498                 ret_ref |= 1;
20499         }
20500         return ret_ref;
20501 }
20502
20503 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
20504         LDKInMemorySigner this_arg_conv;
20505         this_arg_conv.inner = (void*)(this_arg & (~1));
20506         this_arg_conv.is_owned = false;
20507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20508         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
20509         uintptr_t ret_ref = 0;
20510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20513         ret_ref = (uintptr_t)ret_var.inner;
20514         if (ret_var.is_owned) {
20515                 ret_ref |= 1;
20516         }
20517         return ret_ref;
20518 }
20519
20520 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
20521         LDKInMemorySigner this_arg_conv;
20522         this_arg_conv.inner = (void*)(this_arg & (~1));
20523         this_arg_conv.is_owned = false;
20524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20525         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
20526         return ret_val;
20527 }
20528
20529 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, intptr_t input_idx, uint32_t descriptor) {
20530         LDKInMemorySigner this_arg_conv;
20531         this_arg_conv.inner = (void*)(this_arg & (~1));
20532         this_arg_conv.is_owned = false;
20533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20534         LDKTransaction spend_tx_ref;
20535         spend_tx_ref.datalen = spend_tx->arr_len;
20536         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
20537         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
20538         spend_tx_ref.data_is_owned = true;
20539         LDKStaticPaymentOutputDescriptor descriptor_conv;
20540         descriptor_conv.inner = (void*)(descriptor & (~1));
20541         descriptor_conv.is_owned = false;
20542         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
20543         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20544         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
20545         return (uintptr_t)ret_conv;
20546 }
20547
20548 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, intptr_t input_idx, uint32_t descriptor) {
20549         LDKInMemorySigner this_arg_conv;
20550         this_arg_conv.inner = (void*)(this_arg & (~1));
20551         this_arg_conv.is_owned = false;
20552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20553         LDKTransaction spend_tx_ref;
20554         spend_tx_ref.datalen = spend_tx->arr_len;
20555         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
20556         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
20557         spend_tx_ref.data_is_owned = true;
20558         LDKDelayedPaymentOutputDescriptor descriptor_conv;
20559         descriptor_conv.inner = (void*)(descriptor & (~1));
20560         descriptor_conv.is_owned = false;
20561         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
20562         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20563         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
20564         return (uintptr_t)ret_conv;
20565 }
20566
20567 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
20568         LDKInMemorySigner this_arg_conv;
20569         this_arg_conv.inner = (void*)(this_arg & (~1));
20570         this_arg_conv.is_owned = false;
20571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20572         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
20573         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
20574         return (uintptr_t)ret_ret;
20575 }
20576
20577 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
20578         LDKInMemorySigner this_arg_conv;
20579         this_arg_conv.inner = (void*)(this_arg & (~1));
20580         this_arg_conv.is_owned = false;
20581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20582         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20583         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
20584         return (uintptr_t)ret_ret;
20585 }
20586
20587 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
20588         LDKInMemorySigner obj_conv;
20589         obj_conv.inner = (void*)(obj & (~1));
20590         obj_conv.is_owned = false;
20591         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20592         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
20593         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20594         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20595         CVec_u8Z_free(ret_var);
20596         return ret_arr;
20597 }
20598
20599 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser) {
20600         LDKu8slice ser_ref;
20601         ser_ref.datalen = ser->arr_len;
20602         ser_ref.data = ser->elems /* XXX ser leaks */;
20603         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20604         *ret_conv = InMemorySigner_read(ser_ref);
20605         return (uintptr_t)ret_conv;
20606 }
20607
20608 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
20609         LDKKeysManager this_obj_conv;
20610         this_obj_conv.inner = (void*)(this_obj & (~1));
20611         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20613         KeysManager_free(this_obj_conv);
20614 }
20615
20616 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
20617         unsigned char seed_arr[32];
20618         CHECK(seed->arr_len == 32);
20619         memcpy(seed_arr, seed->elems, 32); FREE(seed);
20620         unsigned char (*seed_ref)[32] = &seed_arr;
20621         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
20622         uintptr_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 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) {
20634         LDKKeysManager this_arg_conv;
20635         this_arg_conv.inner = (void*)(this_arg & (~1));
20636         this_arg_conv.is_owned = false;
20637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20638         unsigned char params_arr[32];
20639         CHECK(params->arr_len == 32);
20640         memcpy(params_arr, params->elems, 32); FREE(params);
20641         unsigned char (*params_ref)[32] = &params_arr;
20642         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
20643         uintptr_t ret_ref = 0;
20644         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20645         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20647         ret_ref = (uintptr_t)ret_var.inner;
20648         if (ret_var.is_owned) {
20649                 ret_ref |= 1;
20650         }
20651         return ret_ref;
20652 }
20653
20654 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) {
20655         LDKKeysManager this_arg_conv;
20656         this_arg_conv.inner = (void*)(this_arg & (~1));
20657         this_arg_conv.is_owned = false;
20658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20659         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
20660         descriptors_constr.datalen = descriptors->arr_len;
20661         if (descriptors_constr.datalen > 0)
20662                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
20663         else
20664                 descriptors_constr.data = NULL;
20665         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
20666         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
20667                 uint32_t descriptors_conv_27 = descriptors_vals[b];
20668                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
20669                 CHECK_ACCESS(descriptors_conv_27_ptr);
20670                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
20671                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
20672                 descriptors_constr.data[b] = descriptors_conv_27_conv;
20673         }
20674         LDKCVec_TxOutZ outputs_constr;
20675         outputs_constr.datalen = outputs->arr_len;
20676         if (outputs_constr.datalen > 0)
20677                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
20678         else
20679                 outputs_constr.data = NULL;
20680         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
20681         for (size_t h = 0; h < outputs_constr.datalen; h++) {
20682                 uint32_t outputs_conv_7 = outputs_vals[h];
20683                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
20684                 CHECK_ACCESS(outputs_conv_7_ptr);
20685                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
20686                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
20687                 outputs_constr.data[h] = outputs_conv_7_conv;
20688         }
20689         LDKCVec_u8Z change_destination_script_ref;
20690         change_destination_script_ref.datalen = change_destination_script->arr_len;
20691         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
20692         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
20693         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20694         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
20695         return (uintptr_t)ret_conv;
20696 }
20697
20698 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
20699         LDKKeysManager this_arg_conv;
20700         this_arg_conv.inner = (void*)(this_arg & (~1));
20701         this_arg_conv.is_owned = false;
20702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20703         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
20704         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
20705         return (uintptr_t)ret_ret;
20706 }
20707
20708 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
20709         LDKChannelManager this_obj_conv;
20710         this_obj_conv.inner = (void*)(this_obj & (~1));
20711         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20713         ChannelManager_free(this_obj_conv);
20714 }
20715
20716 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
20717         LDKChainParameters this_obj_conv;
20718         this_obj_conv.inner = (void*)(this_obj & (~1));
20719         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20721         ChainParameters_free(this_obj_conv);
20722 }
20723
20724 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
20725         LDKChainParameters this_ptr_conv;
20726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20727         this_ptr_conv.is_owned = false;
20728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20729         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
20730         return ret_conv;
20731 }
20732
20733 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
20734         LDKChainParameters this_ptr_conv;
20735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20736         this_ptr_conv.is_owned = false;
20737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20738         LDKNetwork val_conv = LDKNetwork_from_js(val);
20739         ChainParameters_set_network(&this_ptr_conv, val_conv);
20740 }
20741
20742 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
20743         LDKChainParameters this_ptr_conv;
20744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20745         this_ptr_conv.is_owned = false;
20746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20747         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
20748         uintptr_t ret_ref = 0;
20749         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20750         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20752         ret_ref = (uintptr_t)ret_var.inner;
20753         if (ret_var.is_owned) {
20754                 ret_ref |= 1;
20755         }
20756         return ret_ref;
20757 }
20758
20759 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
20760         LDKChainParameters this_ptr_conv;
20761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20762         this_ptr_conv.is_owned = false;
20763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20764         LDKBestBlock val_conv;
20765         val_conv.inner = (void*)(val & (~1));
20766         val_conv.is_owned = (val & 1) || (val == 0);
20767         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20768         val_conv = BestBlock_clone(&val_conv);
20769         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
20770 }
20771
20772 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
20773         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
20774         LDKBestBlock best_block_arg_conv;
20775         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
20776         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
20777         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
20778         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
20779         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
20780         uintptr_t ret_ref = 0;
20781         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20782         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20784         ret_ref = (uintptr_t)ret_var.inner;
20785         if (ret_var.is_owned) {
20786                 ret_ref |= 1;
20787         }
20788         return ret_ref;
20789 }
20790
20791 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
20792         LDKChainParameters ret_var = ChainParameters_clone(arg);
20793 uintptr_t ret_ref = 0;
20794 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20795 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20796 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20797 ret_ref = (uintptr_t)ret_var.inner;
20798 if (ret_var.is_owned) {
20799         ret_ref |= 1;
20800 }
20801         return ret_ref;
20802 }
20803 intptr_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
20804         LDKChainParameters arg_conv;
20805         arg_conv.inner = (void*)(arg & (~1));
20806         arg_conv.is_owned = false;
20807         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20808         intptr_t ret_val = ChainParameters_clone_ptr(&arg_conv);
20809         return ret_val;
20810 }
20811
20812 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
20813         LDKChainParameters orig_conv;
20814         orig_conv.inner = (void*)(orig & (~1));
20815         orig_conv.is_owned = false;
20816         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20817         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
20818         uintptr_t ret_ref = 0;
20819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20822         ret_ref = (uintptr_t)ret_var.inner;
20823         if (ret_var.is_owned) {
20824                 ret_ref |= 1;
20825         }
20826         return ret_ref;
20827 }
20828
20829 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
20830         LDKCounterpartyForwardingInfo this_obj_conv;
20831         this_obj_conv.inner = (void*)(this_obj & (~1));
20832         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20834         CounterpartyForwardingInfo_free(this_obj_conv);
20835 }
20836
20837 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
20838         LDKCounterpartyForwardingInfo this_ptr_conv;
20839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20840         this_ptr_conv.is_owned = false;
20841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20842         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
20843         return ret_val;
20844 }
20845
20846 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
20847         LDKCounterpartyForwardingInfo this_ptr_conv;
20848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20849         this_ptr_conv.is_owned = false;
20850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20851         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
20852 }
20853
20854 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
20855         LDKCounterpartyForwardingInfo this_ptr_conv;
20856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20857         this_ptr_conv.is_owned = false;
20858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20859         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
20860         return ret_val;
20861 }
20862
20863 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
20864         LDKCounterpartyForwardingInfo this_ptr_conv;
20865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20866         this_ptr_conv.is_owned = false;
20867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20868         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
20869 }
20870
20871 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
20872         LDKCounterpartyForwardingInfo this_ptr_conv;
20873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20874         this_ptr_conv.is_owned = false;
20875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20876         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
20877         return ret_val;
20878 }
20879
20880 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20881         LDKCounterpartyForwardingInfo this_ptr_conv;
20882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20883         this_ptr_conv.is_owned = false;
20884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20885         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
20886 }
20887
20888 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) {
20889         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
20890         uintptr_t ret_ref = 0;
20891         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20892         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20894         ret_ref = (uintptr_t)ret_var.inner;
20895         if (ret_var.is_owned) {
20896                 ret_ref |= 1;
20897         }
20898         return ret_ref;
20899 }
20900
20901 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
20902         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
20903 uintptr_t ret_ref = 0;
20904 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20905 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20906 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20907 ret_ref = (uintptr_t)ret_var.inner;
20908 if (ret_var.is_owned) {
20909         ret_ref |= 1;
20910 }
20911         return ret_ref;
20912 }
20913 intptr_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
20914         LDKCounterpartyForwardingInfo arg_conv;
20915         arg_conv.inner = (void*)(arg & (~1));
20916         arg_conv.is_owned = false;
20917         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20918         intptr_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
20919         return ret_val;
20920 }
20921
20922 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
20923         LDKCounterpartyForwardingInfo orig_conv;
20924         orig_conv.inner = (void*)(orig & (~1));
20925         orig_conv.is_owned = false;
20926         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20927         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
20928         uintptr_t ret_ref = 0;
20929         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20930         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20932         ret_ref = (uintptr_t)ret_var.inner;
20933         if (ret_var.is_owned) {
20934                 ret_ref |= 1;
20935         }
20936         return ret_ref;
20937 }
20938
20939 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
20940         LDKChannelCounterparty this_obj_conv;
20941         this_obj_conv.inner = (void*)(this_obj & (~1));
20942         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20944         ChannelCounterparty_free(this_obj_conv);
20945 }
20946
20947 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
20948         LDKChannelCounterparty this_ptr_conv;
20949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20950         this_ptr_conv.is_owned = false;
20951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20952         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
20953         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
20954         return ret_arr;
20955 }
20956
20957 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
20958         LDKChannelCounterparty this_ptr_conv;
20959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20960         this_ptr_conv.is_owned = false;
20961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20962         LDKPublicKey val_ref;
20963         CHECK(val->arr_len == 33);
20964         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
20965         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
20966 }
20967
20968 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
20969         LDKChannelCounterparty this_ptr_conv;
20970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20971         this_ptr_conv.is_owned = false;
20972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20973         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
20974         uintptr_t ret_ref = 0;
20975         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20976         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20978         ret_ref = (uintptr_t)ret_var.inner;
20979         if (ret_var.is_owned) {
20980                 ret_ref |= 1;
20981         }
20982         return ret_ref;
20983 }
20984
20985 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
20986         LDKChannelCounterparty this_ptr_conv;
20987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20988         this_ptr_conv.is_owned = false;
20989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20990         LDKInitFeatures val_conv;
20991         val_conv.inner = (void*)(val & (~1));
20992         val_conv.is_owned = (val & 1) || (val == 0);
20993         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20994         val_conv = InitFeatures_clone(&val_conv);
20995         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
20996 }
20997
20998 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
20999         LDKChannelCounterparty this_ptr_conv;
21000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21001         this_ptr_conv.is_owned = false;
21002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21003         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
21004         return ret_val;
21005 }
21006
21007 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
21008         LDKChannelCounterparty this_ptr_conv;
21009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21010         this_ptr_conv.is_owned = false;
21011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21012         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
21013 }
21014
21015 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
21016         LDKChannelCounterparty this_ptr_conv;
21017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21018         this_ptr_conv.is_owned = false;
21019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21020         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
21021         uintptr_t ret_ref = 0;
21022         if ((uintptr_t)ret_var.inner > 4096) {
21023                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21024                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21026                 ret_ref = (uintptr_t)ret_var.inner;
21027                 if (ret_var.is_owned) {
21028                         ret_ref |= 1;
21029                 }
21030         }
21031         return ret_ref;
21032 }
21033
21034 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
21035         LDKChannelCounterparty this_ptr_conv;
21036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21037         this_ptr_conv.is_owned = false;
21038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21039         LDKCounterpartyForwardingInfo val_conv;
21040         val_conv.inner = (void*)(val & (~1));
21041         val_conv.is_owned = (val & 1) || (val == 0);
21042         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21043         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
21044         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
21045 }
21046
21047 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) {
21048         LDKPublicKey node_id_arg_ref;
21049         CHECK(node_id_arg->arr_len == 33);
21050         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
21051         LDKInitFeatures features_arg_conv;
21052         features_arg_conv.inner = (void*)(features_arg & (~1));
21053         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21054         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
21055         features_arg_conv = InitFeatures_clone(&features_arg_conv);
21056         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
21057         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
21058         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
21059         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
21060         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
21061         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
21062         uintptr_t ret_ref = 0;
21063         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21064         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21066         ret_ref = (uintptr_t)ret_var.inner;
21067         if (ret_var.is_owned) {
21068                 ret_ref |= 1;
21069         }
21070         return ret_ref;
21071 }
21072
21073 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
21074         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
21075 uintptr_t ret_ref = 0;
21076 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21077 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21078 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21079 ret_ref = (uintptr_t)ret_var.inner;
21080 if (ret_var.is_owned) {
21081         ret_ref |= 1;
21082 }
21083         return ret_ref;
21084 }
21085 intptr_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
21086         LDKChannelCounterparty arg_conv;
21087         arg_conv.inner = (void*)(arg & (~1));
21088         arg_conv.is_owned = false;
21089         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21090         intptr_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
21091         return ret_val;
21092 }
21093
21094 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
21095         LDKChannelCounterparty orig_conv;
21096         orig_conv.inner = (void*)(orig & (~1));
21097         orig_conv.is_owned = false;
21098         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21099         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
21100         uintptr_t ret_ref = 0;
21101         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21102         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21103         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21104         ret_ref = (uintptr_t)ret_var.inner;
21105         if (ret_var.is_owned) {
21106                 ret_ref |= 1;
21107         }
21108         return ret_ref;
21109 }
21110
21111 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
21112         LDKChannelDetails this_obj_conv;
21113         this_obj_conv.inner = (void*)(this_obj & (~1));
21114         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21116         ChannelDetails_free(this_obj_conv);
21117 }
21118
21119 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
21120         LDKChannelDetails this_ptr_conv;
21121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21122         this_ptr_conv.is_owned = false;
21123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21124         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21125         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
21126         return ret_arr;
21127 }
21128
21129 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
21130         LDKChannelDetails this_ptr_conv;
21131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21132         this_ptr_conv.is_owned = false;
21133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21134         LDKThirtyTwoBytes val_ref;
21135         CHECK(val->arr_len == 32);
21136         memcpy(val_ref.data, val->elems, 32); FREE(val);
21137         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
21138 }
21139
21140 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
21141         LDKChannelDetails this_ptr_conv;
21142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21143         this_ptr_conv.is_owned = false;
21144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21145         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
21146         uintptr_t ret_ref = 0;
21147         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21148         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21150         ret_ref = (uintptr_t)ret_var.inner;
21151         if (ret_var.is_owned) {
21152                 ret_ref |= 1;
21153         }
21154         return ret_ref;
21155 }
21156
21157 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
21158         LDKChannelDetails this_ptr_conv;
21159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21160         this_ptr_conv.is_owned = false;
21161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21162         LDKChannelCounterparty val_conv;
21163         val_conv.inner = (void*)(val & (~1));
21164         val_conv.is_owned = (val & 1) || (val == 0);
21165         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21166         val_conv = ChannelCounterparty_clone(&val_conv);
21167         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
21168 }
21169
21170 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
21171         LDKChannelDetails this_ptr_conv;
21172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21173         this_ptr_conv.is_owned = false;
21174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21175         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
21176         uintptr_t ret_ref = 0;
21177         if ((uintptr_t)ret_var.inner > 4096) {
21178                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21179                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21181                 ret_ref = (uintptr_t)ret_var.inner;
21182                 if (ret_var.is_owned) {
21183                         ret_ref |= 1;
21184                 }
21185         }
21186         return ret_ref;
21187 }
21188
21189 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
21190         LDKChannelDetails this_ptr_conv;
21191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21192         this_ptr_conv.is_owned = false;
21193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21194         LDKOutPoint val_conv;
21195         val_conv.inner = (void*)(val & (~1));
21196         val_conv.is_owned = (val & 1) || (val == 0);
21197         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21198         val_conv = OutPoint_clone(&val_conv);
21199         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
21200 }
21201
21202 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
21203         LDKChannelDetails this_ptr_conv;
21204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21205         this_ptr_conv.is_owned = false;
21206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21207         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21208         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
21209         uintptr_t ret_ref = (uintptr_t)ret_copy;
21210         return ret_ref;
21211 }
21212
21213 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
21214         LDKChannelDetails this_ptr_conv;
21215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21216         this_ptr_conv.is_owned = false;
21217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21218         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
21219         CHECK_ACCESS(val_ptr);
21220         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
21221         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
21222         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
21223 }
21224
21225 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
21226         LDKChannelDetails this_ptr_conv;
21227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21228         this_ptr_conv.is_owned = false;
21229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21230         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
21231         return ret_val;
21232 }
21233
21234 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
21235         LDKChannelDetails this_ptr_conv;
21236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21237         this_ptr_conv.is_owned = false;
21238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21239         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
21240 }
21241
21242 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
21243         LDKChannelDetails this_ptr_conv;
21244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21245         this_ptr_conv.is_owned = false;
21246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21247         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21248         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
21249         uintptr_t ret_ref = (uintptr_t)ret_copy;
21250         return ret_ref;
21251 }
21252
21253 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
21254         LDKChannelDetails this_ptr_conv;
21255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21256         this_ptr_conv.is_owned = false;
21257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21258         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
21259         CHECK_ACCESS(val_ptr);
21260         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
21261         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
21262         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
21263 }
21264
21265 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
21266         LDKChannelDetails this_ptr_conv;
21267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21268         this_ptr_conv.is_owned = false;
21269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21270         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
21271         return ret_val;
21272 }
21273
21274 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
21275         LDKChannelDetails this_ptr_conv;
21276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21277         this_ptr_conv.is_owned = false;
21278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21279         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
21280 }
21281
21282 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
21283         LDKChannelDetails this_ptr_conv;
21284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21285         this_ptr_conv.is_owned = false;
21286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21287         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
21288         return ret_val;
21289 }
21290
21291 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
21292         LDKChannelDetails this_ptr_conv;
21293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21294         this_ptr_conv.is_owned = false;
21295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21296         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
21297 }
21298
21299 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
21300         LDKChannelDetails this_ptr_conv;
21301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21302         this_ptr_conv.is_owned = false;
21303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21304         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
21305         return ret_val;
21306 }
21307
21308 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
21309         LDKChannelDetails this_ptr_conv;
21310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21311         this_ptr_conv.is_owned = false;
21312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21313         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
21314 }
21315
21316 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
21317         LDKChannelDetails this_ptr_conv;
21318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21319         this_ptr_conv.is_owned = false;
21320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21321         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
21322         return ret_val;
21323 }
21324
21325 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
21326         LDKChannelDetails this_ptr_conv;
21327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21328         this_ptr_conv.is_owned = false;
21329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21330         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
21331 }
21332
21333 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
21334         LDKChannelDetails this_ptr_conv;
21335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21336         this_ptr_conv.is_owned = false;
21337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21338         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
21339         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
21340         uintptr_t ret_ref = (uintptr_t)ret_copy;
21341         return ret_ref;
21342 }
21343
21344 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
21345         LDKChannelDetails this_ptr_conv;
21346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21347         this_ptr_conv.is_owned = false;
21348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21349         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
21350         CHECK_ACCESS(val_ptr);
21351         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
21352         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
21353         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
21354 }
21355
21356 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
21357         LDKChannelDetails this_ptr_conv;
21358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21359         this_ptr_conv.is_owned = false;
21360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21361         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21362         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
21363         uintptr_t ret_ref = (uintptr_t)ret_copy;
21364         return ret_ref;
21365 }
21366
21367 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) {
21368         LDKChannelDetails this_ptr_conv;
21369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21370         this_ptr_conv.is_owned = false;
21371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21372         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
21373         CHECK_ACCESS(val_ptr);
21374         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
21375         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
21376         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
21377 }
21378
21379 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
21380         LDKChannelDetails this_ptr_conv;
21381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21382         this_ptr_conv.is_owned = false;
21383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21384         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
21385         return ret_val;
21386 }
21387
21388 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
21389         LDKChannelDetails this_ptr_conv;
21390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21391         this_ptr_conv.is_owned = false;
21392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21393         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
21394 }
21395
21396 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_funding_locked"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
21397         LDKChannelDetails this_ptr_conv;
21398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21399         this_ptr_conv.is_owned = false;
21400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21401         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
21402         return ret_val;
21403 }
21404
21405 void  __attribute__((export_name("TS_ChannelDetails_set_is_funding_locked"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
21406         LDKChannelDetails this_ptr_conv;
21407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21408         this_ptr_conv.is_owned = false;
21409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21410         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
21411 }
21412
21413 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
21414         LDKChannelDetails this_ptr_conv;
21415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21416         this_ptr_conv.is_owned = false;
21417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21418         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
21419         return ret_val;
21420 }
21421
21422 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
21423         LDKChannelDetails this_ptr_conv;
21424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21425         this_ptr_conv.is_owned = false;
21426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21427         ChannelDetails_set_is_usable(&this_ptr_conv, val);
21428 }
21429
21430 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
21431         LDKChannelDetails this_ptr_conv;
21432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21433         this_ptr_conv.is_owned = false;
21434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21435         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
21436         return ret_val;
21437 }
21438
21439 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
21440         LDKChannelDetails this_ptr_conv;
21441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21442         this_ptr_conv.is_owned = false;
21443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21444         ChannelDetails_set_is_public(&this_ptr_conv, val);
21445 }
21446
21447 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 short_channel_id_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) {
21448         LDKThirtyTwoBytes channel_id_arg_ref;
21449         CHECK(channel_id_arg->arr_len == 32);
21450         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
21451         LDKChannelCounterparty counterparty_arg_conv;
21452         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
21453         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
21454         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
21455         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
21456         LDKOutPoint funding_txo_arg_conv;
21457         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
21458         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
21459         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
21460         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
21461         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
21462         CHECK_ACCESS(short_channel_id_arg_ptr);
21463         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
21464         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
21465         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
21466         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
21467         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
21468         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
21469         CHECK_ACCESS(confirmations_required_arg_ptr);
21470         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
21471         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
21472         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
21473         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
21474         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
21475         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
21476         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_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);
21477         uintptr_t ret_ref = 0;
21478         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21479         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21481         ret_ref = (uintptr_t)ret_var.inner;
21482         if (ret_var.is_owned) {
21483                 ret_ref |= 1;
21484         }
21485         return ret_ref;
21486 }
21487
21488 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
21489         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
21490 uintptr_t ret_ref = 0;
21491 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21492 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21493 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21494 ret_ref = (uintptr_t)ret_var.inner;
21495 if (ret_var.is_owned) {
21496         ret_ref |= 1;
21497 }
21498         return ret_ref;
21499 }
21500 intptr_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
21501         LDKChannelDetails arg_conv;
21502         arg_conv.inner = (void*)(arg & (~1));
21503         arg_conv.is_owned = false;
21504         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21505         intptr_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
21506         return ret_val;
21507 }
21508
21509 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
21510         LDKChannelDetails orig_conv;
21511         orig_conv.inner = (void*)(orig & (~1));
21512         orig_conv.is_owned = false;
21513         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21514         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
21515         uintptr_t ret_ref = 0;
21516         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21517         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21519         ret_ref = (uintptr_t)ret_var.inner;
21520         if (ret_var.is_owned) {
21521                 ret_ref |= 1;
21522         }
21523         return ret_ref;
21524 }
21525
21526 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
21527         if ((this_ptr & 1) != 0) return;
21528         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21529         CHECK_ACCESS(this_ptr_ptr);
21530         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
21531         FREE((void*)this_ptr);
21532         PaymentSendFailure_free(this_ptr_conv);
21533 }
21534
21535 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
21536         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21537         *ret_copy = PaymentSendFailure_clone(arg);
21538 uintptr_t ret_ref = (uintptr_t)ret_copy;
21539         return ret_ref;
21540 }
21541 intptr_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
21542         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
21543         intptr_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
21544         return ret_val;
21545 }
21546
21547 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
21548         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
21549         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21550         *ret_copy = PaymentSendFailure_clone(orig_conv);
21551         uintptr_t ret_ref = (uintptr_t)ret_copy;
21552         return ret_ref;
21553 }
21554
21555 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
21556         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
21557         CHECK_ACCESS(a_ptr);
21558         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
21559         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
21560         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21561         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
21562         uintptr_t ret_ref = (uintptr_t)ret_copy;
21563         return ret_ref;
21564 }
21565
21566 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
21567         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
21568         a_constr.datalen = a->arr_len;
21569         if (a_constr.datalen > 0)
21570                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
21571         else
21572                 a_constr.data = NULL;
21573         uint32_t* a_vals = a->elems /* XXX a leaks */;
21574         for (size_t w = 0; w < a_constr.datalen; w++) {
21575                 uint32_t a_conv_22 = a_vals[w];
21576                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
21577                 CHECK_ACCESS(a_conv_22_ptr);
21578                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
21579                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
21580                 a_constr.data[w] = a_conv_22_conv;
21581         }
21582         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21583         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
21584         uintptr_t ret_ref = (uintptr_t)ret_copy;
21585         return ret_ref;
21586 }
21587
21588 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
21589         LDKCVec_APIErrorZ a_constr;
21590         a_constr.datalen = a->arr_len;
21591         if (a_constr.datalen > 0)
21592                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
21593         else
21594                 a_constr.data = NULL;
21595         uint32_t* a_vals = a->elems /* XXX a leaks */;
21596         for (size_t k = 0; k < a_constr.datalen; k++) {
21597                 uint32_t a_conv_10 = a_vals[k];
21598                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
21599                 CHECK_ACCESS(a_conv_10_ptr);
21600                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
21601                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
21602                 a_constr.data[k] = a_conv_10_conv;
21603         }
21604         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21605         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
21606         uintptr_t ret_ref = (uintptr_t)ret_copy;
21607         return ret_ref;
21608 }
21609
21610 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) {
21611         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
21612         results_constr.datalen = results->arr_len;
21613         if (results_constr.datalen > 0)
21614                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
21615         else
21616                 results_constr.data = NULL;
21617         uint32_t* results_vals = results->elems /* XXX results leaks */;
21618         for (size_t w = 0; w < results_constr.datalen; w++) {
21619                 uint32_t results_conv_22 = results_vals[w];
21620                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
21621                 CHECK_ACCESS(results_conv_22_ptr);
21622                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
21623                 results_constr.data[w] = results_conv_22_conv;
21624         }
21625         LDKRouteParameters failed_paths_retry_conv;
21626         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
21627         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
21628         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
21629         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
21630         LDKThirtyTwoBytes payment_id_ref;
21631         CHECK(payment_id->arr_len == 32);
21632         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21633         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21634         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
21635         uintptr_t ret_ref = (uintptr_t)ret_copy;
21636         return ret_ref;
21637 }
21638
21639 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) {
21640         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
21641         CHECK_ACCESS(fee_est_ptr);
21642         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
21643         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
21644         CHECK_ACCESS(chain_monitor_ptr);
21645         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
21646         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
21647         CHECK_ACCESS(tx_broadcaster_ptr);
21648         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
21649         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
21650         CHECK_ACCESS(logger_ptr);
21651         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21652         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
21653         CHECK_ACCESS(keys_manager_ptr);
21654         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
21655         LDKUserConfig config_conv;
21656         config_conv.inner = (void*)(config & (~1));
21657         config_conv.is_owned = (config & 1) || (config == 0);
21658         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
21659         config_conv = UserConfig_clone(&config_conv);
21660         LDKChainParameters params_conv;
21661         params_conv.inner = (void*)(params & (~1));
21662         params_conv.is_owned = (params & 1) || (params == 0);
21663         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
21664         params_conv = ChainParameters_clone(&params_conv);
21665         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
21666         uintptr_t ret_ref = 0;
21667         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21668         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21670         ret_ref = (uintptr_t)ret_var.inner;
21671         if (ret_var.is_owned) {
21672                 ret_ref |= 1;
21673         }
21674         return ret_ref;
21675 }
21676
21677 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
21678         LDKChannelManager this_arg_conv;
21679         this_arg_conv.inner = (void*)(this_arg & (~1));
21680         this_arg_conv.is_owned = false;
21681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21682         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
21683         uintptr_t ret_ref = 0;
21684         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21685         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21687         ret_ref = (uintptr_t)ret_var.inner;
21688         if (ret_var.is_owned) {
21689                 ret_ref |= 1;
21690         }
21691         return ret_ref;
21692 }
21693
21694 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) {
21695         LDKChannelManager this_arg_conv;
21696         this_arg_conv.inner = (void*)(this_arg & (~1));
21697         this_arg_conv.is_owned = false;
21698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21699         LDKPublicKey their_network_key_ref;
21700         CHECK(their_network_key->arr_len == 33);
21701         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
21702         LDKUserConfig override_config_conv;
21703         override_config_conv.inner = (void*)(override_config & (~1));
21704         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
21705         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
21706         override_config_conv = UserConfig_clone(&override_config_conv);
21707         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21708         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
21709         return (uintptr_t)ret_conv;
21710 }
21711
21712 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
21713         LDKChannelManager this_arg_conv;
21714         this_arg_conv.inner = (void*)(this_arg & (~1));
21715         this_arg_conv.is_owned = false;
21716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21717         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
21718         uint32_tArray ret_arr = NULL;
21719         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21720         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21721         for (size_t q = 0; q < ret_var.datalen; q++) {
21722                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
21723                 uintptr_t ret_conv_16_ref = 0;
21724                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21725                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21726                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
21727                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
21728                 if (ret_conv_16_var.is_owned) {
21729                         ret_conv_16_ref |= 1;
21730                 }
21731                 ret_arr_ptr[q] = ret_conv_16_ref;
21732         }
21733         
21734         FREE(ret_var.data);
21735         return ret_arr;
21736 }
21737
21738 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
21739         LDKChannelManager this_arg_conv;
21740         this_arg_conv.inner = (void*)(this_arg & (~1));
21741         this_arg_conv.is_owned = false;
21742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21743         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
21744         uint32_tArray ret_arr = NULL;
21745         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21746         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21747         for (size_t q = 0; q < ret_var.datalen; q++) {
21748                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
21749                 uintptr_t ret_conv_16_ref = 0;
21750                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21751                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21752                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
21753                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
21754                 if (ret_conv_16_var.is_owned) {
21755                         ret_conv_16_ref |= 1;
21756                 }
21757                 ret_arr_ptr[q] = ret_conv_16_ref;
21758         }
21759         
21760         FREE(ret_var.data);
21761         return ret_arr;
21762 }
21763
21764 uint32_t  __attribute__((export_name("TS_ChannelManager_close_channel"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
21765         LDKChannelManager this_arg_conv;
21766         this_arg_conv.inner = (void*)(this_arg & (~1));
21767         this_arg_conv.is_owned = false;
21768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21769         unsigned char channel_id_arr[32];
21770         CHECK(channel_id->arr_len == 32);
21771         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
21772         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21773         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21774         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
21775         return (uintptr_t)ret_conv;
21776 }
21777
21778 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) {
21779         LDKChannelManager this_arg_conv;
21780         this_arg_conv.inner = (void*)(this_arg & (~1));
21781         this_arg_conv.is_owned = false;
21782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21783         unsigned char channel_id_arr[32];
21784         CHECK(channel_id->arr_len == 32);
21785         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
21786         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21787         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21788         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
21789         return (uintptr_t)ret_conv;
21790 }
21791
21792 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_channel"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
21793         LDKChannelManager this_arg_conv;
21794         this_arg_conv.inner = (void*)(this_arg & (~1));
21795         this_arg_conv.is_owned = false;
21796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21797         unsigned char channel_id_arr[32];
21798         CHECK(channel_id->arr_len == 32);
21799         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
21800         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21801         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21802         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
21803         return (uintptr_t)ret_conv;
21804 }
21805
21806 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
21807         LDKChannelManager this_arg_conv;
21808         this_arg_conv.inner = (void*)(this_arg & (~1));
21809         this_arg_conv.is_owned = false;
21810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21811         ChannelManager_force_close_all_channels(&this_arg_conv);
21812 }
21813
21814 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) {
21815         LDKChannelManager this_arg_conv;
21816         this_arg_conv.inner = (void*)(this_arg & (~1));
21817         this_arg_conv.is_owned = false;
21818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21819         LDKRoute route_conv;
21820         route_conv.inner = (void*)(route & (~1));
21821         route_conv.is_owned = false;
21822         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21823         LDKThirtyTwoBytes payment_hash_ref;
21824         CHECK(payment_hash->arr_len == 32);
21825         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21826         LDKThirtyTwoBytes payment_secret_ref;
21827         CHECK(payment_secret->arr_len == 32);
21828         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
21829         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
21830         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
21831         return (uintptr_t)ret_conv;
21832 }
21833
21834 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
21835         LDKChannelManager 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         LDKRoute route_conv;
21840         route_conv.inner = (void*)(route & (~1));
21841         route_conv.is_owned = false;
21842         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21843         LDKThirtyTwoBytes payment_id_ref;
21844         CHECK(payment_id->arr_len == 32);
21845         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21846         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21847         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
21848         return (uintptr_t)ret_conv;
21849 }
21850
21851 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
21852         LDKChannelManager this_arg_conv;
21853         this_arg_conv.inner = (void*)(this_arg & (~1));
21854         this_arg_conv.is_owned = false;
21855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21856         LDKThirtyTwoBytes payment_id_ref;
21857         CHECK(payment_id->arr_len == 32);
21858         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21859         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
21860 }
21861
21862 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) {
21863         LDKChannelManager this_arg_conv;
21864         this_arg_conv.inner = (void*)(this_arg & (~1));
21865         this_arg_conv.is_owned = false;
21866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21867         LDKRoute route_conv;
21868         route_conv.inner = (void*)(route & (~1));
21869         route_conv.is_owned = false;
21870         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21871         LDKThirtyTwoBytes payment_preimage_ref;
21872         CHECK(payment_preimage->arr_len == 32);
21873         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
21874         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21875         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
21876         return (uintptr_t)ret_conv;
21877 }
21878
21879 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) {
21880         LDKChannelManager this_arg_conv;
21881         this_arg_conv.inner = (void*)(this_arg & (~1));
21882         this_arg_conv.is_owned = false;
21883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21884         unsigned char temporary_channel_id_arr[32];
21885         CHECK(temporary_channel_id->arr_len == 32);
21886         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
21887         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
21888         LDKTransaction funding_transaction_ref;
21889         funding_transaction_ref.datalen = funding_transaction->arr_len;
21890         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
21891         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
21892         funding_transaction_ref.data_is_owned = true;
21893         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21894         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
21895         return (uintptr_t)ret_conv;
21896 }
21897
21898 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) {
21899         LDKChannelManager this_arg_conv;
21900         this_arg_conv.inner = (void*)(this_arg & (~1));
21901         this_arg_conv.is_owned = false;
21902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21903         LDKThreeBytes rgb_ref;
21904         CHECK(rgb->arr_len == 3);
21905         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
21906         LDKThirtyTwoBytes alias_ref;
21907         CHECK(alias->arr_len == 32);
21908         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
21909         LDKCVec_NetAddressZ addresses_constr;
21910         addresses_constr.datalen = addresses->arr_len;
21911         if (addresses_constr.datalen > 0)
21912                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21913         else
21914                 addresses_constr.data = NULL;
21915         uint32_t* addresses_vals = addresses->elems /* XXX addresses leaks */;
21916         for (size_t m = 0; m < addresses_constr.datalen; m++) {
21917                 uint32_t addresses_conv_12 = addresses_vals[m];
21918                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
21919                 CHECK_ACCESS(addresses_conv_12_ptr);
21920                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
21921                 addresses_constr.data[m] = addresses_conv_12_conv;
21922         }
21923         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
21924 }
21925
21926 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
21927         LDKChannelManager this_arg_conv;
21928         this_arg_conv.inner = (void*)(this_arg & (~1));
21929         this_arg_conv.is_owned = false;
21930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21931         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
21932 }
21933
21934 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
21935         LDKChannelManager this_arg_conv;
21936         this_arg_conv.inner = (void*)(this_arg & (~1));
21937         this_arg_conv.is_owned = false;
21938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21939         ChannelManager_timer_tick_occurred(&this_arg_conv);
21940 }
21941
21942 jboolean  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
21943         LDKChannelManager this_arg_conv;
21944         this_arg_conv.inner = (void*)(this_arg & (~1));
21945         this_arg_conv.is_owned = false;
21946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21947         unsigned char payment_hash_arr[32];
21948         CHECK(payment_hash->arr_len == 32);
21949         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
21950         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
21951         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
21952         return ret_val;
21953 }
21954
21955 jboolean  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
21956         LDKChannelManager this_arg_conv;
21957         this_arg_conv.inner = (void*)(this_arg & (~1));
21958         this_arg_conv.is_owned = false;
21959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21960         LDKThirtyTwoBytes payment_preimage_ref;
21961         CHECK(payment_preimage->arr_len == 32);
21962         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
21963         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
21964         return ret_val;
21965 }
21966
21967 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
21968         LDKChannelManager this_arg_conv;
21969         this_arg_conv.inner = (void*)(this_arg & (~1));
21970         this_arg_conv.is_owned = false;
21971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21972         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
21973         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
21974         return ret_arr;
21975 }
21976
21977 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) {
21978         LDKChannelManager this_arg_conv;
21979         this_arg_conv.inner = (void*)(this_arg & (~1));
21980         this_arg_conv.is_owned = false;
21981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21982         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
21983         CHECK_ACCESS(min_value_msat_ptr);
21984         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
21985         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
21986         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21987         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
21988         return (uintptr_t)ret_conv;
21989 }
21990
21991 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) {
21992         LDKChannelManager this_arg_conv;
21993         this_arg_conv.inner = (void*)(this_arg & (~1));
21994         this_arg_conv.is_owned = false;
21995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21996         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
21997         CHECK_ACCESS(min_value_msat_ptr);
21998         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
21999         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
22000         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
22001         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
22002         return (uintptr_t)ret_conv;
22003 }
22004
22005 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) {
22006         LDKChannelManager this_arg_conv;
22007         this_arg_conv.inner = (void*)(this_arg & (~1));
22008         this_arg_conv.is_owned = false;
22009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22010         LDKThirtyTwoBytes payment_hash_ref;
22011         CHECK(payment_hash->arr_len == 32);
22012         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
22013         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
22014         CHECK_ACCESS(min_value_msat_ptr);
22015         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
22016         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
22017         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22018         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
22019         return (uintptr_t)ret_conv;
22020 }
22021
22022 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) {
22023         LDKChannelManager this_arg_conv;
22024         this_arg_conv.inner = (void*)(this_arg & (~1));
22025         this_arg_conv.is_owned = false;
22026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22027         LDKThirtyTwoBytes payment_hash_ref;
22028         CHECK(payment_hash->arr_len == 32);
22029         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
22030         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
22031         CHECK_ACCESS(min_value_msat_ptr);
22032         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
22033         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
22034         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22035         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
22036         return (uintptr_t)ret_conv;
22037 }
22038
22039 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) {
22040         LDKChannelManager this_arg_conv;
22041         this_arg_conv.inner = (void*)(this_arg & (~1));
22042         this_arg_conv.is_owned = false;
22043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22044         LDKThirtyTwoBytes payment_hash_ref;
22045         CHECK(payment_hash->arr_len == 32);
22046         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
22047         LDKThirtyTwoBytes payment_secret_ref;
22048         CHECK(payment_secret->arr_len == 32);
22049         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
22050         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22051         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
22052         return (uintptr_t)ret_conv;
22053 }
22054
22055 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
22056         LDKChannelManager this_arg_conv;
22057         this_arg_conv.inner = (void*)(this_arg & (~1));
22058         this_arg_conv.is_owned = false;
22059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22060         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
22061         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
22062         return (uintptr_t)ret_ret;
22063 }
22064
22065 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
22066         LDKChannelManager this_arg_conv;
22067         this_arg_conv.inner = (void*)(this_arg & (~1));
22068         this_arg_conv.is_owned = false;
22069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22070         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
22071         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
22072         return (uintptr_t)ret_ret;
22073 }
22074
22075 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
22076         LDKChannelManager this_arg_conv;
22077         this_arg_conv.inner = (void*)(this_arg & (~1));
22078         this_arg_conv.is_owned = false;
22079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22080         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
22081         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
22082         return (uintptr_t)ret_ret;
22083 }
22084
22085 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
22086         LDKChannelManager this_arg_conv;
22087         this_arg_conv.inner = (void*)(this_arg & (~1));
22088         this_arg_conv.is_owned = false;
22089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22090         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
22091         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
22092         return (uintptr_t)ret_ret;
22093 }
22094
22095 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
22096         LDKChannelManager this_arg_conv;
22097         this_arg_conv.inner = (void*)(this_arg & (~1));
22098         this_arg_conv.is_owned = false;
22099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22100         ChannelManager_await_persistable_update(&this_arg_conv);
22101 }
22102
22103 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
22104         LDKChannelManager this_arg_conv;
22105         this_arg_conv.inner = (void*)(this_arg & (~1));
22106         this_arg_conv.is_owned = false;
22107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22108         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
22109         uintptr_t ret_ref = 0;
22110         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22111         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22113         ret_ref = (uintptr_t)ret_var.inner;
22114         if (ret_var.is_owned) {
22115                 ret_ref |= 1;
22116         }
22117         return ret_ref;
22118 }
22119
22120 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
22121         LDKChannelManager this_arg_conv;
22122         this_arg_conv.inner = (void*)(this_arg & (~1));
22123         this_arg_conv.is_owned = false;
22124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22125         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
22126         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
22127         return (uintptr_t)ret_ret;
22128 }
22129
22130 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
22131         LDKChannelManager obj_conv;
22132         obj_conv.inner = (void*)(obj & (~1));
22133         obj_conv.is_owned = false;
22134         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22135         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
22136         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22137         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22138         CVec_u8Z_free(ret_var);
22139         return ret_arr;
22140 }
22141
22142 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
22143         LDKChannelManagerReadArgs this_obj_conv;
22144         this_obj_conv.inner = (void*)(this_obj & (~1));
22145         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22147         ChannelManagerReadArgs_free(this_obj_conv);
22148 }
22149
22150 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
22151         LDKChannelManagerReadArgs this_ptr_conv;
22152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22153         this_ptr_conv.is_owned = false;
22154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22155         // WARNING: This object doesn't live past this scope, needs clone!
22156         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
22157         return ret_ret;
22158 }
22159
22160 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
22161         LDKChannelManagerReadArgs this_ptr_conv;
22162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22163         this_ptr_conv.is_owned = false;
22164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22165         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22166         CHECK_ACCESS(val_ptr);
22167         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
22168         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
22169 }
22170
22171 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
22172         LDKChannelManagerReadArgs this_ptr_conv;
22173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22174         this_ptr_conv.is_owned = false;
22175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22176         // WARNING: This object doesn't live past this scope, needs clone!
22177         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
22178         return ret_ret;
22179 }
22180
22181 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
22182         LDKChannelManagerReadArgs this_ptr_conv;
22183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22184         this_ptr_conv.is_owned = false;
22185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22186         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22187         CHECK_ACCESS(val_ptr);
22188         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
22189         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
22190 }
22191
22192 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
22193         LDKChannelManagerReadArgs this_ptr_conv;
22194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22195         this_ptr_conv.is_owned = false;
22196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22197         // WARNING: This object doesn't live past this scope, needs clone!
22198         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
22199         return ret_ret;
22200 }
22201
22202 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
22203         LDKChannelManagerReadArgs this_ptr_conv;
22204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22205         this_ptr_conv.is_owned = false;
22206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22207         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22208         CHECK_ACCESS(val_ptr);
22209         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
22210         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
22211 }
22212
22213 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
22214         LDKChannelManagerReadArgs this_ptr_conv;
22215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22216         this_ptr_conv.is_owned = false;
22217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22218         // WARNING: This object doesn't live past this scope, needs clone!
22219         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
22220         return ret_ret;
22221 }
22222
22223 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
22224         LDKChannelManagerReadArgs this_ptr_conv;
22225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22226         this_ptr_conv.is_owned = false;
22227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22228         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22229         CHECK_ACCESS(val_ptr);
22230         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
22231         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
22232 }
22233
22234 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
22235         LDKChannelManagerReadArgs this_ptr_conv;
22236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22237         this_ptr_conv.is_owned = false;
22238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22239         // WARNING: This object doesn't live past this scope, needs clone!
22240         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
22241         return ret_ret;
22242 }
22243
22244 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
22245         LDKChannelManagerReadArgs this_ptr_conv;
22246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22247         this_ptr_conv.is_owned = false;
22248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22249         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22250         CHECK_ACCESS(val_ptr);
22251         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
22252         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
22253 }
22254
22255 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
22256         LDKChannelManagerReadArgs this_ptr_conv;
22257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22258         this_ptr_conv.is_owned = false;
22259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22260         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
22261         uintptr_t ret_ref = 0;
22262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22265         ret_ref = (uintptr_t)ret_var.inner;
22266         if (ret_var.is_owned) {
22267                 ret_ref |= 1;
22268         }
22269         return ret_ref;
22270 }
22271
22272 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
22273         LDKChannelManagerReadArgs this_ptr_conv;
22274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22275         this_ptr_conv.is_owned = false;
22276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22277         LDKUserConfig val_conv;
22278         val_conv.inner = (void*)(val & (~1));
22279         val_conv.is_owned = (val & 1) || (val == 0);
22280         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22281         val_conv = UserConfig_clone(&val_conv);
22282         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
22283 }
22284
22285 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) {
22286         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
22287         CHECK_ACCESS(keys_manager_ptr);
22288         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
22289         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22290         CHECK_ACCESS(fee_estimator_ptr);
22291         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22292         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
22293         CHECK_ACCESS(chain_monitor_ptr);
22294         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
22295         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
22296         CHECK_ACCESS(tx_broadcaster_ptr);
22297         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
22298         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22299         CHECK_ACCESS(logger_ptr);
22300         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22301         LDKUserConfig default_config_conv;
22302         default_config_conv.inner = (void*)(default_config & (~1));
22303         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
22304         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
22305         default_config_conv = UserConfig_clone(&default_config_conv);
22306         LDKCVec_ChannelMonitorZ channel_monitors_constr;
22307         channel_monitors_constr.datalen = channel_monitors->arr_len;
22308         if (channel_monitors_constr.datalen > 0)
22309                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
22310         else
22311                 channel_monitors_constr.data = NULL;
22312         uint32_t* channel_monitors_vals = channel_monitors->elems /* XXX channel_monitors leaks */;
22313         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
22314                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
22315                 LDKChannelMonitor channel_monitors_conv_16_conv;
22316                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
22317                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
22318                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
22319                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
22320         }
22321         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);
22322         uintptr_t ret_ref = 0;
22323         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22324         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22326         ret_ref = (uintptr_t)ret_var.inner;
22327         if (ret_var.is_owned) {
22328                 ret_ref |= 1;
22329         }
22330         return ret_ref;
22331 }
22332
22333 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
22334         LDKu8slice ser_ref;
22335         ser_ref.datalen = ser->arr_len;
22336         ser_ref.data = ser->elems /* XXX ser leaks */;
22337         LDKChannelManagerReadArgs arg_conv;
22338         arg_conv.inner = (void*)(arg & (~1));
22339         arg_conv.is_owned = (arg & 1) || (arg == 0);
22340         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22341         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
22342         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
22343         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
22344         return (uintptr_t)ret_conv;
22345 }
22346
22347 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
22348         LDKDecodeError this_obj_conv;
22349         this_obj_conv.inner = (void*)(this_obj & (~1));
22350         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22352         DecodeError_free(this_obj_conv);
22353 }
22354
22355 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
22356         LDKDecodeError ret_var = DecodeError_clone(arg);
22357 uintptr_t ret_ref = 0;
22358 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22359 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22360 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22361 ret_ref = (uintptr_t)ret_var.inner;
22362 if (ret_var.is_owned) {
22363         ret_ref |= 1;
22364 }
22365         return ret_ref;
22366 }
22367 intptr_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
22368         LDKDecodeError arg_conv;
22369         arg_conv.inner = (void*)(arg & (~1));
22370         arg_conv.is_owned = false;
22371         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22372         intptr_t ret_val = DecodeError_clone_ptr(&arg_conv);
22373         return ret_val;
22374 }
22375
22376 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
22377         LDKDecodeError orig_conv;
22378         orig_conv.inner = (void*)(orig & (~1));
22379         orig_conv.is_owned = false;
22380         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22381         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
22382         uintptr_t ret_ref = 0;
22383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22386         ret_ref = (uintptr_t)ret_var.inner;
22387         if (ret_var.is_owned) {
22388                 ret_ref |= 1;
22389         }
22390         return ret_ref;
22391 }
22392
22393 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
22394         LDKInit this_obj_conv;
22395         this_obj_conv.inner = (void*)(this_obj & (~1));
22396         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22398         Init_free(this_obj_conv);
22399 }
22400
22401 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
22402         LDKInit this_ptr_conv;
22403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22404         this_ptr_conv.is_owned = false;
22405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22406         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
22407         uintptr_t ret_ref = 0;
22408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22411         ret_ref = (uintptr_t)ret_var.inner;
22412         if (ret_var.is_owned) {
22413                 ret_ref |= 1;
22414         }
22415         return ret_ref;
22416 }
22417
22418 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
22419         LDKInit this_ptr_conv;
22420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22421         this_ptr_conv.is_owned = false;
22422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22423         LDKInitFeatures val_conv;
22424         val_conv.inner = (void*)(val & (~1));
22425         val_conv.is_owned = (val & 1) || (val == 0);
22426         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22427         val_conv = InitFeatures_clone(&val_conv);
22428         Init_set_features(&this_ptr_conv, val_conv);
22429 }
22430
22431 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg) {
22432         LDKInitFeatures features_arg_conv;
22433         features_arg_conv.inner = (void*)(features_arg & (~1));
22434         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
22435         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
22436         features_arg_conv = InitFeatures_clone(&features_arg_conv);
22437         LDKInit ret_var = Init_new(features_arg_conv);
22438         uintptr_t ret_ref = 0;
22439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22442         ret_ref = (uintptr_t)ret_var.inner;
22443         if (ret_var.is_owned) {
22444                 ret_ref |= 1;
22445         }
22446         return ret_ref;
22447 }
22448
22449 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
22450         LDKInit ret_var = Init_clone(arg);
22451 uintptr_t ret_ref = 0;
22452 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22453 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22454 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22455 ret_ref = (uintptr_t)ret_var.inner;
22456 if (ret_var.is_owned) {
22457         ret_ref |= 1;
22458 }
22459         return ret_ref;
22460 }
22461 intptr_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
22462         LDKInit arg_conv;
22463         arg_conv.inner = (void*)(arg & (~1));
22464         arg_conv.is_owned = false;
22465         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22466         intptr_t ret_val = Init_clone_ptr(&arg_conv);
22467         return ret_val;
22468 }
22469
22470 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
22471         LDKInit orig_conv;
22472         orig_conv.inner = (void*)(orig & (~1));
22473         orig_conv.is_owned = false;
22474         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22475         LDKInit ret_var = Init_clone(&orig_conv);
22476         uintptr_t ret_ref = 0;
22477         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22478         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22480         ret_ref = (uintptr_t)ret_var.inner;
22481         if (ret_var.is_owned) {
22482                 ret_ref |= 1;
22483         }
22484         return ret_ref;
22485 }
22486
22487 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
22488         LDKErrorMessage this_obj_conv;
22489         this_obj_conv.inner = (void*)(this_obj & (~1));
22490         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22492         ErrorMessage_free(this_obj_conv);
22493 }
22494
22495 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
22496         LDKErrorMessage this_ptr_conv;
22497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22498         this_ptr_conv.is_owned = false;
22499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22500         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22501         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
22502         return ret_arr;
22503 }
22504
22505 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
22506         LDKErrorMessage this_ptr_conv;
22507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22508         this_ptr_conv.is_owned = false;
22509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22510         LDKThirtyTwoBytes val_ref;
22511         CHECK(val->arr_len == 32);
22512         memcpy(val_ref.data, val->elems, 32); FREE(val);
22513         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
22514 }
22515
22516 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
22517         LDKErrorMessage this_ptr_conv;
22518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22519         this_ptr_conv.is_owned = false;
22520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22521         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
22522         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22523         Str_free(ret_str);
22524         return ret_conv;
22525 }
22526
22527 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
22528         LDKErrorMessage this_ptr_conv;
22529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22530         this_ptr_conv.is_owned = false;
22531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22532         LDKStr val_conv = str_ref_to_owned_c(val);
22533         ErrorMessage_set_data(&this_ptr_conv, val_conv);
22534 }
22535
22536 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
22537         LDKThirtyTwoBytes channel_id_arg_ref;
22538         CHECK(channel_id_arg->arr_len == 32);
22539         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
22540         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
22541         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
22542         uintptr_t ret_ref = 0;
22543         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22544         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22546         ret_ref = (uintptr_t)ret_var.inner;
22547         if (ret_var.is_owned) {
22548                 ret_ref |= 1;
22549         }
22550         return ret_ref;
22551 }
22552
22553 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
22554         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
22555 uintptr_t ret_ref = 0;
22556 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22557 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22558 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22559 ret_ref = (uintptr_t)ret_var.inner;
22560 if (ret_var.is_owned) {
22561         ret_ref |= 1;
22562 }
22563         return ret_ref;
22564 }
22565 intptr_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
22566         LDKErrorMessage arg_conv;
22567         arg_conv.inner = (void*)(arg & (~1));
22568         arg_conv.is_owned = false;
22569         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22570         intptr_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
22571         return ret_val;
22572 }
22573
22574 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
22575         LDKErrorMessage orig_conv;
22576         orig_conv.inner = (void*)(orig & (~1));
22577         orig_conv.is_owned = false;
22578         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22579         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
22580         uintptr_t ret_ref = 0;
22581         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22582         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22584         ret_ref = (uintptr_t)ret_var.inner;
22585         if (ret_var.is_owned) {
22586                 ret_ref |= 1;
22587         }
22588         return ret_ref;
22589 }
22590
22591 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
22592         LDKPing this_obj_conv;
22593         this_obj_conv.inner = (void*)(this_obj & (~1));
22594         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22596         Ping_free(this_obj_conv);
22597 }
22598
22599 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
22600         LDKPing this_ptr_conv;
22601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22602         this_ptr_conv.is_owned = false;
22603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22604         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
22605         return ret_val;
22606 }
22607
22608 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
22609         LDKPing this_ptr_conv;
22610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22611         this_ptr_conv.is_owned = false;
22612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22613         Ping_set_ponglen(&this_ptr_conv, val);
22614 }
22615
22616 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
22617         LDKPing this_ptr_conv;
22618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22619         this_ptr_conv.is_owned = false;
22620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22621         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
22622         return ret_val;
22623 }
22624
22625 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
22626         LDKPing this_ptr_conv;
22627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22628         this_ptr_conv.is_owned = false;
22629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22630         Ping_set_byteslen(&this_ptr_conv, val);
22631 }
22632
22633 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
22634         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
22635         uintptr_t ret_ref = 0;
22636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22639         ret_ref = (uintptr_t)ret_var.inner;
22640         if (ret_var.is_owned) {
22641                 ret_ref |= 1;
22642         }
22643         return ret_ref;
22644 }
22645
22646 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
22647         LDKPing ret_var = Ping_clone(arg);
22648 uintptr_t ret_ref = 0;
22649 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22650 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22651 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22652 ret_ref = (uintptr_t)ret_var.inner;
22653 if (ret_var.is_owned) {
22654         ret_ref |= 1;
22655 }
22656         return ret_ref;
22657 }
22658 intptr_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
22659         LDKPing arg_conv;
22660         arg_conv.inner = (void*)(arg & (~1));
22661         arg_conv.is_owned = false;
22662         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22663         intptr_t ret_val = Ping_clone_ptr(&arg_conv);
22664         return ret_val;
22665 }
22666
22667 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
22668         LDKPing orig_conv;
22669         orig_conv.inner = (void*)(orig & (~1));
22670         orig_conv.is_owned = false;
22671         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22672         LDKPing ret_var = Ping_clone(&orig_conv);
22673         uintptr_t ret_ref = 0;
22674         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22675         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22677         ret_ref = (uintptr_t)ret_var.inner;
22678         if (ret_var.is_owned) {
22679                 ret_ref |= 1;
22680         }
22681         return ret_ref;
22682 }
22683
22684 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
22685         LDKPong this_obj_conv;
22686         this_obj_conv.inner = (void*)(this_obj & (~1));
22687         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22689         Pong_free(this_obj_conv);
22690 }
22691
22692 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
22693         LDKPong this_ptr_conv;
22694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22695         this_ptr_conv.is_owned = false;
22696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22697         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
22698         return ret_val;
22699 }
22700
22701 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
22702         LDKPong this_ptr_conv;
22703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22704         this_ptr_conv.is_owned = false;
22705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22706         Pong_set_byteslen(&this_ptr_conv, val);
22707 }
22708
22709 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
22710         LDKPong ret_var = Pong_new(byteslen_arg);
22711         uintptr_t ret_ref = 0;
22712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22715         ret_ref = (uintptr_t)ret_var.inner;
22716         if (ret_var.is_owned) {
22717                 ret_ref |= 1;
22718         }
22719         return ret_ref;
22720 }
22721
22722 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
22723         LDKPong ret_var = Pong_clone(arg);
22724 uintptr_t ret_ref = 0;
22725 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22726 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22727 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22728 ret_ref = (uintptr_t)ret_var.inner;
22729 if (ret_var.is_owned) {
22730         ret_ref |= 1;
22731 }
22732         return ret_ref;
22733 }
22734 intptr_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
22735         LDKPong arg_conv;
22736         arg_conv.inner = (void*)(arg & (~1));
22737         arg_conv.is_owned = false;
22738         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22739         intptr_t ret_val = Pong_clone_ptr(&arg_conv);
22740         return ret_val;
22741 }
22742
22743 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
22744         LDKPong orig_conv;
22745         orig_conv.inner = (void*)(orig & (~1));
22746         orig_conv.is_owned = false;
22747         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22748         LDKPong ret_var = Pong_clone(&orig_conv);
22749         uintptr_t ret_ref = 0;
22750         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22751         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22753         ret_ref = (uintptr_t)ret_var.inner;
22754         if (ret_var.is_owned) {
22755                 ret_ref |= 1;
22756         }
22757         return ret_ref;
22758 }
22759
22760 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
22761         LDKOpenChannel this_obj_conv;
22762         this_obj_conv.inner = (void*)(this_obj & (~1));
22763         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22765         OpenChannel_free(this_obj_conv);
22766 }
22767
22768 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
22769         LDKOpenChannel this_ptr_conv;
22770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22771         this_ptr_conv.is_owned = false;
22772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22773         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22774         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
22775         return ret_arr;
22776 }
22777
22778 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
22779         LDKOpenChannel this_ptr_conv;
22780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22781         this_ptr_conv.is_owned = false;
22782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22783         LDKThirtyTwoBytes val_ref;
22784         CHECK(val->arr_len == 32);
22785         memcpy(val_ref.data, val->elems, 32); FREE(val);
22786         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
22787 }
22788
22789 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
22790         LDKOpenChannel this_ptr_conv;
22791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22792         this_ptr_conv.is_owned = false;
22793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22794         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22795         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
22796         return ret_arr;
22797 }
22798
22799 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
22800         LDKOpenChannel this_ptr_conv;
22801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22802         this_ptr_conv.is_owned = false;
22803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22804         LDKThirtyTwoBytes val_ref;
22805         CHECK(val->arr_len == 32);
22806         memcpy(val_ref.data, val->elems, 32); FREE(val);
22807         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
22808 }
22809
22810 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
22811         LDKOpenChannel this_ptr_conv;
22812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22813         this_ptr_conv.is_owned = false;
22814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22815         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
22816         return ret_val;
22817 }
22818
22819 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
22820         LDKOpenChannel this_ptr_conv;
22821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22822         this_ptr_conv.is_owned = false;
22823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22824         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
22825 }
22826
22827 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
22828         LDKOpenChannel this_ptr_conv;
22829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22830         this_ptr_conv.is_owned = false;
22831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22832         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
22833         return ret_val;
22834 }
22835
22836 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
22837         LDKOpenChannel this_ptr_conv;
22838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22839         this_ptr_conv.is_owned = false;
22840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22841         OpenChannel_set_push_msat(&this_ptr_conv, val);
22842 }
22843
22844 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
22845         LDKOpenChannel this_ptr_conv;
22846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22847         this_ptr_conv.is_owned = false;
22848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22849         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
22850         return ret_val;
22851 }
22852
22853 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
22854         LDKOpenChannel this_ptr_conv;
22855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22856         this_ptr_conv.is_owned = false;
22857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22858         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
22859 }
22860
22861 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) {
22862         LDKOpenChannel this_ptr_conv;
22863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22864         this_ptr_conv.is_owned = false;
22865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22866         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
22867         return ret_val;
22868 }
22869
22870 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) {
22871         LDKOpenChannel this_ptr_conv;
22872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22873         this_ptr_conv.is_owned = false;
22874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22875         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
22876 }
22877
22878 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
22879         LDKOpenChannel this_ptr_conv;
22880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22881         this_ptr_conv.is_owned = false;
22882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22883         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
22884         return ret_val;
22885 }
22886
22887 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
22888         LDKOpenChannel this_ptr_conv;
22889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22890         this_ptr_conv.is_owned = false;
22891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22892         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
22893 }
22894
22895 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
22896         LDKOpenChannel this_ptr_conv;
22897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22898         this_ptr_conv.is_owned = false;
22899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22900         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
22901         return ret_val;
22902 }
22903
22904 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
22905         LDKOpenChannel this_ptr_conv;
22906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22907         this_ptr_conv.is_owned = false;
22908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22909         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
22910 }
22911
22912 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
22913         LDKOpenChannel this_ptr_conv;
22914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22915         this_ptr_conv.is_owned = false;
22916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22917         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
22918         return ret_val;
22919 }
22920
22921 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
22922         LDKOpenChannel this_ptr_conv;
22923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22924         this_ptr_conv.is_owned = false;
22925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22926         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
22927 }
22928
22929 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
22930         LDKOpenChannel this_ptr_conv;
22931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22932         this_ptr_conv.is_owned = false;
22933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22934         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
22935         return ret_val;
22936 }
22937
22938 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
22939         LDKOpenChannel this_ptr_conv;
22940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22941         this_ptr_conv.is_owned = false;
22942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22943         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
22944 }
22945
22946 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
22947         LDKOpenChannel this_ptr_conv;
22948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22949         this_ptr_conv.is_owned = false;
22950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22951         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
22952         return ret_val;
22953 }
22954
22955 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
22956         LDKOpenChannel this_ptr_conv;
22957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22958         this_ptr_conv.is_owned = false;
22959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22960         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
22961 }
22962
22963 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
22964         LDKOpenChannel this_ptr_conv;
22965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22966         this_ptr_conv.is_owned = false;
22967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22968         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22969         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
22970         return ret_arr;
22971 }
22972
22973 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
22974         LDKOpenChannel this_ptr_conv;
22975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22976         this_ptr_conv.is_owned = false;
22977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22978         LDKPublicKey val_ref;
22979         CHECK(val->arr_len == 33);
22980         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
22981         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
22982 }
22983
22984 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
22985         LDKOpenChannel this_ptr_conv;
22986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22987         this_ptr_conv.is_owned = false;
22988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22989         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22990         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
22991         return ret_arr;
22992 }
22993
22994 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
22995         LDKOpenChannel this_ptr_conv;
22996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22997         this_ptr_conv.is_owned = false;
22998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22999         LDKPublicKey val_ref;
23000         CHECK(val->arr_len == 33);
23001         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23002         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
23003 }
23004
23005 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
23006         LDKOpenChannel this_ptr_conv;
23007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23008         this_ptr_conv.is_owned = false;
23009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23010         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23011         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
23012         return ret_arr;
23013 }
23014
23015 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
23016         LDKOpenChannel this_ptr_conv;
23017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23018         this_ptr_conv.is_owned = false;
23019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23020         LDKPublicKey val_ref;
23021         CHECK(val->arr_len == 33);
23022         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23023         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
23024 }
23025
23026 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
23027         LDKOpenChannel this_ptr_conv;
23028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23029         this_ptr_conv.is_owned = false;
23030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23031         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23032         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
23033         return ret_arr;
23034 }
23035
23036 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
23037         LDKOpenChannel this_ptr_conv;
23038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23039         this_ptr_conv.is_owned = false;
23040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23041         LDKPublicKey val_ref;
23042         CHECK(val->arr_len == 33);
23043         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23044         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
23045 }
23046
23047 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
23048         LDKOpenChannel this_ptr_conv;
23049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23050         this_ptr_conv.is_owned = false;
23051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23052         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23053         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
23054         return ret_arr;
23055 }
23056
23057 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
23058         LDKOpenChannel this_ptr_conv;
23059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23060         this_ptr_conv.is_owned = false;
23061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23062         LDKPublicKey val_ref;
23063         CHECK(val->arr_len == 33);
23064         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23065         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
23066 }
23067
23068 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
23069         LDKOpenChannel this_ptr_conv;
23070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23071         this_ptr_conv.is_owned = false;
23072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23073         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23074         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23075         return ret_arr;
23076 }
23077
23078 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) {
23079         LDKOpenChannel this_ptr_conv;
23080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23081         this_ptr_conv.is_owned = false;
23082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23083         LDKPublicKey val_ref;
23084         CHECK(val->arr_len == 33);
23085         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23086         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
23087 }
23088
23089 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
23090         LDKOpenChannel this_ptr_conv;
23091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23092         this_ptr_conv.is_owned = false;
23093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23094         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
23095         return ret_val;
23096 }
23097
23098 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
23099         LDKOpenChannel this_ptr_conv;
23100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23101         this_ptr_conv.is_owned = false;
23102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23103         OpenChannel_set_channel_flags(&this_ptr_conv, val);
23104 }
23105
23106 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
23107         LDKOpenChannel this_ptr_conv;
23108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23109         this_ptr_conv.is_owned = false;
23110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23111         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
23112         uintptr_t ret_ref = 0;
23113         if ((uintptr_t)ret_var.inner > 4096) {
23114                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23115                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23117                 ret_ref = (uintptr_t)ret_var.inner;
23118                 if (ret_var.is_owned) {
23119                         ret_ref |= 1;
23120                 }
23121         }
23122         return ret_ref;
23123 }
23124
23125 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
23126         LDKOpenChannel this_ptr_conv;
23127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23128         this_ptr_conv.is_owned = false;
23129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23130         LDKChannelTypeFeatures val_conv;
23131         val_conv.inner = (void*)(val & (~1));
23132         val_conv.is_owned = (val & 1) || (val == 0);
23133         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23134         val_conv = ChannelTypeFeatures_clone(&val_conv);
23135         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
23136 }
23137
23138 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
23139         LDKOpenChannel ret_var = OpenChannel_clone(arg);
23140 uintptr_t ret_ref = 0;
23141 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23142 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23143 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23144 ret_ref = (uintptr_t)ret_var.inner;
23145 if (ret_var.is_owned) {
23146         ret_ref |= 1;
23147 }
23148         return ret_ref;
23149 }
23150 intptr_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
23151         LDKOpenChannel arg_conv;
23152         arg_conv.inner = (void*)(arg & (~1));
23153         arg_conv.is_owned = false;
23154         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23155         intptr_t ret_val = OpenChannel_clone_ptr(&arg_conv);
23156         return ret_val;
23157 }
23158
23159 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
23160         LDKOpenChannel orig_conv;
23161         orig_conv.inner = (void*)(orig & (~1));
23162         orig_conv.is_owned = false;
23163         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23164         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
23165         uintptr_t ret_ref = 0;
23166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23169         ret_ref = (uintptr_t)ret_var.inner;
23170         if (ret_var.is_owned) {
23171                 ret_ref |= 1;
23172         }
23173         return ret_ref;
23174 }
23175
23176 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
23177         LDKAcceptChannel this_obj_conv;
23178         this_obj_conv.inner = (void*)(this_obj & (~1));
23179         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23181         AcceptChannel_free(this_obj_conv);
23182 }
23183
23184 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
23185         LDKAcceptChannel this_ptr_conv;
23186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23187         this_ptr_conv.is_owned = false;
23188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23189         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23190         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
23191         return ret_arr;
23192 }
23193
23194 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
23195         LDKAcceptChannel this_ptr_conv;
23196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23197         this_ptr_conv.is_owned = false;
23198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23199         LDKThirtyTwoBytes val_ref;
23200         CHECK(val->arr_len == 32);
23201         memcpy(val_ref.data, val->elems, 32); FREE(val);
23202         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
23203 }
23204
23205 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
23206         LDKAcceptChannel 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         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
23211         return ret_val;
23212 }
23213
23214 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
23215         LDKAcceptChannel this_ptr_conv;
23216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23217         this_ptr_conv.is_owned = false;
23218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23219         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
23220 }
23221
23222 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) {
23223         LDKAcceptChannel this_ptr_conv;
23224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23225         this_ptr_conv.is_owned = false;
23226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23227         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
23228         return ret_val;
23229 }
23230
23231 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) {
23232         LDKAcceptChannel this_ptr_conv;
23233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23234         this_ptr_conv.is_owned = false;
23235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23236         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
23237 }
23238
23239 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
23240         LDKAcceptChannel this_ptr_conv;
23241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23242         this_ptr_conv.is_owned = false;
23243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23244         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
23245         return ret_val;
23246 }
23247
23248 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
23249         LDKAcceptChannel this_ptr_conv;
23250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23251         this_ptr_conv.is_owned = false;
23252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23253         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
23254 }
23255
23256 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
23257         LDKAcceptChannel this_ptr_conv;
23258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23259         this_ptr_conv.is_owned = false;
23260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23261         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
23262         return ret_val;
23263 }
23264
23265 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
23266         LDKAcceptChannel this_ptr_conv;
23267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23268         this_ptr_conv.is_owned = false;
23269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23270         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
23271 }
23272
23273 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
23274         LDKAcceptChannel this_ptr_conv;
23275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23276         this_ptr_conv.is_owned = false;
23277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23278         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
23279         return ret_val;
23280 }
23281
23282 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
23283         LDKAcceptChannel this_ptr_conv;
23284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23285         this_ptr_conv.is_owned = false;
23286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23287         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
23288 }
23289
23290 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
23291         LDKAcceptChannel this_ptr_conv;
23292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23293         this_ptr_conv.is_owned = false;
23294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23295         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
23296         return ret_val;
23297 }
23298
23299 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
23300         LDKAcceptChannel this_ptr_conv;
23301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23302         this_ptr_conv.is_owned = false;
23303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23304         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
23305 }
23306
23307 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
23308         LDKAcceptChannel this_ptr_conv;
23309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23310         this_ptr_conv.is_owned = false;
23311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23312         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
23313         return ret_val;
23314 }
23315
23316 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
23317         LDKAcceptChannel this_ptr_conv;
23318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23319         this_ptr_conv.is_owned = false;
23320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23321         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
23322 }
23323
23324 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
23325         LDKAcceptChannel this_ptr_conv;
23326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23327         this_ptr_conv.is_owned = false;
23328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23329         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23330         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
23331         return ret_arr;
23332 }
23333
23334 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
23335         LDKAcceptChannel this_ptr_conv;
23336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23337         this_ptr_conv.is_owned = false;
23338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23339         LDKPublicKey val_ref;
23340         CHECK(val->arr_len == 33);
23341         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23342         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
23343 }
23344
23345 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
23346         LDKAcceptChannel this_ptr_conv;
23347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23348         this_ptr_conv.is_owned = false;
23349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23350         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23351         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
23352         return ret_arr;
23353 }
23354
23355 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
23356         LDKAcceptChannel this_ptr_conv;
23357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23358         this_ptr_conv.is_owned = false;
23359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23360         LDKPublicKey val_ref;
23361         CHECK(val->arr_len == 33);
23362         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23363         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
23364 }
23365
23366 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
23367         LDKAcceptChannel this_ptr_conv;
23368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23369         this_ptr_conv.is_owned = false;
23370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23371         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23372         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
23373         return ret_arr;
23374 }
23375
23376 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
23377         LDKAcceptChannel this_ptr_conv;
23378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23379         this_ptr_conv.is_owned = false;
23380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23381         LDKPublicKey val_ref;
23382         CHECK(val->arr_len == 33);
23383         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23384         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
23385 }
23386
23387 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
23388         LDKAcceptChannel this_ptr_conv;
23389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23390         this_ptr_conv.is_owned = false;
23391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23392         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23393         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
23394         return ret_arr;
23395 }
23396
23397 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
23398         LDKAcceptChannel this_ptr_conv;
23399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23400         this_ptr_conv.is_owned = false;
23401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23402         LDKPublicKey val_ref;
23403         CHECK(val->arr_len == 33);
23404         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23405         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
23406 }
23407
23408 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
23409         LDKAcceptChannel this_ptr_conv;
23410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23411         this_ptr_conv.is_owned = false;
23412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23413         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23414         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
23415         return ret_arr;
23416 }
23417
23418 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
23419         LDKAcceptChannel this_ptr_conv;
23420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23421         this_ptr_conv.is_owned = false;
23422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23423         LDKPublicKey val_ref;
23424         CHECK(val->arr_len == 33);
23425         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23426         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
23427 }
23428
23429 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
23430         LDKAcceptChannel this_ptr_conv;
23431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23432         this_ptr_conv.is_owned = false;
23433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23434         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23435         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23436         return ret_arr;
23437 }
23438
23439 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) {
23440         LDKAcceptChannel this_ptr_conv;
23441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23442         this_ptr_conv.is_owned = false;
23443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23444         LDKPublicKey val_ref;
23445         CHECK(val->arr_len == 33);
23446         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23447         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
23448 }
23449
23450 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
23451         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
23452 uintptr_t ret_ref = 0;
23453 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23454 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23455 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23456 ret_ref = (uintptr_t)ret_var.inner;
23457 if (ret_var.is_owned) {
23458         ret_ref |= 1;
23459 }
23460         return ret_ref;
23461 }
23462 intptr_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
23463         LDKAcceptChannel arg_conv;
23464         arg_conv.inner = (void*)(arg & (~1));
23465         arg_conv.is_owned = false;
23466         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23467         intptr_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
23468         return ret_val;
23469 }
23470
23471 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
23472         LDKAcceptChannel orig_conv;
23473         orig_conv.inner = (void*)(orig & (~1));
23474         orig_conv.is_owned = false;
23475         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23476         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
23477         uintptr_t ret_ref = 0;
23478         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23479         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23481         ret_ref = (uintptr_t)ret_var.inner;
23482         if (ret_var.is_owned) {
23483                 ret_ref |= 1;
23484         }
23485         return ret_ref;
23486 }
23487
23488 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
23489         LDKFundingCreated this_obj_conv;
23490         this_obj_conv.inner = (void*)(this_obj & (~1));
23491         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23493         FundingCreated_free(this_obj_conv);
23494 }
23495
23496 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
23497         LDKFundingCreated this_ptr_conv;
23498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23499         this_ptr_conv.is_owned = false;
23500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23501         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23502         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
23503         return ret_arr;
23504 }
23505
23506 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
23507         LDKFundingCreated this_ptr_conv;
23508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23509         this_ptr_conv.is_owned = false;
23510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23511         LDKThirtyTwoBytes val_ref;
23512         CHECK(val->arr_len == 32);
23513         memcpy(val_ref.data, val->elems, 32); FREE(val);
23514         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
23515 }
23516
23517 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
23518         LDKFundingCreated this_ptr_conv;
23519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23520         this_ptr_conv.is_owned = false;
23521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23522         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23523         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
23524         return ret_arr;
23525 }
23526
23527 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
23528         LDKFundingCreated this_ptr_conv;
23529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23530         this_ptr_conv.is_owned = false;
23531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23532         LDKThirtyTwoBytes val_ref;
23533         CHECK(val->arr_len == 32);
23534         memcpy(val_ref.data, val->elems, 32); FREE(val);
23535         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
23536 }
23537
23538 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
23539         LDKFundingCreated this_ptr_conv;
23540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23541         this_ptr_conv.is_owned = false;
23542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23543         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
23544         return ret_val;
23545 }
23546
23547 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
23548         LDKFundingCreated this_ptr_conv;
23549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23550         this_ptr_conv.is_owned = false;
23551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23552         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
23553 }
23554
23555 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
23556         LDKFundingCreated this_ptr_conv;
23557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23558         this_ptr_conv.is_owned = false;
23559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23560         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
23561         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
23562         return ret_arr;
23563 }
23564
23565 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
23566         LDKFundingCreated this_ptr_conv;
23567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23568         this_ptr_conv.is_owned = false;
23569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23570         LDKSignature val_ref;
23571         CHECK(val->arr_len == 64);
23572         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
23573         FundingCreated_set_signature(&this_ptr_conv, val_ref);
23574 }
23575
23576 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) {
23577         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
23578         CHECK(temporary_channel_id_arg->arr_len == 32);
23579         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
23580         LDKThirtyTwoBytes funding_txid_arg_ref;
23581         CHECK(funding_txid_arg->arr_len == 32);
23582         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
23583         LDKSignature signature_arg_ref;
23584         CHECK(signature_arg->arr_len == 64);
23585         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
23586         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
23587         uintptr_t ret_ref = 0;
23588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23591         ret_ref = (uintptr_t)ret_var.inner;
23592         if (ret_var.is_owned) {
23593                 ret_ref |= 1;
23594         }
23595         return ret_ref;
23596 }
23597
23598 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
23599         LDKFundingCreated ret_var = FundingCreated_clone(arg);
23600 uintptr_t ret_ref = 0;
23601 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23602 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23603 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23604 ret_ref = (uintptr_t)ret_var.inner;
23605 if (ret_var.is_owned) {
23606         ret_ref |= 1;
23607 }
23608         return ret_ref;
23609 }
23610 intptr_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
23611         LDKFundingCreated arg_conv;
23612         arg_conv.inner = (void*)(arg & (~1));
23613         arg_conv.is_owned = false;
23614         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23615         intptr_t ret_val = FundingCreated_clone_ptr(&arg_conv);
23616         return ret_val;
23617 }
23618
23619 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
23620         LDKFundingCreated orig_conv;
23621         orig_conv.inner = (void*)(orig & (~1));
23622         orig_conv.is_owned = false;
23623         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23624         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
23625         uintptr_t ret_ref = 0;
23626         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23627         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23629         ret_ref = (uintptr_t)ret_var.inner;
23630         if (ret_var.is_owned) {
23631                 ret_ref |= 1;
23632         }
23633         return ret_ref;
23634 }
23635
23636 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
23637         LDKFundingSigned this_obj_conv;
23638         this_obj_conv.inner = (void*)(this_obj & (~1));
23639         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23641         FundingSigned_free(this_obj_conv);
23642 }
23643
23644 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
23645         LDKFundingSigned this_ptr_conv;
23646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23647         this_ptr_conv.is_owned = false;
23648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23649         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23650         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
23651         return ret_arr;
23652 }
23653
23654 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23655         LDKFundingSigned this_ptr_conv;
23656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23657         this_ptr_conv.is_owned = false;
23658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23659         LDKThirtyTwoBytes val_ref;
23660         CHECK(val->arr_len == 32);
23661         memcpy(val_ref.data, val->elems, 32); FREE(val);
23662         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
23663 }
23664
23665 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
23666         LDKFundingSigned this_ptr_conv;
23667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23668         this_ptr_conv.is_owned = false;
23669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23670         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
23671         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
23672         return ret_arr;
23673 }
23674
23675 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
23676         LDKFundingSigned this_ptr_conv;
23677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23678         this_ptr_conv.is_owned = false;
23679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23680         LDKSignature val_ref;
23681         CHECK(val->arr_len == 64);
23682         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
23683         FundingSigned_set_signature(&this_ptr_conv, val_ref);
23684 }
23685
23686 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
23687         LDKThirtyTwoBytes channel_id_arg_ref;
23688         CHECK(channel_id_arg->arr_len == 32);
23689         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
23690         LDKSignature signature_arg_ref;
23691         CHECK(signature_arg->arr_len == 64);
23692         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
23693         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
23694         uintptr_t ret_ref = 0;
23695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23698         ret_ref = (uintptr_t)ret_var.inner;
23699         if (ret_var.is_owned) {
23700                 ret_ref |= 1;
23701         }
23702         return ret_ref;
23703 }
23704
23705 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
23706         LDKFundingSigned ret_var = FundingSigned_clone(arg);
23707 uintptr_t ret_ref = 0;
23708 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23709 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23710 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23711 ret_ref = (uintptr_t)ret_var.inner;
23712 if (ret_var.is_owned) {
23713         ret_ref |= 1;
23714 }
23715         return ret_ref;
23716 }
23717 intptr_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
23718         LDKFundingSigned arg_conv;
23719         arg_conv.inner = (void*)(arg & (~1));
23720         arg_conv.is_owned = false;
23721         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23722         intptr_t ret_val = FundingSigned_clone_ptr(&arg_conv);
23723         return ret_val;
23724 }
23725
23726 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
23727         LDKFundingSigned orig_conv;
23728         orig_conv.inner = (void*)(orig & (~1));
23729         orig_conv.is_owned = false;
23730         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23731         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
23732         uintptr_t ret_ref = 0;
23733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23736         ret_ref = (uintptr_t)ret_var.inner;
23737         if (ret_var.is_owned) {
23738                 ret_ref |= 1;
23739         }
23740         return ret_ref;
23741 }
23742
23743 void  __attribute__((export_name("TS_FundingLocked_free"))) TS_FundingLocked_free(uint32_t this_obj) {
23744         LDKFundingLocked this_obj_conv;
23745         this_obj_conv.inner = (void*)(this_obj & (~1));
23746         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23748         FundingLocked_free(this_obj_conv);
23749 }
23750
23751 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_channel_id"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
23752         LDKFundingLocked this_ptr_conv;
23753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23754         this_ptr_conv.is_owned = false;
23755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23756         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23757         memcpy(ret_arr->elems, *FundingLocked_get_channel_id(&this_ptr_conv), 32);
23758         return ret_arr;
23759 }
23760
23761 void  __attribute__((export_name("TS_FundingLocked_set_channel_id"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23762         LDKFundingLocked this_ptr_conv;
23763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23764         this_ptr_conv.is_owned = false;
23765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23766         LDKThirtyTwoBytes val_ref;
23767         CHECK(val->arr_len == 32);
23768         memcpy(val_ref.data, val->elems, 32); FREE(val);
23769         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
23770 }
23771
23772 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_next_per_commitment_point"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
23773         LDKFundingLocked this_ptr_conv;
23774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23775         this_ptr_conv.is_owned = false;
23776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23777         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23778         memcpy(ret_arr->elems, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23779         return ret_arr;
23780 }
23781
23782 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) {
23783         LDKFundingLocked this_ptr_conv;
23784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23785         this_ptr_conv.is_owned = false;
23786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23787         LDKPublicKey val_ref;
23788         CHECK(val->arr_len == 33);
23789         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23790         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
23791 }
23792
23793 uint32_t  __attribute__((export_name("TS_FundingLocked_new"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
23794         LDKThirtyTwoBytes channel_id_arg_ref;
23795         CHECK(channel_id_arg->arr_len == 32);
23796         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
23797         LDKPublicKey next_per_commitment_point_arg_ref;
23798         CHECK(next_per_commitment_point_arg->arr_len == 33);
23799         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
23800         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
23801         uintptr_t ret_ref = 0;
23802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23805         ret_ref = (uintptr_t)ret_var.inner;
23806         if (ret_var.is_owned) {
23807                 ret_ref |= 1;
23808         }
23809         return ret_ref;
23810 }
23811
23812 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
23813         LDKFundingLocked ret_var = FundingLocked_clone(arg);
23814 uintptr_t ret_ref = 0;
23815 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23816 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23817 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23818 ret_ref = (uintptr_t)ret_var.inner;
23819 if (ret_var.is_owned) {
23820         ret_ref |= 1;
23821 }
23822         return ret_ref;
23823 }
23824 intptr_t  __attribute__((export_name("TS_FundingLocked_clone_ptr"))) TS_FundingLocked_clone_ptr(uint32_t arg) {
23825         LDKFundingLocked arg_conv;
23826         arg_conv.inner = (void*)(arg & (~1));
23827         arg_conv.is_owned = false;
23828         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23829         intptr_t ret_val = FundingLocked_clone_ptr(&arg_conv);
23830         return ret_val;
23831 }
23832
23833 uint32_t  __attribute__((export_name("TS_FundingLocked_clone"))) TS_FundingLocked_clone(uint32_t orig) {
23834         LDKFundingLocked orig_conv;
23835         orig_conv.inner = (void*)(orig & (~1));
23836         orig_conv.is_owned = false;
23837         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23838         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
23839         uintptr_t ret_ref = 0;
23840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23843         ret_ref = (uintptr_t)ret_var.inner;
23844         if (ret_var.is_owned) {
23845                 ret_ref |= 1;
23846         }
23847         return ret_ref;
23848 }
23849
23850 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
23851         LDKShutdown this_obj_conv;
23852         this_obj_conv.inner = (void*)(this_obj & (~1));
23853         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23855         Shutdown_free(this_obj_conv);
23856 }
23857
23858 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
23859         LDKShutdown this_ptr_conv;
23860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23861         this_ptr_conv.is_owned = false;
23862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23863         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23864         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
23865         return ret_arr;
23866 }
23867
23868 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23869         LDKShutdown this_ptr_conv;
23870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23871         this_ptr_conv.is_owned = false;
23872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23873         LDKThirtyTwoBytes val_ref;
23874         CHECK(val->arr_len == 32);
23875         memcpy(val_ref.data, val->elems, 32); FREE(val);
23876         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
23877 }
23878
23879 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
23880         LDKShutdown this_ptr_conv;
23881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23882         this_ptr_conv.is_owned = false;
23883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23884         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
23885         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23886         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23887         return ret_arr;
23888 }
23889
23890 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
23891         LDKShutdown this_ptr_conv;
23892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23893         this_ptr_conv.is_owned = false;
23894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23895         LDKCVec_u8Z val_ref;
23896         val_ref.datalen = val->arr_len;
23897         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
23898         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
23899         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
23900 }
23901
23902 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
23903         LDKThirtyTwoBytes channel_id_arg_ref;
23904         CHECK(channel_id_arg->arr_len == 32);
23905         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
23906         LDKCVec_u8Z scriptpubkey_arg_ref;
23907         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
23908         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
23909         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
23910         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
23911         uintptr_t ret_ref = 0;
23912         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23913         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23915         ret_ref = (uintptr_t)ret_var.inner;
23916         if (ret_var.is_owned) {
23917                 ret_ref |= 1;
23918         }
23919         return ret_ref;
23920 }
23921
23922 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
23923         LDKShutdown ret_var = Shutdown_clone(arg);
23924 uintptr_t ret_ref = 0;
23925 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23926 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23927 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23928 ret_ref = (uintptr_t)ret_var.inner;
23929 if (ret_var.is_owned) {
23930         ret_ref |= 1;
23931 }
23932         return ret_ref;
23933 }
23934 intptr_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
23935         LDKShutdown arg_conv;
23936         arg_conv.inner = (void*)(arg & (~1));
23937         arg_conv.is_owned = false;
23938         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23939         intptr_t ret_val = Shutdown_clone_ptr(&arg_conv);
23940         return ret_val;
23941 }
23942
23943 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
23944         LDKShutdown orig_conv;
23945         orig_conv.inner = (void*)(orig & (~1));
23946         orig_conv.is_owned = false;
23947         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23948         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
23949         uintptr_t ret_ref = 0;
23950         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23951         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23953         ret_ref = (uintptr_t)ret_var.inner;
23954         if (ret_var.is_owned) {
23955                 ret_ref |= 1;
23956         }
23957         return ret_ref;
23958 }
23959
23960 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
23961         LDKClosingSignedFeeRange this_obj_conv;
23962         this_obj_conv.inner = (void*)(this_obj & (~1));
23963         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23965         ClosingSignedFeeRange_free(this_obj_conv);
23966 }
23967
23968 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
23969         LDKClosingSignedFeeRange this_ptr_conv;
23970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23971         this_ptr_conv.is_owned = false;
23972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23973         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
23974         return ret_val;
23975 }
23976
23977 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
23978         LDKClosingSignedFeeRange this_ptr_conv;
23979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23980         this_ptr_conv.is_owned = false;
23981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23982         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
23983 }
23984
23985 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
23986         LDKClosingSignedFeeRange this_ptr_conv;
23987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23988         this_ptr_conv.is_owned = false;
23989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23990         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
23991         return ret_val;
23992 }
23993
23994 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
23995         LDKClosingSignedFeeRange this_ptr_conv;
23996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23997         this_ptr_conv.is_owned = false;
23998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23999         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
24000 }
24001
24002 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
24003         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
24004         uintptr_t ret_ref = 0;
24005         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24006         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24008         ret_ref = (uintptr_t)ret_var.inner;
24009         if (ret_var.is_owned) {
24010                 ret_ref |= 1;
24011         }
24012         return ret_ref;
24013 }
24014
24015 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
24016         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
24017 uintptr_t ret_ref = 0;
24018 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24019 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24020 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24021 ret_ref = (uintptr_t)ret_var.inner;
24022 if (ret_var.is_owned) {
24023         ret_ref |= 1;
24024 }
24025         return ret_ref;
24026 }
24027 intptr_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
24028         LDKClosingSignedFeeRange arg_conv;
24029         arg_conv.inner = (void*)(arg & (~1));
24030         arg_conv.is_owned = false;
24031         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24032         intptr_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
24033         return ret_val;
24034 }
24035
24036 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
24037         LDKClosingSignedFeeRange orig_conv;
24038         orig_conv.inner = (void*)(orig & (~1));
24039         orig_conv.is_owned = false;
24040         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24041         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
24042         uintptr_t ret_ref = 0;
24043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24046         ret_ref = (uintptr_t)ret_var.inner;
24047         if (ret_var.is_owned) {
24048                 ret_ref |= 1;
24049         }
24050         return ret_ref;
24051 }
24052
24053 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
24054         LDKClosingSigned this_obj_conv;
24055         this_obj_conv.inner = (void*)(this_obj & (~1));
24056         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24058         ClosingSigned_free(this_obj_conv);
24059 }
24060
24061 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
24062         LDKClosingSigned this_ptr_conv;
24063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24064         this_ptr_conv.is_owned = false;
24065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24066         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24067         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
24068         return ret_arr;
24069 }
24070
24071 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24072         LDKClosingSigned this_ptr_conv;
24073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24074         this_ptr_conv.is_owned = false;
24075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24076         LDKThirtyTwoBytes val_ref;
24077         CHECK(val->arr_len == 32);
24078         memcpy(val_ref.data, val->elems, 32); FREE(val);
24079         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
24080 }
24081
24082 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
24083         LDKClosingSigned 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         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
24088         return ret_val;
24089 }
24090
24091 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
24092         LDKClosingSigned this_ptr_conv;
24093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24094         this_ptr_conv.is_owned = false;
24095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24096         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
24097 }
24098
24099 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
24100         LDKClosingSigned this_ptr_conv;
24101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24102         this_ptr_conv.is_owned = false;
24103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24104         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
24105         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
24106         return ret_arr;
24107 }
24108
24109 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
24110         LDKClosingSigned this_ptr_conv;
24111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24112         this_ptr_conv.is_owned = false;
24113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24114         LDKSignature val_ref;
24115         CHECK(val->arr_len == 64);
24116         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
24117         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
24118 }
24119
24120 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
24121         LDKClosingSigned this_ptr_conv;
24122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24123         this_ptr_conv.is_owned = false;
24124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24125         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
24126         uintptr_t ret_ref = 0;
24127         if ((uintptr_t)ret_var.inner > 4096) {
24128                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24129                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24131                 ret_ref = (uintptr_t)ret_var.inner;
24132                 if (ret_var.is_owned) {
24133                         ret_ref |= 1;
24134                 }
24135         }
24136         return ret_ref;
24137 }
24138
24139 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
24140         LDKClosingSigned this_ptr_conv;
24141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24142         this_ptr_conv.is_owned = false;
24143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24144         LDKClosingSignedFeeRange val_conv;
24145         val_conv.inner = (void*)(val & (~1));
24146         val_conv.is_owned = (val & 1) || (val == 0);
24147         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24148         val_conv = ClosingSignedFeeRange_clone(&val_conv);
24149         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
24150 }
24151
24152 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) {
24153         LDKThirtyTwoBytes channel_id_arg_ref;
24154         CHECK(channel_id_arg->arr_len == 32);
24155         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24156         LDKSignature signature_arg_ref;
24157         CHECK(signature_arg->arr_len == 64);
24158         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
24159         LDKClosingSignedFeeRange fee_range_arg_conv;
24160         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
24161         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
24162         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
24163         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
24164         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
24165         uintptr_t ret_ref = 0;
24166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24169         ret_ref = (uintptr_t)ret_var.inner;
24170         if (ret_var.is_owned) {
24171                 ret_ref |= 1;
24172         }
24173         return ret_ref;
24174 }
24175
24176 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
24177         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
24178 uintptr_t ret_ref = 0;
24179 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24180 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24181 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24182 ret_ref = (uintptr_t)ret_var.inner;
24183 if (ret_var.is_owned) {
24184         ret_ref |= 1;
24185 }
24186         return ret_ref;
24187 }
24188 intptr_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
24189         LDKClosingSigned arg_conv;
24190         arg_conv.inner = (void*)(arg & (~1));
24191         arg_conv.is_owned = false;
24192         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24193         intptr_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
24194         return ret_val;
24195 }
24196
24197 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
24198         LDKClosingSigned orig_conv;
24199         orig_conv.inner = (void*)(orig & (~1));
24200         orig_conv.is_owned = false;
24201         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24202         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
24203         uintptr_t ret_ref = 0;
24204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24207         ret_ref = (uintptr_t)ret_var.inner;
24208         if (ret_var.is_owned) {
24209                 ret_ref |= 1;
24210         }
24211         return ret_ref;
24212 }
24213
24214 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
24215         LDKUpdateAddHTLC this_obj_conv;
24216         this_obj_conv.inner = (void*)(this_obj & (~1));
24217         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24219         UpdateAddHTLC_free(this_obj_conv);
24220 }
24221
24222 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
24223         LDKUpdateAddHTLC this_ptr_conv;
24224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24225         this_ptr_conv.is_owned = false;
24226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24227         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24228         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
24229         return ret_arr;
24230 }
24231
24232 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24233         LDKUpdateAddHTLC this_ptr_conv;
24234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24235         this_ptr_conv.is_owned = false;
24236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24237         LDKThirtyTwoBytes val_ref;
24238         CHECK(val->arr_len == 32);
24239         memcpy(val_ref.data, val->elems, 32); FREE(val);
24240         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
24241 }
24242
24243 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
24244         LDKUpdateAddHTLC this_ptr_conv;
24245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24246         this_ptr_conv.is_owned = false;
24247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24248         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
24249         return ret_val;
24250 }
24251
24252 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24253         LDKUpdateAddHTLC this_ptr_conv;
24254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24255         this_ptr_conv.is_owned = false;
24256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24257         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
24258 }
24259
24260 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
24261         LDKUpdateAddHTLC this_ptr_conv;
24262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24263         this_ptr_conv.is_owned = false;
24264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24265         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
24266         return ret_val;
24267 }
24268
24269 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
24270         LDKUpdateAddHTLC this_ptr_conv;
24271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24272         this_ptr_conv.is_owned = false;
24273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24274         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
24275 }
24276
24277 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
24278         LDKUpdateAddHTLC this_ptr_conv;
24279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24280         this_ptr_conv.is_owned = false;
24281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24282         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24283         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
24284         return ret_arr;
24285 }
24286
24287 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
24288         LDKUpdateAddHTLC this_ptr_conv;
24289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24290         this_ptr_conv.is_owned = false;
24291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24292         LDKThirtyTwoBytes val_ref;
24293         CHECK(val->arr_len == 32);
24294         memcpy(val_ref.data, val->elems, 32); FREE(val);
24295         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
24296 }
24297
24298 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
24299         LDKUpdateAddHTLC this_ptr_conv;
24300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24301         this_ptr_conv.is_owned = false;
24302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24303         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
24304         return ret_val;
24305 }
24306
24307 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
24308         LDKUpdateAddHTLC this_ptr_conv;
24309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24310         this_ptr_conv.is_owned = false;
24311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24312         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
24313 }
24314
24315 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
24316         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
24317 uintptr_t ret_ref = 0;
24318 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24319 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24320 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24321 ret_ref = (uintptr_t)ret_var.inner;
24322 if (ret_var.is_owned) {
24323         ret_ref |= 1;
24324 }
24325         return ret_ref;
24326 }
24327 intptr_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
24328         LDKUpdateAddHTLC arg_conv;
24329         arg_conv.inner = (void*)(arg & (~1));
24330         arg_conv.is_owned = false;
24331         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24332         intptr_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
24333         return ret_val;
24334 }
24335
24336 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
24337         LDKUpdateAddHTLC orig_conv;
24338         orig_conv.inner = (void*)(orig & (~1));
24339         orig_conv.is_owned = false;
24340         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24341         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
24342         uintptr_t ret_ref = 0;
24343         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24344         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24346         ret_ref = (uintptr_t)ret_var.inner;
24347         if (ret_var.is_owned) {
24348                 ret_ref |= 1;
24349         }
24350         return ret_ref;
24351 }
24352
24353 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
24354         LDKUpdateFulfillHTLC this_obj_conv;
24355         this_obj_conv.inner = (void*)(this_obj & (~1));
24356         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24358         UpdateFulfillHTLC_free(this_obj_conv);
24359 }
24360
24361 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
24362         LDKUpdateFulfillHTLC this_ptr_conv;
24363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24364         this_ptr_conv.is_owned = false;
24365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24366         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24367         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
24368         return ret_arr;
24369 }
24370
24371 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24372         LDKUpdateFulfillHTLC this_ptr_conv;
24373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24374         this_ptr_conv.is_owned = false;
24375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24376         LDKThirtyTwoBytes val_ref;
24377         CHECK(val->arr_len == 32);
24378         memcpy(val_ref.data, val->elems, 32); FREE(val);
24379         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
24380 }
24381
24382 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
24383         LDKUpdateFulfillHTLC this_ptr_conv;
24384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24385         this_ptr_conv.is_owned = false;
24386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24387         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
24388         return ret_val;
24389 }
24390
24391 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24392         LDKUpdateFulfillHTLC this_ptr_conv;
24393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24394         this_ptr_conv.is_owned = false;
24395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24396         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
24397 }
24398
24399 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
24400         LDKUpdateFulfillHTLC this_ptr_conv;
24401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24402         this_ptr_conv.is_owned = false;
24403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24404         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24405         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
24406         return ret_arr;
24407 }
24408
24409 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
24410         LDKUpdateFulfillHTLC this_ptr_conv;
24411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24412         this_ptr_conv.is_owned = false;
24413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24414         LDKThirtyTwoBytes val_ref;
24415         CHECK(val->arr_len == 32);
24416         memcpy(val_ref.data, val->elems, 32); FREE(val);
24417         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
24418 }
24419
24420 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) {
24421         LDKThirtyTwoBytes channel_id_arg_ref;
24422         CHECK(channel_id_arg->arr_len == 32);
24423         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24424         LDKThirtyTwoBytes payment_preimage_arg_ref;
24425         CHECK(payment_preimage_arg->arr_len == 32);
24426         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
24427         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
24428         uintptr_t ret_ref = 0;
24429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24432         ret_ref = (uintptr_t)ret_var.inner;
24433         if (ret_var.is_owned) {
24434                 ret_ref |= 1;
24435         }
24436         return ret_ref;
24437 }
24438
24439 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
24440         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
24441 uintptr_t ret_ref = 0;
24442 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24443 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24444 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24445 ret_ref = (uintptr_t)ret_var.inner;
24446 if (ret_var.is_owned) {
24447         ret_ref |= 1;
24448 }
24449         return ret_ref;
24450 }
24451 intptr_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
24452         LDKUpdateFulfillHTLC arg_conv;
24453         arg_conv.inner = (void*)(arg & (~1));
24454         arg_conv.is_owned = false;
24455         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24456         intptr_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
24457         return ret_val;
24458 }
24459
24460 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
24461         LDKUpdateFulfillHTLC orig_conv;
24462         orig_conv.inner = (void*)(orig & (~1));
24463         orig_conv.is_owned = false;
24464         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24465         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
24466         uintptr_t ret_ref = 0;
24467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24470         ret_ref = (uintptr_t)ret_var.inner;
24471         if (ret_var.is_owned) {
24472                 ret_ref |= 1;
24473         }
24474         return ret_ref;
24475 }
24476
24477 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
24478         LDKUpdateFailHTLC this_obj_conv;
24479         this_obj_conv.inner = (void*)(this_obj & (~1));
24480         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24482         UpdateFailHTLC_free(this_obj_conv);
24483 }
24484
24485 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
24486         LDKUpdateFailHTLC this_ptr_conv;
24487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24488         this_ptr_conv.is_owned = false;
24489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24490         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24491         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
24492         return ret_arr;
24493 }
24494
24495 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24496         LDKUpdateFailHTLC this_ptr_conv;
24497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24498         this_ptr_conv.is_owned = false;
24499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24500         LDKThirtyTwoBytes val_ref;
24501         CHECK(val->arr_len == 32);
24502         memcpy(val_ref.data, val->elems, 32); FREE(val);
24503         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
24504 }
24505
24506 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
24507         LDKUpdateFailHTLC this_ptr_conv;
24508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24509         this_ptr_conv.is_owned = false;
24510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24511         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
24512         return ret_val;
24513 }
24514
24515 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24516         LDKUpdateFailHTLC this_ptr_conv;
24517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24518         this_ptr_conv.is_owned = false;
24519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24520         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
24521 }
24522
24523 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
24524         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
24525 uintptr_t ret_ref = 0;
24526 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24527 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24528 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24529 ret_ref = (uintptr_t)ret_var.inner;
24530 if (ret_var.is_owned) {
24531         ret_ref |= 1;
24532 }
24533         return ret_ref;
24534 }
24535 intptr_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
24536         LDKUpdateFailHTLC arg_conv;
24537         arg_conv.inner = (void*)(arg & (~1));
24538         arg_conv.is_owned = false;
24539         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24540         intptr_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
24541         return ret_val;
24542 }
24543
24544 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
24545         LDKUpdateFailHTLC orig_conv;
24546         orig_conv.inner = (void*)(orig & (~1));
24547         orig_conv.is_owned = false;
24548         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24549         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
24550         uintptr_t ret_ref = 0;
24551         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24552         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24554         ret_ref = (uintptr_t)ret_var.inner;
24555         if (ret_var.is_owned) {
24556                 ret_ref |= 1;
24557         }
24558         return ret_ref;
24559 }
24560
24561 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
24562         LDKUpdateFailMalformedHTLC this_obj_conv;
24563         this_obj_conv.inner = (void*)(this_obj & (~1));
24564         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24566         UpdateFailMalformedHTLC_free(this_obj_conv);
24567 }
24568
24569 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
24570         LDKUpdateFailMalformedHTLC this_ptr_conv;
24571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24572         this_ptr_conv.is_owned = false;
24573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24574         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24575         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
24576         return ret_arr;
24577 }
24578
24579 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24580         LDKUpdateFailMalformedHTLC this_ptr_conv;
24581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24582         this_ptr_conv.is_owned = false;
24583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24584         LDKThirtyTwoBytes val_ref;
24585         CHECK(val->arr_len == 32);
24586         memcpy(val_ref.data, val->elems, 32); FREE(val);
24587         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
24588 }
24589
24590 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
24591         LDKUpdateFailMalformedHTLC this_ptr_conv;
24592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24593         this_ptr_conv.is_owned = false;
24594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24595         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
24596         return ret_val;
24597 }
24598
24599 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24600         LDKUpdateFailMalformedHTLC this_ptr_conv;
24601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24602         this_ptr_conv.is_owned = false;
24603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24604         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
24605 }
24606
24607 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
24608         LDKUpdateFailMalformedHTLC this_ptr_conv;
24609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24610         this_ptr_conv.is_owned = false;
24611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24612         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
24613         return ret_val;
24614 }
24615
24616 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
24617         LDKUpdateFailMalformedHTLC this_ptr_conv;
24618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24619         this_ptr_conv.is_owned = false;
24620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24621         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
24622 }
24623
24624 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
24625         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
24626 uintptr_t ret_ref = 0;
24627 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24628 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24629 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24630 ret_ref = (uintptr_t)ret_var.inner;
24631 if (ret_var.is_owned) {
24632         ret_ref |= 1;
24633 }
24634         return ret_ref;
24635 }
24636 intptr_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
24637         LDKUpdateFailMalformedHTLC arg_conv;
24638         arg_conv.inner = (void*)(arg & (~1));
24639         arg_conv.is_owned = false;
24640         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24641         intptr_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
24642         return ret_val;
24643 }
24644
24645 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
24646         LDKUpdateFailMalformedHTLC orig_conv;
24647         orig_conv.inner = (void*)(orig & (~1));
24648         orig_conv.is_owned = false;
24649         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24650         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
24651         uintptr_t ret_ref = 0;
24652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24655         ret_ref = (uintptr_t)ret_var.inner;
24656         if (ret_var.is_owned) {
24657                 ret_ref |= 1;
24658         }
24659         return ret_ref;
24660 }
24661
24662 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
24663         LDKCommitmentSigned this_obj_conv;
24664         this_obj_conv.inner = (void*)(this_obj & (~1));
24665         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24667         CommitmentSigned_free(this_obj_conv);
24668 }
24669
24670 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
24671         LDKCommitmentSigned this_ptr_conv;
24672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24673         this_ptr_conv.is_owned = false;
24674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24675         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24676         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
24677         return ret_arr;
24678 }
24679
24680 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24681         LDKCommitmentSigned this_ptr_conv;
24682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24683         this_ptr_conv.is_owned = false;
24684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24685         LDKThirtyTwoBytes val_ref;
24686         CHECK(val->arr_len == 32);
24687         memcpy(val_ref.data, val->elems, 32); FREE(val);
24688         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
24689 }
24690
24691 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
24692         LDKCommitmentSigned this_ptr_conv;
24693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24694         this_ptr_conv.is_owned = false;
24695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24696         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
24697         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
24698         return ret_arr;
24699 }
24700
24701 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
24702         LDKCommitmentSigned this_ptr_conv;
24703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24704         this_ptr_conv.is_owned = false;
24705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24706         LDKSignature val_ref;
24707         CHECK(val->arr_len == 64);
24708         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
24709         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
24710 }
24711
24712 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
24713         LDKCommitmentSigned this_ptr_conv;
24714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24715         this_ptr_conv.is_owned = false;
24716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24717         LDKCVec_SignatureZ val_constr;
24718         val_constr.datalen = val->arr_len;
24719         if (val_constr.datalen > 0)
24720                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
24721         else
24722                 val_constr.data = NULL;
24723         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
24724         for (size_t m = 0; m < val_constr.datalen; m++) {
24725                 int8_tArray val_conv_12 = val_vals[m];
24726                 LDKSignature val_conv_12_ref;
24727                 CHECK(val_conv_12->arr_len == 64);
24728                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
24729                 val_constr.data[m] = val_conv_12_ref;
24730         }
24731         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
24732 }
24733
24734 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
24735         LDKThirtyTwoBytes channel_id_arg_ref;
24736         CHECK(channel_id_arg->arr_len == 32);
24737         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24738         LDKSignature signature_arg_ref;
24739         CHECK(signature_arg->arr_len == 64);
24740         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
24741         LDKCVec_SignatureZ htlc_signatures_arg_constr;
24742         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
24743         if (htlc_signatures_arg_constr.datalen > 0)
24744                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
24745         else
24746                 htlc_signatures_arg_constr.data = NULL;
24747         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems /* XXX htlc_signatures_arg leaks */;
24748         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
24749                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
24750                 LDKSignature htlc_signatures_arg_conv_12_ref;
24751                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
24752                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
24753                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
24754         }
24755         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
24756         uintptr_t ret_ref = 0;
24757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24760         ret_ref = (uintptr_t)ret_var.inner;
24761         if (ret_var.is_owned) {
24762                 ret_ref |= 1;
24763         }
24764         return ret_ref;
24765 }
24766
24767 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
24768         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
24769 uintptr_t ret_ref = 0;
24770 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24771 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24772 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24773 ret_ref = (uintptr_t)ret_var.inner;
24774 if (ret_var.is_owned) {
24775         ret_ref |= 1;
24776 }
24777         return ret_ref;
24778 }
24779 intptr_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
24780         LDKCommitmentSigned arg_conv;
24781         arg_conv.inner = (void*)(arg & (~1));
24782         arg_conv.is_owned = false;
24783         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24784         intptr_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
24785         return ret_val;
24786 }
24787
24788 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
24789         LDKCommitmentSigned orig_conv;
24790         orig_conv.inner = (void*)(orig & (~1));
24791         orig_conv.is_owned = false;
24792         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24793         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
24794         uintptr_t ret_ref = 0;
24795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24798         ret_ref = (uintptr_t)ret_var.inner;
24799         if (ret_var.is_owned) {
24800                 ret_ref |= 1;
24801         }
24802         return ret_ref;
24803 }
24804
24805 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
24806         LDKRevokeAndACK this_obj_conv;
24807         this_obj_conv.inner = (void*)(this_obj & (~1));
24808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24810         RevokeAndACK_free(this_obj_conv);
24811 }
24812
24813 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
24814         LDKRevokeAndACK this_ptr_conv;
24815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24816         this_ptr_conv.is_owned = false;
24817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24818         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24819         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
24820         return ret_arr;
24821 }
24822
24823 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24824         LDKRevokeAndACK this_ptr_conv;
24825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24826         this_ptr_conv.is_owned = false;
24827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24828         LDKThirtyTwoBytes val_ref;
24829         CHECK(val->arr_len == 32);
24830         memcpy(val_ref.data, val->elems, 32); FREE(val);
24831         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
24832 }
24833
24834 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
24835         LDKRevokeAndACK this_ptr_conv;
24836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24837         this_ptr_conv.is_owned = false;
24838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24839         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24840         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
24841         return ret_arr;
24842 }
24843
24844 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
24845         LDKRevokeAndACK this_ptr_conv;
24846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24847         this_ptr_conv.is_owned = false;
24848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24849         LDKThirtyTwoBytes val_ref;
24850         CHECK(val->arr_len == 32);
24851         memcpy(val_ref.data, val->elems, 32); FREE(val);
24852         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
24853 }
24854
24855 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
24856         LDKRevokeAndACK this_ptr_conv;
24857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24858         this_ptr_conv.is_owned = false;
24859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24860         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24861         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
24862         return ret_arr;
24863 }
24864
24865 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) {
24866         LDKRevokeAndACK this_ptr_conv;
24867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24868         this_ptr_conv.is_owned = false;
24869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24870         LDKPublicKey val_ref;
24871         CHECK(val->arr_len == 33);
24872         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24873         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
24874 }
24875
24876 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) {
24877         LDKThirtyTwoBytes channel_id_arg_ref;
24878         CHECK(channel_id_arg->arr_len == 32);
24879         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24880         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
24881         CHECK(per_commitment_secret_arg->arr_len == 32);
24882         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
24883         LDKPublicKey next_per_commitment_point_arg_ref;
24884         CHECK(next_per_commitment_point_arg->arr_len == 33);
24885         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
24886         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
24887         uintptr_t ret_ref = 0;
24888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24891         ret_ref = (uintptr_t)ret_var.inner;
24892         if (ret_var.is_owned) {
24893                 ret_ref |= 1;
24894         }
24895         return ret_ref;
24896 }
24897
24898 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
24899         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
24900 uintptr_t ret_ref = 0;
24901 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24902 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24903 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24904 ret_ref = (uintptr_t)ret_var.inner;
24905 if (ret_var.is_owned) {
24906         ret_ref |= 1;
24907 }
24908         return ret_ref;
24909 }
24910 intptr_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
24911         LDKRevokeAndACK arg_conv;
24912         arg_conv.inner = (void*)(arg & (~1));
24913         arg_conv.is_owned = false;
24914         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24915         intptr_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
24916         return ret_val;
24917 }
24918
24919 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
24920         LDKRevokeAndACK orig_conv;
24921         orig_conv.inner = (void*)(orig & (~1));
24922         orig_conv.is_owned = false;
24923         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24924         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
24925         uintptr_t ret_ref = 0;
24926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24929         ret_ref = (uintptr_t)ret_var.inner;
24930         if (ret_var.is_owned) {
24931                 ret_ref |= 1;
24932         }
24933         return ret_ref;
24934 }
24935
24936 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
24937         LDKUpdateFee this_obj_conv;
24938         this_obj_conv.inner = (void*)(this_obj & (~1));
24939         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24941         UpdateFee_free(this_obj_conv);
24942 }
24943
24944 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
24945         LDKUpdateFee this_ptr_conv;
24946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24947         this_ptr_conv.is_owned = false;
24948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24949         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24950         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
24951         return ret_arr;
24952 }
24953
24954 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24955         LDKUpdateFee this_ptr_conv;
24956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24957         this_ptr_conv.is_owned = false;
24958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24959         LDKThirtyTwoBytes val_ref;
24960         CHECK(val->arr_len == 32);
24961         memcpy(val_ref.data, val->elems, 32); FREE(val);
24962         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
24963 }
24964
24965 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
24966         LDKUpdateFee this_ptr_conv;
24967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24968         this_ptr_conv.is_owned = false;
24969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24970         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
24971         return ret_val;
24972 }
24973
24974 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
24975         LDKUpdateFee this_ptr_conv;
24976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24977         this_ptr_conv.is_owned = false;
24978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24979         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
24980 }
24981
24982 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
24983         LDKThirtyTwoBytes channel_id_arg_ref;
24984         CHECK(channel_id_arg->arr_len == 32);
24985         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24986         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
24987         uintptr_t ret_ref = 0;
24988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24991         ret_ref = (uintptr_t)ret_var.inner;
24992         if (ret_var.is_owned) {
24993                 ret_ref |= 1;
24994         }
24995         return ret_ref;
24996 }
24997
24998 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
24999         LDKUpdateFee ret_var = UpdateFee_clone(arg);
25000 uintptr_t ret_ref = 0;
25001 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25002 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25003 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25004 ret_ref = (uintptr_t)ret_var.inner;
25005 if (ret_var.is_owned) {
25006         ret_ref |= 1;
25007 }
25008         return ret_ref;
25009 }
25010 intptr_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
25011         LDKUpdateFee arg_conv;
25012         arg_conv.inner = (void*)(arg & (~1));
25013         arg_conv.is_owned = false;
25014         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25015         intptr_t ret_val = UpdateFee_clone_ptr(&arg_conv);
25016         return ret_val;
25017 }
25018
25019 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
25020         LDKUpdateFee orig_conv;
25021         orig_conv.inner = (void*)(orig & (~1));
25022         orig_conv.is_owned = false;
25023         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25024         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
25025         uintptr_t ret_ref = 0;
25026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25029         ret_ref = (uintptr_t)ret_var.inner;
25030         if (ret_var.is_owned) {
25031                 ret_ref |= 1;
25032         }
25033         return ret_ref;
25034 }
25035
25036 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
25037         LDKDataLossProtect this_obj_conv;
25038         this_obj_conv.inner = (void*)(this_obj & (~1));
25039         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25041         DataLossProtect_free(this_obj_conv);
25042 }
25043
25044 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) {
25045         LDKDataLossProtect this_ptr_conv;
25046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25047         this_ptr_conv.is_owned = false;
25048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25049         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25050         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
25051         return ret_arr;
25052 }
25053
25054 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) {
25055         LDKDataLossProtect this_ptr_conv;
25056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25057         this_ptr_conv.is_owned = false;
25058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25059         LDKThirtyTwoBytes val_ref;
25060         CHECK(val->arr_len == 32);
25061         memcpy(val_ref.data, val->elems, 32); FREE(val);
25062         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
25063 }
25064
25065 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) {
25066         LDKDataLossProtect this_ptr_conv;
25067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25068         this_ptr_conv.is_owned = false;
25069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25070         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25071         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
25072         return ret_arr;
25073 }
25074
25075 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) {
25076         LDKDataLossProtect this_ptr_conv;
25077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25078         this_ptr_conv.is_owned = false;
25079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25080         LDKPublicKey val_ref;
25081         CHECK(val->arr_len == 33);
25082         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25083         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
25084 }
25085
25086 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) {
25087         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
25088         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
25089         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
25090         LDKPublicKey my_current_per_commitment_point_arg_ref;
25091         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
25092         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);
25093         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
25094         uintptr_t ret_ref = 0;
25095         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25096         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25098         ret_ref = (uintptr_t)ret_var.inner;
25099         if (ret_var.is_owned) {
25100                 ret_ref |= 1;
25101         }
25102         return ret_ref;
25103 }
25104
25105 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
25106         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
25107 uintptr_t ret_ref = 0;
25108 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25109 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25110 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25111 ret_ref = (uintptr_t)ret_var.inner;
25112 if (ret_var.is_owned) {
25113         ret_ref |= 1;
25114 }
25115         return ret_ref;
25116 }
25117 intptr_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
25118         LDKDataLossProtect arg_conv;
25119         arg_conv.inner = (void*)(arg & (~1));
25120         arg_conv.is_owned = false;
25121         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25122         intptr_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
25123         return ret_val;
25124 }
25125
25126 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
25127         LDKDataLossProtect orig_conv;
25128         orig_conv.inner = (void*)(orig & (~1));
25129         orig_conv.is_owned = false;
25130         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25131         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
25132         uintptr_t ret_ref = 0;
25133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25136         ret_ref = (uintptr_t)ret_var.inner;
25137         if (ret_var.is_owned) {
25138                 ret_ref |= 1;
25139         }
25140         return ret_ref;
25141 }
25142
25143 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
25144         LDKChannelReestablish this_obj_conv;
25145         this_obj_conv.inner = (void*)(this_obj & (~1));
25146         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25148         ChannelReestablish_free(this_obj_conv);
25149 }
25150
25151 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
25152         LDKChannelReestablish this_ptr_conv;
25153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25154         this_ptr_conv.is_owned = false;
25155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25156         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25157         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
25158         return ret_arr;
25159 }
25160
25161 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25162         LDKChannelReestablish this_ptr_conv;
25163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25164         this_ptr_conv.is_owned = false;
25165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25166         LDKThirtyTwoBytes val_ref;
25167         CHECK(val->arr_len == 32);
25168         memcpy(val_ref.data, val->elems, 32); FREE(val);
25169         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
25170 }
25171
25172 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
25173         LDKChannelReestablish this_ptr_conv;
25174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25175         this_ptr_conv.is_owned = false;
25176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25177         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
25178         return ret_val;
25179 }
25180
25181 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) {
25182         LDKChannelReestablish this_ptr_conv;
25183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25184         this_ptr_conv.is_owned = false;
25185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25186         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
25187 }
25188
25189 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
25190         LDKChannelReestablish this_ptr_conv;
25191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25192         this_ptr_conv.is_owned = false;
25193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25194         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
25195         return ret_val;
25196 }
25197
25198 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) {
25199         LDKChannelReestablish this_ptr_conv;
25200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25201         this_ptr_conv.is_owned = false;
25202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25203         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
25204 }
25205
25206 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
25207         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
25208 uintptr_t ret_ref = 0;
25209 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25210 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25211 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25212 ret_ref = (uintptr_t)ret_var.inner;
25213 if (ret_var.is_owned) {
25214         ret_ref |= 1;
25215 }
25216         return ret_ref;
25217 }
25218 intptr_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
25219         LDKChannelReestablish arg_conv;
25220         arg_conv.inner = (void*)(arg & (~1));
25221         arg_conv.is_owned = false;
25222         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25223         intptr_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
25224         return ret_val;
25225 }
25226
25227 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
25228         LDKChannelReestablish orig_conv;
25229         orig_conv.inner = (void*)(orig & (~1));
25230         orig_conv.is_owned = false;
25231         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25232         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
25233         uintptr_t ret_ref = 0;
25234         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25235         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25237         ret_ref = (uintptr_t)ret_var.inner;
25238         if (ret_var.is_owned) {
25239                 ret_ref |= 1;
25240         }
25241         return ret_ref;
25242 }
25243
25244 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
25245         LDKAnnouncementSignatures this_obj_conv;
25246         this_obj_conv.inner = (void*)(this_obj & (~1));
25247         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25249         AnnouncementSignatures_free(this_obj_conv);
25250 }
25251
25252 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
25253         LDKAnnouncementSignatures this_ptr_conv;
25254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25255         this_ptr_conv.is_owned = false;
25256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25257         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25258         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
25259         return ret_arr;
25260 }
25261
25262 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25263         LDKAnnouncementSignatures this_ptr_conv;
25264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25265         this_ptr_conv.is_owned = false;
25266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25267         LDKThirtyTwoBytes val_ref;
25268         CHECK(val->arr_len == 32);
25269         memcpy(val_ref.data, val->elems, 32); FREE(val);
25270         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
25271 }
25272
25273 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
25274         LDKAnnouncementSignatures this_ptr_conv;
25275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25276         this_ptr_conv.is_owned = false;
25277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25278         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
25279         return ret_val;
25280 }
25281
25282 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
25283         LDKAnnouncementSignatures this_ptr_conv;
25284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25285         this_ptr_conv.is_owned = false;
25286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25287         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
25288 }
25289
25290 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
25291         LDKAnnouncementSignatures this_ptr_conv;
25292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25293         this_ptr_conv.is_owned = false;
25294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25295         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
25296         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
25297         return ret_arr;
25298 }
25299
25300 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
25301         LDKAnnouncementSignatures this_ptr_conv;
25302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25303         this_ptr_conv.is_owned = false;
25304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25305         LDKSignature val_ref;
25306         CHECK(val->arr_len == 64);
25307         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
25308         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
25309 }
25310
25311 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
25312         LDKAnnouncementSignatures this_ptr_conv;
25313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25314         this_ptr_conv.is_owned = false;
25315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25316         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
25317         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
25318         return ret_arr;
25319 }
25320
25321 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
25322         LDKAnnouncementSignatures this_ptr_conv;
25323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25324         this_ptr_conv.is_owned = false;
25325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25326         LDKSignature val_ref;
25327         CHECK(val->arr_len == 64);
25328         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
25329         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
25330 }
25331
25332 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) {
25333         LDKThirtyTwoBytes channel_id_arg_ref;
25334         CHECK(channel_id_arg->arr_len == 32);
25335         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
25336         LDKSignature node_signature_arg_ref;
25337         CHECK(node_signature_arg->arr_len == 64);
25338         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
25339         LDKSignature bitcoin_signature_arg_ref;
25340         CHECK(bitcoin_signature_arg->arr_len == 64);
25341         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
25342         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
25343         uintptr_t ret_ref = 0;
25344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25347         ret_ref = (uintptr_t)ret_var.inner;
25348         if (ret_var.is_owned) {
25349                 ret_ref |= 1;
25350         }
25351         return ret_ref;
25352 }
25353
25354 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
25355         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
25356 uintptr_t ret_ref = 0;
25357 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25358 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25359 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25360 ret_ref = (uintptr_t)ret_var.inner;
25361 if (ret_var.is_owned) {
25362         ret_ref |= 1;
25363 }
25364         return ret_ref;
25365 }
25366 intptr_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
25367         LDKAnnouncementSignatures arg_conv;
25368         arg_conv.inner = (void*)(arg & (~1));
25369         arg_conv.is_owned = false;
25370         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25371         intptr_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
25372         return ret_val;
25373 }
25374
25375 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
25376         LDKAnnouncementSignatures orig_conv;
25377         orig_conv.inner = (void*)(orig & (~1));
25378         orig_conv.is_owned = false;
25379         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25380         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
25381         uintptr_t ret_ref = 0;
25382         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25383         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25385         ret_ref = (uintptr_t)ret_var.inner;
25386         if (ret_var.is_owned) {
25387                 ret_ref |= 1;
25388         }
25389         return ret_ref;
25390 }
25391
25392 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
25393         if ((this_ptr & 1) != 0) return;
25394         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25395         CHECK_ACCESS(this_ptr_ptr);
25396         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
25397         FREE((void*)this_ptr);
25398         NetAddress_free(this_ptr_conv);
25399 }
25400
25401 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
25402         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25403         *ret_copy = NetAddress_clone(arg);
25404 uintptr_t ret_ref = (uintptr_t)ret_copy;
25405         return ret_ref;
25406 }
25407 intptr_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
25408         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
25409         intptr_t ret_val = NetAddress_clone_ptr(arg_conv);
25410         return ret_val;
25411 }
25412
25413 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
25414         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
25415         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25416         *ret_copy = NetAddress_clone(orig_conv);
25417         uintptr_t ret_ref = (uintptr_t)ret_copy;
25418         return ret_ref;
25419 }
25420
25421 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
25422         LDKFourBytes addr_ref;
25423         CHECK(addr->arr_len == 4);
25424         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
25425         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25426         *ret_copy = NetAddress_ipv4(addr_ref, port);
25427         uintptr_t ret_ref = (uintptr_t)ret_copy;
25428         return ret_ref;
25429 }
25430
25431 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
25432         LDKSixteenBytes addr_ref;
25433         CHECK(addr->arr_len == 16);
25434         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
25435         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25436         *ret_copy = NetAddress_ipv6(addr_ref, port);
25437         uintptr_t ret_ref = (uintptr_t)ret_copy;
25438         return ret_ref;
25439 }
25440
25441 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
25442         LDKTwelveBytes a_ref;
25443         CHECK(a->arr_len == 12);
25444         memcpy(a_ref.data, a->elems, 12); FREE(a);
25445         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25446         *ret_copy = NetAddress_onion_v2(a_ref);
25447         uintptr_t ret_ref = (uintptr_t)ret_copy;
25448         return ret_ref;
25449 }
25450
25451 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) {
25452         LDKThirtyTwoBytes ed25519_pubkey_ref;
25453         CHECK(ed25519_pubkey->arr_len == 32);
25454         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
25455         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25456         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
25457         uintptr_t ret_ref = (uintptr_t)ret_copy;
25458         return ret_ref;
25459 }
25460
25461 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
25462         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
25463         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
25464         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25465         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25466         CVec_u8Z_free(ret_var);
25467         return ret_arr;
25468 }
25469
25470 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
25471         LDKu8slice ser_ref;
25472         ser_ref.datalen = ser->arr_len;
25473         ser_ref.data = ser->elems /* XXX ser leaks */;
25474         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
25475         *ret_conv = NetAddress_read(ser_ref);
25476         return (uintptr_t)ret_conv;
25477 }
25478
25479 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
25480         LDKUnsignedNodeAnnouncement this_obj_conv;
25481         this_obj_conv.inner = (void*)(this_obj & (~1));
25482         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25484         UnsignedNodeAnnouncement_free(this_obj_conv);
25485 }
25486
25487 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
25488         LDKUnsignedNodeAnnouncement this_ptr_conv;
25489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25490         this_ptr_conv.is_owned = false;
25491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25492         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
25493         uintptr_t ret_ref = 0;
25494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25497         ret_ref = (uintptr_t)ret_var.inner;
25498         if (ret_var.is_owned) {
25499                 ret_ref |= 1;
25500         }
25501         return ret_ref;
25502 }
25503
25504 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
25505         LDKUnsignedNodeAnnouncement this_ptr_conv;
25506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25507         this_ptr_conv.is_owned = false;
25508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25509         LDKNodeFeatures val_conv;
25510         val_conv.inner = (void*)(val & (~1));
25511         val_conv.is_owned = (val & 1) || (val == 0);
25512         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25513         val_conv = NodeFeatures_clone(&val_conv);
25514         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
25515 }
25516
25517 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
25518         LDKUnsignedNodeAnnouncement this_ptr_conv;
25519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25520         this_ptr_conv.is_owned = false;
25521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25522         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
25523         return ret_val;
25524 }
25525
25526 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
25527         LDKUnsignedNodeAnnouncement this_ptr_conv;
25528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25529         this_ptr_conv.is_owned = false;
25530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25531         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
25532 }
25533
25534 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
25535         LDKUnsignedNodeAnnouncement this_ptr_conv;
25536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25537         this_ptr_conv.is_owned = false;
25538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25539         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25540         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
25541         return ret_arr;
25542 }
25543
25544 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
25545         LDKUnsignedNodeAnnouncement this_ptr_conv;
25546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25547         this_ptr_conv.is_owned = false;
25548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25549         LDKPublicKey val_ref;
25550         CHECK(val->arr_len == 33);
25551         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25552         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
25553 }
25554
25555 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
25556         LDKUnsignedNodeAnnouncement this_ptr_conv;
25557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25558         this_ptr_conv.is_owned = false;
25559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25560         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
25561         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
25562         return ret_arr;
25563 }
25564
25565 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
25566         LDKUnsignedNodeAnnouncement this_ptr_conv;
25567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25568         this_ptr_conv.is_owned = false;
25569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25570         LDKThreeBytes val_ref;
25571         CHECK(val->arr_len == 3);
25572         memcpy(val_ref.data, val->elems, 3); FREE(val);
25573         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
25574 }
25575
25576 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
25577         LDKUnsignedNodeAnnouncement this_ptr_conv;
25578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25579         this_ptr_conv.is_owned = false;
25580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25581         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25582         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
25583         return ret_arr;
25584 }
25585
25586 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
25587         LDKUnsignedNodeAnnouncement this_ptr_conv;
25588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25589         this_ptr_conv.is_owned = false;
25590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25591         LDKThirtyTwoBytes val_ref;
25592         CHECK(val->arr_len == 32);
25593         memcpy(val_ref.data, val->elems, 32); FREE(val);
25594         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
25595 }
25596
25597 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
25598         LDKUnsignedNodeAnnouncement this_ptr_conv;
25599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25600         this_ptr_conv.is_owned = false;
25601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25602         LDKCVec_NetAddressZ val_constr;
25603         val_constr.datalen = val->arr_len;
25604         if (val_constr.datalen > 0)
25605                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25606         else
25607                 val_constr.data = NULL;
25608         uint32_t* val_vals = val->elems /* XXX val leaks */;
25609         for (size_t m = 0; m < val_constr.datalen; m++) {
25610                 uint32_t val_conv_12 = val_vals[m];
25611                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
25612                 CHECK_ACCESS(val_conv_12_ptr);
25613                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
25614                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
25615                 val_constr.data[m] = val_conv_12_conv;
25616         }
25617         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
25618 }
25619
25620 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
25621         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
25622 uintptr_t ret_ref = 0;
25623 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25624 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25625 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25626 ret_ref = (uintptr_t)ret_var.inner;
25627 if (ret_var.is_owned) {
25628         ret_ref |= 1;
25629 }
25630         return ret_ref;
25631 }
25632 intptr_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
25633         LDKUnsignedNodeAnnouncement arg_conv;
25634         arg_conv.inner = (void*)(arg & (~1));
25635         arg_conv.is_owned = false;
25636         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25637         intptr_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
25638         return ret_val;
25639 }
25640
25641 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
25642         LDKUnsignedNodeAnnouncement orig_conv;
25643         orig_conv.inner = (void*)(orig & (~1));
25644         orig_conv.is_owned = false;
25645         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25646         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
25647         uintptr_t ret_ref = 0;
25648         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25649         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25651         ret_ref = (uintptr_t)ret_var.inner;
25652         if (ret_var.is_owned) {
25653                 ret_ref |= 1;
25654         }
25655         return ret_ref;
25656 }
25657
25658 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
25659         LDKNodeAnnouncement this_obj_conv;
25660         this_obj_conv.inner = (void*)(this_obj & (~1));
25661         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25663         NodeAnnouncement_free(this_obj_conv);
25664 }
25665
25666 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
25667         LDKNodeAnnouncement this_ptr_conv;
25668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25669         this_ptr_conv.is_owned = false;
25670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25671         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
25672         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
25673         return ret_arr;
25674 }
25675
25676 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
25677         LDKNodeAnnouncement this_ptr_conv;
25678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25679         this_ptr_conv.is_owned = false;
25680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25681         LDKSignature val_ref;
25682         CHECK(val->arr_len == 64);
25683         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
25684         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
25685 }
25686
25687 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
25688         LDKNodeAnnouncement this_ptr_conv;
25689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25690         this_ptr_conv.is_owned = false;
25691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25692         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
25693         uintptr_t ret_ref = 0;
25694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25697         ret_ref = (uintptr_t)ret_var.inner;
25698         if (ret_var.is_owned) {
25699                 ret_ref |= 1;
25700         }
25701         return ret_ref;
25702 }
25703
25704 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
25705         LDKNodeAnnouncement this_ptr_conv;
25706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25707         this_ptr_conv.is_owned = false;
25708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25709         LDKUnsignedNodeAnnouncement val_conv;
25710         val_conv.inner = (void*)(val & (~1));
25711         val_conv.is_owned = (val & 1) || (val == 0);
25712         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25713         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
25714         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
25715 }
25716
25717 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
25718         LDKSignature signature_arg_ref;
25719         CHECK(signature_arg->arr_len == 64);
25720         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
25721         LDKUnsignedNodeAnnouncement contents_arg_conv;
25722         contents_arg_conv.inner = (void*)(contents_arg & (~1));
25723         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
25724         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
25725         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
25726         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
25727         uintptr_t ret_ref = 0;
25728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25731         ret_ref = (uintptr_t)ret_var.inner;
25732         if (ret_var.is_owned) {
25733                 ret_ref |= 1;
25734         }
25735         return ret_ref;
25736 }
25737
25738 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
25739         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
25740 uintptr_t ret_ref = 0;
25741 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25742 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25743 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25744 ret_ref = (uintptr_t)ret_var.inner;
25745 if (ret_var.is_owned) {
25746         ret_ref |= 1;
25747 }
25748         return ret_ref;
25749 }
25750 intptr_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
25751         LDKNodeAnnouncement arg_conv;
25752         arg_conv.inner = (void*)(arg & (~1));
25753         arg_conv.is_owned = false;
25754         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25755         intptr_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
25756         return ret_val;
25757 }
25758
25759 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
25760         LDKNodeAnnouncement orig_conv;
25761         orig_conv.inner = (void*)(orig & (~1));
25762         orig_conv.is_owned = false;
25763         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25764         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
25765         uintptr_t ret_ref = 0;
25766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25769         ret_ref = (uintptr_t)ret_var.inner;
25770         if (ret_var.is_owned) {
25771                 ret_ref |= 1;
25772         }
25773         return ret_ref;
25774 }
25775
25776 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
25777         LDKUnsignedChannelAnnouncement this_obj_conv;
25778         this_obj_conv.inner = (void*)(this_obj & (~1));
25779         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25781         UnsignedChannelAnnouncement_free(this_obj_conv);
25782 }
25783
25784 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
25785         LDKUnsignedChannelAnnouncement this_ptr_conv;
25786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25787         this_ptr_conv.is_owned = false;
25788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25789         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
25790         uintptr_t ret_ref = 0;
25791         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25792         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25794         ret_ref = (uintptr_t)ret_var.inner;
25795         if (ret_var.is_owned) {
25796                 ret_ref |= 1;
25797         }
25798         return ret_ref;
25799 }
25800
25801 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
25802         LDKUnsignedChannelAnnouncement this_ptr_conv;
25803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25804         this_ptr_conv.is_owned = false;
25805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25806         LDKChannelFeatures val_conv;
25807         val_conv.inner = (void*)(val & (~1));
25808         val_conv.is_owned = (val & 1) || (val == 0);
25809         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25810         val_conv = ChannelFeatures_clone(&val_conv);
25811         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
25812 }
25813
25814 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
25815         LDKUnsignedChannelAnnouncement this_ptr_conv;
25816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25817         this_ptr_conv.is_owned = false;
25818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25819         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25820         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
25821         return ret_arr;
25822 }
25823
25824 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
25825         LDKUnsignedChannelAnnouncement this_ptr_conv;
25826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25827         this_ptr_conv.is_owned = false;
25828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25829         LDKThirtyTwoBytes val_ref;
25830         CHECK(val->arr_len == 32);
25831         memcpy(val_ref.data, val->elems, 32); FREE(val);
25832         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
25833 }
25834
25835 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
25836         LDKUnsignedChannelAnnouncement this_ptr_conv;
25837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25838         this_ptr_conv.is_owned = false;
25839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25840         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
25841         return ret_val;
25842 }
25843
25844 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
25845         LDKUnsignedChannelAnnouncement this_ptr_conv;
25846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25847         this_ptr_conv.is_owned = false;
25848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25849         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
25850 }
25851
25852 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
25853         LDKUnsignedChannelAnnouncement this_ptr_conv;
25854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25855         this_ptr_conv.is_owned = false;
25856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25857         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25858         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
25859         return ret_arr;
25860 }
25861
25862 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
25863         LDKUnsignedChannelAnnouncement this_ptr_conv;
25864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25865         this_ptr_conv.is_owned = false;
25866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25867         LDKPublicKey val_ref;
25868         CHECK(val->arr_len == 33);
25869         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25870         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
25871 }
25872
25873 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
25874         LDKUnsignedChannelAnnouncement this_ptr_conv;
25875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25876         this_ptr_conv.is_owned = false;
25877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25878         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25879         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
25880         return ret_arr;
25881 }
25882
25883 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
25884         LDKUnsignedChannelAnnouncement 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         LDKPublicKey val_ref;
25889         CHECK(val->arr_len == 33);
25890         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25891         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
25892 }
25893
25894 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
25895         LDKUnsignedChannelAnnouncement this_ptr_conv;
25896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25897         this_ptr_conv.is_owned = false;
25898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25899         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25900         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
25901         return ret_arr;
25902 }
25903
25904 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
25905         LDKUnsignedChannelAnnouncement this_ptr_conv;
25906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25907         this_ptr_conv.is_owned = false;
25908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25909         LDKPublicKey val_ref;
25910         CHECK(val->arr_len == 33);
25911         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25912         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
25913 }
25914
25915 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
25916         LDKUnsignedChannelAnnouncement this_ptr_conv;
25917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25918         this_ptr_conv.is_owned = false;
25919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25920         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25921         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
25922         return ret_arr;
25923 }
25924
25925 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
25926         LDKUnsignedChannelAnnouncement this_ptr_conv;
25927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25928         this_ptr_conv.is_owned = false;
25929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25930         LDKPublicKey val_ref;
25931         CHECK(val->arr_len == 33);
25932         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25933         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
25934 }
25935
25936 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
25937         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
25938 uintptr_t ret_ref = 0;
25939 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25940 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25941 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25942 ret_ref = (uintptr_t)ret_var.inner;
25943 if (ret_var.is_owned) {
25944         ret_ref |= 1;
25945 }
25946         return ret_ref;
25947 }
25948 intptr_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
25949         LDKUnsignedChannelAnnouncement arg_conv;
25950         arg_conv.inner = (void*)(arg & (~1));
25951         arg_conv.is_owned = false;
25952         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25953         intptr_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
25954         return ret_val;
25955 }
25956
25957 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
25958         LDKUnsignedChannelAnnouncement orig_conv;
25959         orig_conv.inner = (void*)(orig & (~1));
25960         orig_conv.is_owned = false;
25961         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25962         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
25963         uintptr_t ret_ref = 0;
25964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25967         ret_ref = (uintptr_t)ret_var.inner;
25968         if (ret_var.is_owned) {
25969                 ret_ref |= 1;
25970         }
25971         return ret_ref;
25972 }
25973
25974 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
25975         LDKChannelAnnouncement this_obj_conv;
25976         this_obj_conv.inner = (void*)(this_obj & (~1));
25977         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25979         ChannelAnnouncement_free(this_obj_conv);
25980 }
25981
25982 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
25983         LDKChannelAnnouncement this_ptr_conv;
25984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25985         this_ptr_conv.is_owned = false;
25986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25987         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
25988         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
25989         return ret_arr;
25990 }
25991
25992 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
25993         LDKChannelAnnouncement this_ptr_conv;
25994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25995         this_ptr_conv.is_owned = false;
25996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25997         LDKSignature val_ref;
25998         CHECK(val->arr_len == 64);
25999         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
26000         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
26001 }
26002
26003 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
26004         LDKChannelAnnouncement this_ptr_conv;
26005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26006         this_ptr_conv.is_owned = false;
26007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26008         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
26009         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
26010         return ret_arr;
26011 }
26012
26013 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
26014         LDKChannelAnnouncement this_ptr_conv;
26015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26016         this_ptr_conv.is_owned = false;
26017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26018         LDKSignature val_ref;
26019         CHECK(val->arr_len == 64);
26020         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
26021         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
26022 }
26023
26024 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
26025         LDKChannelAnnouncement this_ptr_conv;
26026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26027         this_ptr_conv.is_owned = false;
26028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26029         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
26030         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
26031         return ret_arr;
26032 }
26033
26034 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
26035         LDKChannelAnnouncement this_ptr_conv;
26036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26037         this_ptr_conv.is_owned = false;
26038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26039         LDKSignature val_ref;
26040         CHECK(val->arr_len == 64);
26041         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
26042         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
26043 }
26044
26045 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
26046         LDKChannelAnnouncement this_ptr_conv;
26047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26048         this_ptr_conv.is_owned = false;
26049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26050         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
26051         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
26052         return ret_arr;
26053 }
26054
26055 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
26056         LDKChannelAnnouncement this_ptr_conv;
26057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26058         this_ptr_conv.is_owned = false;
26059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26060         LDKSignature val_ref;
26061         CHECK(val->arr_len == 64);
26062         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
26063         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
26064 }
26065
26066 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
26067         LDKChannelAnnouncement this_ptr_conv;
26068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26069         this_ptr_conv.is_owned = false;
26070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26071         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
26072         uintptr_t ret_ref = 0;
26073         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26074         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26076         ret_ref = (uintptr_t)ret_var.inner;
26077         if (ret_var.is_owned) {
26078                 ret_ref |= 1;
26079         }
26080         return ret_ref;
26081 }
26082
26083 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
26084         LDKChannelAnnouncement this_ptr_conv;
26085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26086         this_ptr_conv.is_owned = false;
26087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26088         LDKUnsignedChannelAnnouncement val_conv;
26089         val_conv.inner = (void*)(val & (~1));
26090         val_conv.is_owned = (val & 1) || (val == 0);
26091         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26092         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
26093         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
26094 }
26095
26096 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) {
26097         LDKSignature node_signature_1_arg_ref;
26098         CHECK(node_signature_1_arg->arr_len == 64);
26099         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
26100         LDKSignature node_signature_2_arg_ref;
26101         CHECK(node_signature_2_arg->arr_len == 64);
26102         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
26103         LDKSignature bitcoin_signature_1_arg_ref;
26104         CHECK(bitcoin_signature_1_arg->arr_len == 64);
26105         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
26106         LDKSignature bitcoin_signature_2_arg_ref;
26107         CHECK(bitcoin_signature_2_arg->arr_len == 64);
26108         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
26109         LDKUnsignedChannelAnnouncement contents_arg_conv;
26110         contents_arg_conv.inner = (void*)(contents_arg & (~1));
26111         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
26112         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
26113         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
26114         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);
26115         uintptr_t ret_ref = 0;
26116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26119         ret_ref = (uintptr_t)ret_var.inner;
26120         if (ret_var.is_owned) {
26121                 ret_ref |= 1;
26122         }
26123         return ret_ref;
26124 }
26125
26126 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
26127         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
26128 uintptr_t ret_ref = 0;
26129 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26130 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26131 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26132 ret_ref = (uintptr_t)ret_var.inner;
26133 if (ret_var.is_owned) {
26134         ret_ref |= 1;
26135 }
26136         return ret_ref;
26137 }
26138 intptr_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
26139         LDKChannelAnnouncement arg_conv;
26140         arg_conv.inner = (void*)(arg & (~1));
26141         arg_conv.is_owned = false;
26142         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26143         intptr_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
26144         return ret_val;
26145 }
26146
26147 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
26148         LDKChannelAnnouncement orig_conv;
26149         orig_conv.inner = (void*)(orig & (~1));
26150         orig_conv.is_owned = false;
26151         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26152         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
26153         uintptr_t ret_ref = 0;
26154         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26155         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26157         ret_ref = (uintptr_t)ret_var.inner;
26158         if (ret_var.is_owned) {
26159                 ret_ref |= 1;
26160         }
26161         return ret_ref;
26162 }
26163
26164 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
26165         LDKUnsignedChannelUpdate this_obj_conv;
26166         this_obj_conv.inner = (void*)(this_obj & (~1));
26167         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26169         UnsignedChannelUpdate_free(this_obj_conv);
26170 }
26171
26172 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
26173         LDKUnsignedChannelUpdate this_ptr_conv;
26174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26175         this_ptr_conv.is_owned = false;
26176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26177         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26178         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
26179         return ret_arr;
26180 }
26181
26182 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26183         LDKUnsignedChannelUpdate this_ptr_conv;
26184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26185         this_ptr_conv.is_owned = false;
26186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26187         LDKThirtyTwoBytes val_ref;
26188         CHECK(val->arr_len == 32);
26189         memcpy(val_ref.data, val->elems, 32); FREE(val);
26190         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
26191 }
26192
26193 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
26194         LDKUnsignedChannelUpdate this_ptr_conv;
26195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26196         this_ptr_conv.is_owned = false;
26197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26198         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
26199         return ret_val;
26200 }
26201
26202 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
26203         LDKUnsignedChannelUpdate this_ptr_conv;
26204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26205         this_ptr_conv.is_owned = false;
26206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26207         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
26208 }
26209
26210 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
26211         LDKUnsignedChannelUpdate this_ptr_conv;
26212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26213         this_ptr_conv.is_owned = false;
26214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26215         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
26216         return ret_val;
26217 }
26218
26219 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
26220         LDKUnsignedChannelUpdate this_ptr_conv;
26221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26222         this_ptr_conv.is_owned = false;
26223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26224         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
26225 }
26226
26227 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
26228         LDKUnsignedChannelUpdate this_ptr_conv;
26229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26230         this_ptr_conv.is_owned = false;
26231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26232         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
26233         return ret_val;
26234 }
26235
26236 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
26237         LDKUnsignedChannelUpdate this_ptr_conv;
26238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26239         this_ptr_conv.is_owned = false;
26240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26241         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
26242 }
26243
26244 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
26245         LDKUnsignedChannelUpdate this_ptr_conv;
26246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26247         this_ptr_conv.is_owned = false;
26248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26249         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
26250         return ret_val;
26251 }
26252
26253 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
26254         LDKUnsignedChannelUpdate this_ptr_conv;
26255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26256         this_ptr_conv.is_owned = false;
26257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26258         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
26259 }
26260
26261 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
26262         LDKUnsignedChannelUpdate this_ptr_conv;
26263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26264         this_ptr_conv.is_owned = false;
26265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26266         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
26267         return ret_val;
26268 }
26269
26270 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26271         LDKUnsignedChannelUpdate this_ptr_conv;
26272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26273         this_ptr_conv.is_owned = false;
26274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26275         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
26276 }
26277
26278 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
26279         LDKUnsignedChannelUpdate this_ptr_conv;
26280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26281         this_ptr_conv.is_owned = false;
26282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26283         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
26284         return ret_val;
26285 }
26286
26287 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
26288         LDKUnsignedChannelUpdate this_ptr_conv;
26289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26290         this_ptr_conv.is_owned = false;
26291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26292         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
26293 }
26294
26295 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
26296         LDKUnsignedChannelUpdate this_ptr_conv;
26297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26298         this_ptr_conv.is_owned = false;
26299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26300         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
26301         return ret_val;
26302 }
26303
26304 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
26305         LDKUnsignedChannelUpdate this_ptr_conv;
26306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26307         this_ptr_conv.is_owned = false;
26308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26309         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
26310 }
26311
26312 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
26313         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
26314 uintptr_t ret_ref = 0;
26315 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26316 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26317 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26318 ret_ref = (uintptr_t)ret_var.inner;
26319 if (ret_var.is_owned) {
26320         ret_ref |= 1;
26321 }
26322         return ret_ref;
26323 }
26324 intptr_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
26325         LDKUnsignedChannelUpdate arg_conv;
26326         arg_conv.inner = (void*)(arg & (~1));
26327         arg_conv.is_owned = false;
26328         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26329         intptr_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
26330         return ret_val;
26331 }
26332
26333 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
26334         LDKUnsignedChannelUpdate orig_conv;
26335         orig_conv.inner = (void*)(orig & (~1));
26336         orig_conv.is_owned = false;
26337         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26338         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
26339         uintptr_t ret_ref = 0;
26340         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26341         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26343         ret_ref = (uintptr_t)ret_var.inner;
26344         if (ret_var.is_owned) {
26345                 ret_ref |= 1;
26346         }
26347         return ret_ref;
26348 }
26349
26350 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
26351         LDKChannelUpdate this_obj_conv;
26352         this_obj_conv.inner = (void*)(this_obj & (~1));
26353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26355         ChannelUpdate_free(this_obj_conv);
26356 }
26357
26358 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
26359         LDKChannelUpdate this_ptr_conv;
26360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26361         this_ptr_conv.is_owned = false;
26362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26363         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
26364         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
26365         return ret_arr;
26366 }
26367
26368 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
26369         LDKChannelUpdate this_ptr_conv;
26370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26371         this_ptr_conv.is_owned = false;
26372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26373         LDKSignature val_ref;
26374         CHECK(val->arr_len == 64);
26375         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
26376         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
26377 }
26378
26379 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
26380         LDKChannelUpdate this_ptr_conv;
26381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26382         this_ptr_conv.is_owned = false;
26383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26384         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
26385         uintptr_t ret_ref = 0;
26386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26389         ret_ref = (uintptr_t)ret_var.inner;
26390         if (ret_var.is_owned) {
26391                 ret_ref |= 1;
26392         }
26393         return ret_ref;
26394 }
26395
26396 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
26397         LDKChannelUpdate this_ptr_conv;
26398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26399         this_ptr_conv.is_owned = false;
26400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26401         LDKUnsignedChannelUpdate val_conv;
26402         val_conv.inner = (void*)(val & (~1));
26403         val_conv.is_owned = (val & 1) || (val == 0);
26404         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26405         val_conv = UnsignedChannelUpdate_clone(&val_conv);
26406         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
26407 }
26408
26409 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
26410         LDKSignature signature_arg_ref;
26411         CHECK(signature_arg->arr_len == 64);
26412         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
26413         LDKUnsignedChannelUpdate contents_arg_conv;
26414         contents_arg_conv.inner = (void*)(contents_arg & (~1));
26415         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
26416         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
26417         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
26418         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
26419         uintptr_t ret_ref = 0;
26420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26423         ret_ref = (uintptr_t)ret_var.inner;
26424         if (ret_var.is_owned) {
26425                 ret_ref |= 1;
26426         }
26427         return ret_ref;
26428 }
26429
26430 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
26431         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
26432 uintptr_t ret_ref = 0;
26433 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26434 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26435 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26436 ret_ref = (uintptr_t)ret_var.inner;
26437 if (ret_var.is_owned) {
26438         ret_ref |= 1;
26439 }
26440         return ret_ref;
26441 }
26442 intptr_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
26443         LDKChannelUpdate arg_conv;
26444         arg_conv.inner = (void*)(arg & (~1));
26445         arg_conv.is_owned = false;
26446         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26447         intptr_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
26448         return ret_val;
26449 }
26450
26451 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
26452         LDKChannelUpdate orig_conv;
26453         orig_conv.inner = (void*)(orig & (~1));
26454         orig_conv.is_owned = false;
26455         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26456         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
26457         uintptr_t ret_ref = 0;
26458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26461         ret_ref = (uintptr_t)ret_var.inner;
26462         if (ret_var.is_owned) {
26463                 ret_ref |= 1;
26464         }
26465         return ret_ref;
26466 }
26467
26468 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
26469         LDKQueryChannelRange this_obj_conv;
26470         this_obj_conv.inner = (void*)(this_obj & (~1));
26471         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26473         QueryChannelRange_free(this_obj_conv);
26474 }
26475
26476 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
26477         LDKQueryChannelRange this_ptr_conv;
26478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26479         this_ptr_conv.is_owned = false;
26480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26481         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26482         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
26483         return ret_arr;
26484 }
26485
26486 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26487         LDKQueryChannelRange 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         LDKThirtyTwoBytes val_ref;
26492         CHECK(val->arr_len == 32);
26493         memcpy(val_ref.data, val->elems, 32); FREE(val);
26494         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
26495 }
26496
26497 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
26498         LDKQueryChannelRange this_ptr_conv;
26499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26500         this_ptr_conv.is_owned = false;
26501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26502         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
26503         return ret_val;
26504 }
26505
26506 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
26507         LDKQueryChannelRange this_ptr_conv;
26508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26509         this_ptr_conv.is_owned = false;
26510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26511         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
26512 }
26513
26514 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
26515         LDKQueryChannelRange this_ptr_conv;
26516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26517         this_ptr_conv.is_owned = false;
26518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26519         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
26520         return ret_val;
26521 }
26522
26523 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
26524         LDKQueryChannelRange this_ptr_conv;
26525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26526         this_ptr_conv.is_owned = false;
26527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26528         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
26529 }
26530
26531 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) {
26532         LDKThirtyTwoBytes chain_hash_arg_ref;
26533         CHECK(chain_hash_arg->arr_len == 32);
26534         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
26535         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
26536         uintptr_t ret_ref = 0;
26537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26540         ret_ref = (uintptr_t)ret_var.inner;
26541         if (ret_var.is_owned) {
26542                 ret_ref |= 1;
26543         }
26544         return ret_ref;
26545 }
26546
26547 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
26548         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
26549 uintptr_t ret_ref = 0;
26550 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26551 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26552 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26553 ret_ref = (uintptr_t)ret_var.inner;
26554 if (ret_var.is_owned) {
26555         ret_ref |= 1;
26556 }
26557         return ret_ref;
26558 }
26559 intptr_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
26560         LDKQueryChannelRange arg_conv;
26561         arg_conv.inner = (void*)(arg & (~1));
26562         arg_conv.is_owned = false;
26563         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26564         intptr_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
26565         return ret_val;
26566 }
26567
26568 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
26569         LDKQueryChannelRange orig_conv;
26570         orig_conv.inner = (void*)(orig & (~1));
26571         orig_conv.is_owned = false;
26572         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26573         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
26574         uintptr_t ret_ref = 0;
26575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26578         ret_ref = (uintptr_t)ret_var.inner;
26579         if (ret_var.is_owned) {
26580                 ret_ref |= 1;
26581         }
26582         return ret_ref;
26583 }
26584
26585 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
26586         LDKReplyChannelRange this_obj_conv;
26587         this_obj_conv.inner = (void*)(this_obj & (~1));
26588         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26590         ReplyChannelRange_free(this_obj_conv);
26591 }
26592
26593 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
26594         LDKReplyChannelRange this_ptr_conv;
26595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26596         this_ptr_conv.is_owned = false;
26597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26598         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26599         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
26600         return ret_arr;
26601 }
26602
26603 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26604         LDKReplyChannelRange this_ptr_conv;
26605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26606         this_ptr_conv.is_owned = false;
26607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26608         LDKThirtyTwoBytes val_ref;
26609         CHECK(val->arr_len == 32);
26610         memcpy(val_ref.data, val->elems, 32); FREE(val);
26611         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
26612 }
26613
26614 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
26615         LDKReplyChannelRange this_ptr_conv;
26616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26617         this_ptr_conv.is_owned = false;
26618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26619         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
26620         return ret_val;
26621 }
26622
26623 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
26624         LDKReplyChannelRange this_ptr_conv;
26625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26626         this_ptr_conv.is_owned = false;
26627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26628         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
26629 }
26630
26631 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
26632         LDKReplyChannelRange this_ptr_conv;
26633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26634         this_ptr_conv.is_owned = false;
26635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26636         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
26637         return ret_val;
26638 }
26639
26640 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
26641         LDKReplyChannelRange this_ptr_conv;
26642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26643         this_ptr_conv.is_owned = false;
26644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26645         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
26646 }
26647
26648 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
26649         LDKReplyChannelRange this_ptr_conv;
26650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26651         this_ptr_conv.is_owned = false;
26652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26653         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
26654         return ret_val;
26655 }
26656
26657 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
26658         LDKReplyChannelRange this_ptr_conv;
26659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26660         this_ptr_conv.is_owned = false;
26661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26662         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
26663 }
26664
26665 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
26666         LDKReplyChannelRange this_ptr_conv;
26667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26668         this_ptr_conv.is_owned = false;
26669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26670         LDKCVec_u64Z val_constr;
26671         val_constr.datalen = val->arr_len;
26672         if (val_constr.datalen > 0)
26673                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26674         else
26675                 val_constr.data = NULL;
26676         int64_t* val_vals = val->elems /* XXX val leaks */;
26677         for (size_t i = 0; i < val_constr.datalen; i++) {
26678                 int64_t val_conv_8 = val_vals[i];
26679                 val_constr.data[i] = val_conv_8;
26680         }
26681         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
26682 }
26683
26684 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) {
26685         LDKThirtyTwoBytes chain_hash_arg_ref;
26686         CHECK(chain_hash_arg->arr_len == 32);
26687         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
26688         LDKCVec_u64Z short_channel_ids_arg_constr;
26689         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
26690         if (short_channel_ids_arg_constr.datalen > 0)
26691                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26692         else
26693                 short_channel_ids_arg_constr.data = NULL;
26694         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
26695         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
26696                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
26697                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
26698         }
26699         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
26700         uintptr_t ret_ref = 0;
26701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26704         ret_ref = (uintptr_t)ret_var.inner;
26705         if (ret_var.is_owned) {
26706                 ret_ref |= 1;
26707         }
26708         return ret_ref;
26709 }
26710
26711 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
26712         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
26713 uintptr_t ret_ref = 0;
26714 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26715 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26716 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26717 ret_ref = (uintptr_t)ret_var.inner;
26718 if (ret_var.is_owned) {
26719         ret_ref |= 1;
26720 }
26721         return ret_ref;
26722 }
26723 intptr_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
26724         LDKReplyChannelRange arg_conv;
26725         arg_conv.inner = (void*)(arg & (~1));
26726         arg_conv.is_owned = false;
26727         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26728         intptr_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
26729         return ret_val;
26730 }
26731
26732 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
26733         LDKReplyChannelRange orig_conv;
26734         orig_conv.inner = (void*)(orig & (~1));
26735         orig_conv.is_owned = false;
26736         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26737         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
26738         uintptr_t ret_ref = 0;
26739         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26740         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26742         ret_ref = (uintptr_t)ret_var.inner;
26743         if (ret_var.is_owned) {
26744                 ret_ref |= 1;
26745         }
26746         return ret_ref;
26747 }
26748
26749 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
26750         LDKQueryShortChannelIds this_obj_conv;
26751         this_obj_conv.inner = (void*)(this_obj & (~1));
26752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26754         QueryShortChannelIds_free(this_obj_conv);
26755 }
26756
26757 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
26758         LDKQueryShortChannelIds this_ptr_conv;
26759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26760         this_ptr_conv.is_owned = false;
26761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26762         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26763         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
26764         return ret_arr;
26765 }
26766
26767 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26768         LDKQueryShortChannelIds this_ptr_conv;
26769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26770         this_ptr_conv.is_owned = false;
26771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26772         LDKThirtyTwoBytes val_ref;
26773         CHECK(val->arr_len == 32);
26774         memcpy(val_ref.data, val->elems, 32); FREE(val);
26775         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
26776 }
26777
26778 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
26779         LDKQueryShortChannelIds this_ptr_conv;
26780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26781         this_ptr_conv.is_owned = false;
26782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26783         LDKCVec_u64Z val_constr;
26784         val_constr.datalen = val->arr_len;
26785         if (val_constr.datalen > 0)
26786                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26787         else
26788                 val_constr.data = NULL;
26789         int64_t* val_vals = val->elems /* XXX val leaks */;
26790         for (size_t i = 0; i < val_constr.datalen; i++) {
26791                 int64_t val_conv_8 = val_vals[i];
26792                 val_constr.data[i] = val_conv_8;
26793         }
26794         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
26795 }
26796
26797 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
26798         LDKThirtyTwoBytes chain_hash_arg_ref;
26799         CHECK(chain_hash_arg->arr_len == 32);
26800         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
26801         LDKCVec_u64Z short_channel_ids_arg_constr;
26802         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
26803         if (short_channel_ids_arg_constr.datalen > 0)
26804                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26805         else
26806                 short_channel_ids_arg_constr.data = NULL;
26807         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
26808         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
26809                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
26810                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
26811         }
26812         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
26813         uintptr_t ret_ref = 0;
26814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26817         ret_ref = (uintptr_t)ret_var.inner;
26818         if (ret_var.is_owned) {
26819                 ret_ref |= 1;
26820         }
26821         return ret_ref;
26822 }
26823
26824 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
26825         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
26826 uintptr_t ret_ref = 0;
26827 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26828 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26829 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26830 ret_ref = (uintptr_t)ret_var.inner;
26831 if (ret_var.is_owned) {
26832         ret_ref |= 1;
26833 }
26834         return ret_ref;
26835 }
26836 intptr_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
26837         LDKQueryShortChannelIds arg_conv;
26838         arg_conv.inner = (void*)(arg & (~1));
26839         arg_conv.is_owned = false;
26840         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26841         intptr_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
26842         return ret_val;
26843 }
26844
26845 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
26846         LDKQueryShortChannelIds orig_conv;
26847         orig_conv.inner = (void*)(orig & (~1));
26848         orig_conv.is_owned = false;
26849         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26850         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
26851         uintptr_t ret_ref = 0;
26852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26855         ret_ref = (uintptr_t)ret_var.inner;
26856         if (ret_var.is_owned) {
26857                 ret_ref |= 1;
26858         }
26859         return ret_ref;
26860 }
26861
26862 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
26863         LDKReplyShortChannelIdsEnd this_obj_conv;
26864         this_obj_conv.inner = (void*)(this_obj & (~1));
26865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26867         ReplyShortChannelIdsEnd_free(this_obj_conv);
26868 }
26869
26870 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
26871         LDKReplyShortChannelIdsEnd this_ptr_conv;
26872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26873         this_ptr_conv.is_owned = false;
26874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26875         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26876         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
26877         return ret_arr;
26878 }
26879
26880 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26881         LDKReplyShortChannelIdsEnd this_ptr_conv;
26882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26883         this_ptr_conv.is_owned = false;
26884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26885         LDKThirtyTwoBytes val_ref;
26886         CHECK(val->arr_len == 32);
26887         memcpy(val_ref.data, val->elems, 32); FREE(val);
26888         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
26889 }
26890
26891 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
26892         LDKReplyShortChannelIdsEnd this_ptr_conv;
26893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26894         this_ptr_conv.is_owned = false;
26895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26896         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
26897         return ret_val;
26898 }
26899
26900 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
26901         LDKReplyShortChannelIdsEnd this_ptr_conv;
26902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26903         this_ptr_conv.is_owned = false;
26904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26905         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
26906 }
26907
26908 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
26909         LDKThirtyTwoBytes chain_hash_arg_ref;
26910         CHECK(chain_hash_arg->arr_len == 32);
26911         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
26912         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
26913         uintptr_t ret_ref = 0;
26914         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26915         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26917         ret_ref = (uintptr_t)ret_var.inner;
26918         if (ret_var.is_owned) {
26919                 ret_ref |= 1;
26920         }
26921         return ret_ref;
26922 }
26923
26924 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
26925         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
26926 uintptr_t ret_ref = 0;
26927 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26928 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26929 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26930 ret_ref = (uintptr_t)ret_var.inner;
26931 if (ret_var.is_owned) {
26932         ret_ref |= 1;
26933 }
26934         return ret_ref;
26935 }
26936 intptr_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
26937         LDKReplyShortChannelIdsEnd arg_conv;
26938         arg_conv.inner = (void*)(arg & (~1));
26939         arg_conv.is_owned = false;
26940         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26941         intptr_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
26942         return ret_val;
26943 }
26944
26945 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
26946         LDKReplyShortChannelIdsEnd orig_conv;
26947         orig_conv.inner = (void*)(orig & (~1));
26948         orig_conv.is_owned = false;
26949         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26950         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
26951         uintptr_t ret_ref = 0;
26952         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26953         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26955         ret_ref = (uintptr_t)ret_var.inner;
26956         if (ret_var.is_owned) {
26957                 ret_ref |= 1;
26958         }
26959         return ret_ref;
26960 }
26961
26962 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
26963         LDKGossipTimestampFilter this_obj_conv;
26964         this_obj_conv.inner = (void*)(this_obj & (~1));
26965         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26967         GossipTimestampFilter_free(this_obj_conv);
26968 }
26969
26970 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
26971         LDKGossipTimestampFilter this_ptr_conv;
26972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26973         this_ptr_conv.is_owned = false;
26974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26975         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26976         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
26977         return ret_arr;
26978 }
26979
26980 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26981         LDKGossipTimestampFilter this_ptr_conv;
26982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26983         this_ptr_conv.is_owned = false;
26984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26985         LDKThirtyTwoBytes val_ref;
26986         CHECK(val->arr_len == 32);
26987         memcpy(val_ref.data, val->elems, 32); FREE(val);
26988         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
26989 }
26990
26991 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
26992         LDKGossipTimestampFilter this_ptr_conv;
26993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26994         this_ptr_conv.is_owned = false;
26995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26996         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
26997         return ret_val;
26998 }
26999
27000 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
27001         LDKGossipTimestampFilter this_ptr_conv;
27002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27003         this_ptr_conv.is_owned = false;
27004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27005         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
27006 }
27007
27008 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
27009         LDKGossipTimestampFilter this_ptr_conv;
27010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27011         this_ptr_conv.is_owned = false;
27012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27013         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
27014         return ret_val;
27015 }
27016
27017 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
27018         LDKGossipTimestampFilter this_ptr_conv;
27019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27020         this_ptr_conv.is_owned = false;
27021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27022         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
27023 }
27024
27025 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) {
27026         LDKThirtyTwoBytes chain_hash_arg_ref;
27027         CHECK(chain_hash_arg->arr_len == 32);
27028         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
27029         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
27030         uintptr_t ret_ref = 0;
27031         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27032         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27034         ret_ref = (uintptr_t)ret_var.inner;
27035         if (ret_var.is_owned) {
27036                 ret_ref |= 1;
27037         }
27038         return ret_ref;
27039 }
27040
27041 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
27042         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
27043 uintptr_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 intptr_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
27054         LDKGossipTimestampFilter arg_conv;
27055         arg_conv.inner = (void*)(arg & (~1));
27056         arg_conv.is_owned = false;
27057         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27058         intptr_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
27059         return ret_val;
27060 }
27061
27062 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
27063         LDKGossipTimestampFilter orig_conv;
27064         orig_conv.inner = (void*)(orig & (~1));
27065         orig_conv.is_owned = false;
27066         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27067         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
27068         uintptr_t ret_ref = 0;
27069         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27070         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27072         ret_ref = (uintptr_t)ret_var.inner;
27073         if (ret_var.is_owned) {
27074                 ret_ref |= 1;
27075         }
27076         return ret_ref;
27077 }
27078
27079 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
27080         if ((this_ptr & 1) != 0) return;
27081         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27082         CHECK_ACCESS(this_ptr_ptr);
27083         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
27084         FREE((void*)this_ptr);
27085         ErrorAction_free(this_ptr_conv);
27086 }
27087
27088 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
27089         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27090         *ret_copy = ErrorAction_clone(arg);
27091 uintptr_t ret_ref = (uintptr_t)ret_copy;
27092         return ret_ref;
27093 }
27094 intptr_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
27095         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
27096         intptr_t ret_val = ErrorAction_clone_ptr(arg_conv);
27097         return ret_val;
27098 }
27099
27100 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
27101         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
27102         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27103         *ret_copy = ErrorAction_clone(orig_conv);
27104         uintptr_t ret_ref = (uintptr_t)ret_copy;
27105         return ret_ref;
27106 }
27107
27108 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
27109         LDKErrorMessage msg_conv;
27110         msg_conv.inner = (void*)(msg & (~1));
27111         msg_conv.is_owned = (msg & 1) || (msg == 0);
27112         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27113         msg_conv = ErrorMessage_clone(&msg_conv);
27114         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27115         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
27116         uintptr_t ret_ref = (uintptr_t)ret_copy;
27117         return ret_ref;
27118 }
27119
27120 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
27121         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27122         *ret_copy = ErrorAction_ignore_error();
27123         uintptr_t ret_ref = (uintptr_t)ret_copy;
27124         return ret_ref;
27125 }
27126
27127 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
27128         LDKLevel a_conv = LDKLevel_from_js(a);
27129         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27130         *ret_copy = ErrorAction_ignore_and_log(a_conv);
27131         uintptr_t ret_ref = (uintptr_t)ret_copy;
27132         return ret_ref;
27133 }
27134
27135 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
27136         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27137         *ret_copy = ErrorAction_ignore_duplicate_gossip();
27138         uintptr_t ret_ref = (uintptr_t)ret_copy;
27139         return ret_ref;
27140 }
27141
27142 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
27143         LDKErrorMessage msg_conv;
27144         msg_conv.inner = (void*)(msg & (~1));
27145         msg_conv.is_owned = (msg & 1) || (msg == 0);
27146         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27147         msg_conv = ErrorMessage_clone(&msg_conv);
27148         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27149         *ret_copy = ErrorAction_send_error_message(msg_conv);
27150         uintptr_t ret_ref = (uintptr_t)ret_copy;
27151         return ret_ref;
27152 }
27153
27154 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
27155         LDKLightningError this_obj_conv;
27156         this_obj_conv.inner = (void*)(this_obj & (~1));
27157         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27159         LightningError_free(this_obj_conv);
27160 }
27161
27162 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
27163         LDKLightningError this_ptr_conv;
27164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27165         this_ptr_conv.is_owned = false;
27166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27167         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
27168         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27169         Str_free(ret_str);
27170         return ret_conv;
27171 }
27172
27173 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
27174         LDKLightningError this_ptr_conv;
27175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27176         this_ptr_conv.is_owned = false;
27177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27178         LDKStr val_conv = str_ref_to_owned_c(val);
27179         LightningError_set_err(&this_ptr_conv, val_conv);
27180 }
27181
27182 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
27183         LDKLightningError this_ptr_conv;
27184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27185         this_ptr_conv.is_owned = false;
27186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27187         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27188         *ret_copy = LightningError_get_action(&this_ptr_conv);
27189         uintptr_t ret_ref = (uintptr_t)ret_copy;
27190         return ret_ref;
27191 }
27192
27193 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
27194         LDKLightningError this_ptr_conv;
27195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27196         this_ptr_conv.is_owned = false;
27197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27198         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27199         CHECK_ACCESS(val_ptr);
27200         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
27201         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
27202         LightningError_set_action(&this_ptr_conv, val_conv);
27203 }
27204
27205 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
27206         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
27207         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
27208         CHECK_ACCESS(action_arg_ptr);
27209         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
27210         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
27211         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
27212         uintptr_t ret_ref = 0;
27213         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27214         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27216         ret_ref = (uintptr_t)ret_var.inner;
27217         if (ret_var.is_owned) {
27218                 ret_ref |= 1;
27219         }
27220         return ret_ref;
27221 }
27222
27223 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
27224         LDKLightningError ret_var = LightningError_clone(arg);
27225 uintptr_t ret_ref = 0;
27226 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27227 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27228 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27229 ret_ref = (uintptr_t)ret_var.inner;
27230 if (ret_var.is_owned) {
27231         ret_ref |= 1;
27232 }
27233         return ret_ref;
27234 }
27235 intptr_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
27236         LDKLightningError arg_conv;
27237         arg_conv.inner = (void*)(arg & (~1));
27238         arg_conv.is_owned = false;
27239         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27240         intptr_t ret_val = LightningError_clone_ptr(&arg_conv);
27241         return ret_val;
27242 }
27243
27244 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
27245         LDKLightningError orig_conv;
27246         orig_conv.inner = (void*)(orig & (~1));
27247         orig_conv.is_owned = false;
27248         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27249         LDKLightningError ret_var = LightningError_clone(&orig_conv);
27250         uintptr_t ret_ref = 0;
27251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27254         ret_ref = (uintptr_t)ret_var.inner;
27255         if (ret_var.is_owned) {
27256                 ret_ref |= 1;
27257         }
27258         return ret_ref;
27259 }
27260
27261 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
27262         LDKCommitmentUpdate this_obj_conv;
27263         this_obj_conv.inner = (void*)(this_obj & (~1));
27264         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27266         CommitmentUpdate_free(this_obj_conv);
27267 }
27268
27269 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
27270         LDKCommitmentUpdate this_ptr_conv;
27271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27272         this_ptr_conv.is_owned = false;
27273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27274         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
27275         uint32_tArray ret_arr = NULL;
27276         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27277         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27278         for (size_t p = 0; p < ret_var.datalen; p++) {
27279                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
27280                 uintptr_t ret_conv_15_ref = 0;
27281                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27282                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27283                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
27284                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
27285                 if (ret_conv_15_var.is_owned) {
27286                         ret_conv_15_ref |= 1;
27287                 }
27288                 ret_arr_ptr[p] = ret_conv_15_ref;
27289         }
27290         
27291         FREE(ret_var.data);
27292         return ret_arr;
27293 }
27294
27295 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
27296         LDKCommitmentUpdate this_ptr_conv;
27297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27298         this_ptr_conv.is_owned = false;
27299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27300         LDKCVec_UpdateAddHTLCZ val_constr;
27301         val_constr.datalen = val->arr_len;
27302         if (val_constr.datalen > 0)
27303                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
27304         else
27305                 val_constr.data = NULL;
27306         uint32_t* val_vals = val->elems /* XXX val leaks */;
27307         for (size_t p = 0; p < val_constr.datalen; p++) {
27308                 uint32_t val_conv_15 = val_vals[p];
27309                 LDKUpdateAddHTLC val_conv_15_conv;
27310                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
27311                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
27312                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
27313                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
27314                 val_constr.data[p] = val_conv_15_conv;
27315         }
27316         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
27317 }
27318
27319 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
27320         LDKCommitmentUpdate this_ptr_conv;
27321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27322         this_ptr_conv.is_owned = false;
27323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27324         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
27325         uint32_tArray ret_arr = NULL;
27326         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27327         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27328         for (size_t t = 0; t < ret_var.datalen; t++) {
27329                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
27330                 uintptr_t ret_conv_19_ref = 0;
27331                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27332                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27333                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
27334                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
27335                 if (ret_conv_19_var.is_owned) {
27336                         ret_conv_19_ref |= 1;
27337                 }
27338                 ret_arr_ptr[t] = ret_conv_19_ref;
27339         }
27340         
27341         FREE(ret_var.data);
27342         return ret_arr;
27343 }
27344
27345 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
27346         LDKCommitmentUpdate this_ptr_conv;
27347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27348         this_ptr_conv.is_owned = false;
27349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27350         LDKCVec_UpdateFulfillHTLCZ val_constr;
27351         val_constr.datalen = val->arr_len;
27352         if (val_constr.datalen > 0)
27353                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
27354         else
27355                 val_constr.data = NULL;
27356         uint32_t* val_vals = val->elems /* XXX val leaks */;
27357         for (size_t t = 0; t < val_constr.datalen; t++) {
27358                 uint32_t val_conv_19 = val_vals[t];
27359                 LDKUpdateFulfillHTLC val_conv_19_conv;
27360                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
27361                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
27362                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
27363                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
27364                 val_constr.data[t] = val_conv_19_conv;
27365         }
27366         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
27367 }
27368
27369 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
27370         LDKCommitmentUpdate this_ptr_conv;
27371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27372         this_ptr_conv.is_owned = false;
27373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27374         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
27375         uint32_tArray ret_arr = NULL;
27376         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27377         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27378         for (size_t q = 0; q < ret_var.datalen; q++) {
27379                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
27380                 uintptr_t ret_conv_16_ref = 0;
27381                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27382                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27383                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
27384                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
27385                 if (ret_conv_16_var.is_owned) {
27386                         ret_conv_16_ref |= 1;
27387                 }
27388                 ret_arr_ptr[q] = ret_conv_16_ref;
27389         }
27390         
27391         FREE(ret_var.data);
27392         return ret_arr;
27393 }
27394
27395 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
27396         LDKCommitmentUpdate this_ptr_conv;
27397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27398         this_ptr_conv.is_owned = false;
27399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27400         LDKCVec_UpdateFailHTLCZ val_constr;
27401         val_constr.datalen = val->arr_len;
27402         if (val_constr.datalen > 0)
27403                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
27404         else
27405                 val_constr.data = NULL;
27406         uint32_t* val_vals = val->elems /* XXX val leaks */;
27407         for (size_t q = 0; q < val_constr.datalen; q++) {
27408                 uint32_t val_conv_16 = val_vals[q];
27409                 LDKUpdateFailHTLC val_conv_16_conv;
27410                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
27411                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
27412                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
27413                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
27414                 val_constr.data[q] = val_conv_16_conv;
27415         }
27416         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
27417 }
27418
27419 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
27420         LDKCommitmentUpdate this_ptr_conv;
27421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27422         this_ptr_conv.is_owned = false;
27423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27424         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
27425         uint32_tArray ret_arr = NULL;
27426         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27427         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27428         for (size_t z = 0; z < ret_var.datalen; z++) {
27429                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
27430                 uintptr_t ret_conv_25_ref = 0;
27431                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27432                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27433                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
27434                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
27435                 if (ret_conv_25_var.is_owned) {
27436                         ret_conv_25_ref |= 1;
27437                 }
27438                 ret_arr_ptr[z] = ret_conv_25_ref;
27439         }
27440         
27441         FREE(ret_var.data);
27442         return ret_arr;
27443 }
27444
27445 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) {
27446         LDKCommitmentUpdate this_ptr_conv;
27447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27448         this_ptr_conv.is_owned = false;
27449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27450         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
27451         val_constr.datalen = val->arr_len;
27452         if (val_constr.datalen > 0)
27453                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
27454         else
27455                 val_constr.data = NULL;
27456         uint32_t* val_vals = val->elems /* XXX val leaks */;
27457         for (size_t z = 0; z < val_constr.datalen; z++) {
27458                 uint32_t val_conv_25 = val_vals[z];
27459                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
27460                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
27461                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
27462                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
27463                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
27464                 val_constr.data[z] = val_conv_25_conv;
27465         }
27466         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
27467 }
27468
27469 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
27470         LDKCommitmentUpdate this_ptr_conv;
27471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27472         this_ptr_conv.is_owned = false;
27473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27474         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
27475         uintptr_t ret_ref = 0;
27476         if ((uintptr_t)ret_var.inner > 4096) {
27477                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27478                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27480                 ret_ref = (uintptr_t)ret_var.inner;
27481                 if (ret_var.is_owned) {
27482                         ret_ref |= 1;
27483                 }
27484         }
27485         return ret_ref;
27486 }
27487
27488 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
27489         LDKCommitmentUpdate this_ptr_conv;
27490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27491         this_ptr_conv.is_owned = false;
27492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27493         LDKUpdateFee val_conv;
27494         val_conv.inner = (void*)(val & (~1));
27495         val_conv.is_owned = (val & 1) || (val == 0);
27496         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27497         val_conv = UpdateFee_clone(&val_conv);
27498         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
27499 }
27500
27501 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
27502         LDKCommitmentUpdate this_ptr_conv;
27503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27504         this_ptr_conv.is_owned = false;
27505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27506         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
27507         uintptr_t ret_ref = 0;
27508         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27509         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27511         ret_ref = (uintptr_t)ret_var.inner;
27512         if (ret_var.is_owned) {
27513                 ret_ref |= 1;
27514         }
27515         return ret_ref;
27516 }
27517
27518 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
27519         LDKCommitmentUpdate this_ptr_conv;
27520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27521         this_ptr_conv.is_owned = false;
27522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27523         LDKCommitmentSigned val_conv;
27524         val_conv.inner = (void*)(val & (~1));
27525         val_conv.is_owned = (val & 1) || (val == 0);
27526         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27527         val_conv = CommitmentSigned_clone(&val_conv);
27528         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
27529 }
27530
27531 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) {
27532         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
27533         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
27534         if (update_add_htlcs_arg_constr.datalen > 0)
27535                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
27536         else
27537                 update_add_htlcs_arg_constr.data = NULL;
27538         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems /* XXX update_add_htlcs_arg leaks */;
27539         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
27540                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
27541                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
27542                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
27543                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
27544                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
27545                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
27546                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
27547         }
27548         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
27549         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
27550         if (update_fulfill_htlcs_arg_constr.datalen > 0)
27551                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
27552         else
27553                 update_fulfill_htlcs_arg_constr.data = NULL;
27554         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems /* XXX update_fulfill_htlcs_arg leaks */;
27555         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
27556                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
27557                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
27558                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
27559                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
27560                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
27561                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
27562                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
27563         }
27564         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
27565         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
27566         if (update_fail_htlcs_arg_constr.datalen > 0)
27567                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
27568         else
27569                 update_fail_htlcs_arg_constr.data = NULL;
27570         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems /* XXX update_fail_htlcs_arg leaks */;
27571         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
27572                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
27573                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
27574                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
27575                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
27576                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
27577                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
27578                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
27579         }
27580         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
27581         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
27582         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
27583                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
27584         else
27585                 update_fail_malformed_htlcs_arg_constr.data = NULL;
27586         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems /* XXX update_fail_malformed_htlcs_arg leaks */;
27587         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
27588                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
27589                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
27590                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
27591                 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);
27592                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
27593                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
27594                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
27595         }
27596         LDKUpdateFee update_fee_arg_conv;
27597         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
27598         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
27599         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
27600         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
27601         LDKCommitmentSigned commitment_signed_arg_conv;
27602         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
27603         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
27604         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
27605         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
27606         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);
27607         uintptr_t ret_ref = 0;
27608         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27609         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27611         ret_ref = (uintptr_t)ret_var.inner;
27612         if (ret_var.is_owned) {
27613                 ret_ref |= 1;
27614         }
27615         return ret_ref;
27616 }
27617
27618 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
27619         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
27620 uintptr_t ret_ref = 0;
27621 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27622 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27623 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27624 ret_ref = (uintptr_t)ret_var.inner;
27625 if (ret_var.is_owned) {
27626         ret_ref |= 1;
27627 }
27628         return ret_ref;
27629 }
27630 intptr_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
27631         LDKCommitmentUpdate arg_conv;
27632         arg_conv.inner = (void*)(arg & (~1));
27633         arg_conv.is_owned = false;
27634         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27635         intptr_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
27636         return ret_val;
27637 }
27638
27639 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
27640         LDKCommitmentUpdate orig_conv;
27641         orig_conv.inner = (void*)(orig & (~1));
27642         orig_conv.is_owned = false;
27643         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27644         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
27645         uintptr_t ret_ref = 0;
27646         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27647         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27649         ret_ref = (uintptr_t)ret_var.inner;
27650         if (ret_var.is_owned) {
27651                 ret_ref |= 1;
27652         }
27653         return ret_ref;
27654 }
27655
27656 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
27657         if ((this_ptr & 1) != 0) return;
27658         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27659         CHECK_ACCESS(this_ptr_ptr);
27660         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
27661         FREE((void*)this_ptr);
27662         ChannelMessageHandler_free(this_ptr_conv);
27663 }
27664
27665 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
27666         if ((this_ptr & 1) != 0) return;
27667         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27668         CHECK_ACCESS(this_ptr_ptr);
27669         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
27670         FREE((void*)this_ptr);
27671         RoutingMessageHandler_free(this_ptr_conv);
27672 }
27673
27674 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
27675         LDKAcceptChannel obj_conv;
27676         obj_conv.inner = (void*)(obj & (~1));
27677         obj_conv.is_owned = false;
27678         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27679         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
27680         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27681         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27682         CVec_u8Z_free(ret_var);
27683         return ret_arr;
27684 }
27685
27686 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
27687         LDKu8slice ser_ref;
27688         ser_ref.datalen = ser->arr_len;
27689         ser_ref.data = ser->elems /* XXX ser leaks */;
27690         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
27691         *ret_conv = AcceptChannel_read(ser_ref);
27692         return (uintptr_t)ret_conv;
27693 }
27694
27695 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
27696         LDKAnnouncementSignatures obj_conv;
27697         obj_conv.inner = (void*)(obj & (~1));
27698         obj_conv.is_owned = false;
27699         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27700         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
27701         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27702         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27703         CVec_u8Z_free(ret_var);
27704         return ret_arr;
27705 }
27706
27707 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
27708         LDKu8slice ser_ref;
27709         ser_ref.datalen = ser->arr_len;
27710         ser_ref.data = ser->elems /* XXX ser leaks */;
27711         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
27712         *ret_conv = AnnouncementSignatures_read(ser_ref);
27713         return (uintptr_t)ret_conv;
27714 }
27715
27716 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
27717         LDKChannelReestablish obj_conv;
27718         obj_conv.inner = (void*)(obj & (~1));
27719         obj_conv.is_owned = false;
27720         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27721         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
27722         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27723         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27724         CVec_u8Z_free(ret_var);
27725         return ret_arr;
27726 }
27727
27728 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
27729         LDKu8slice ser_ref;
27730         ser_ref.datalen = ser->arr_len;
27731         ser_ref.data = ser->elems /* XXX ser leaks */;
27732         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
27733         *ret_conv = ChannelReestablish_read(ser_ref);
27734         return (uintptr_t)ret_conv;
27735 }
27736
27737 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
27738         LDKClosingSigned obj_conv;
27739         obj_conv.inner = (void*)(obj & (~1));
27740         obj_conv.is_owned = false;
27741         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27742         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
27743         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27744         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27745         CVec_u8Z_free(ret_var);
27746         return ret_arr;
27747 }
27748
27749 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
27750         LDKu8slice ser_ref;
27751         ser_ref.datalen = ser->arr_len;
27752         ser_ref.data = ser->elems /* XXX ser leaks */;
27753         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
27754         *ret_conv = ClosingSigned_read(ser_ref);
27755         return (uintptr_t)ret_conv;
27756 }
27757
27758 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
27759         LDKClosingSignedFeeRange obj_conv;
27760         obj_conv.inner = (void*)(obj & (~1));
27761         obj_conv.is_owned = false;
27762         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27763         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
27764         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27765         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27766         CVec_u8Z_free(ret_var);
27767         return ret_arr;
27768 }
27769
27770 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
27771         LDKu8slice ser_ref;
27772         ser_ref.datalen = ser->arr_len;
27773         ser_ref.data = ser->elems /* XXX ser leaks */;
27774         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
27775         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
27776         return (uintptr_t)ret_conv;
27777 }
27778
27779 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
27780         LDKCommitmentSigned obj_conv;
27781         obj_conv.inner = (void*)(obj & (~1));
27782         obj_conv.is_owned = false;
27783         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27784         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
27785         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27786         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27787         CVec_u8Z_free(ret_var);
27788         return ret_arr;
27789 }
27790
27791 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
27792         LDKu8slice ser_ref;
27793         ser_ref.datalen = ser->arr_len;
27794         ser_ref.data = ser->elems /* XXX ser leaks */;
27795         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
27796         *ret_conv = CommitmentSigned_read(ser_ref);
27797         return (uintptr_t)ret_conv;
27798 }
27799
27800 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
27801         LDKFundingCreated obj_conv;
27802         obj_conv.inner = (void*)(obj & (~1));
27803         obj_conv.is_owned = false;
27804         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27805         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
27806         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27807         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27808         CVec_u8Z_free(ret_var);
27809         return ret_arr;
27810 }
27811
27812 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
27813         LDKu8slice ser_ref;
27814         ser_ref.datalen = ser->arr_len;
27815         ser_ref.data = ser->elems /* XXX ser leaks */;
27816         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
27817         *ret_conv = FundingCreated_read(ser_ref);
27818         return (uintptr_t)ret_conv;
27819 }
27820
27821 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
27822         LDKFundingSigned obj_conv;
27823         obj_conv.inner = (void*)(obj & (~1));
27824         obj_conv.is_owned = false;
27825         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27826         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
27827         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27828         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27829         CVec_u8Z_free(ret_var);
27830         return ret_arr;
27831 }
27832
27833 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
27834         LDKu8slice ser_ref;
27835         ser_ref.datalen = ser->arr_len;
27836         ser_ref.data = ser->elems /* XXX ser leaks */;
27837         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
27838         *ret_conv = FundingSigned_read(ser_ref);
27839         return (uintptr_t)ret_conv;
27840 }
27841
27842 int8_tArray  __attribute__((export_name("TS_FundingLocked_write"))) TS_FundingLocked_write(uint32_t obj) {
27843         LDKFundingLocked obj_conv;
27844         obj_conv.inner = (void*)(obj & (~1));
27845         obj_conv.is_owned = false;
27846         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27847         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
27848         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27849         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27850         CVec_u8Z_free(ret_var);
27851         return ret_arr;
27852 }
27853
27854 uint32_t  __attribute__((export_name("TS_FundingLocked_read"))) TS_FundingLocked_read(int8_tArray ser) {
27855         LDKu8slice ser_ref;
27856         ser_ref.datalen = ser->arr_len;
27857         ser_ref.data = ser->elems /* XXX ser leaks */;
27858         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
27859         *ret_conv = FundingLocked_read(ser_ref);
27860         return (uintptr_t)ret_conv;
27861 }
27862
27863 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
27864         LDKInit obj_conv;
27865         obj_conv.inner = (void*)(obj & (~1));
27866         obj_conv.is_owned = false;
27867         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27868         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
27869         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27870         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27871         CVec_u8Z_free(ret_var);
27872         return ret_arr;
27873 }
27874
27875 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
27876         LDKu8slice ser_ref;
27877         ser_ref.datalen = ser->arr_len;
27878         ser_ref.data = ser->elems /* XXX ser leaks */;
27879         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
27880         *ret_conv = Init_read(ser_ref);
27881         return (uintptr_t)ret_conv;
27882 }
27883
27884 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
27885         LDKOpenChannel obj_conv;
27886         obj_conv.inner = (void*)(obj & (~1));
27887         obj_conv.is_owned = false;
27888         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27889         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
27890         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27891         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27892         CVec_u8Z_free(ret_var);
27893         return ret_arr;
27894 }
27895
27896 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
27897         LDKu8slice ser_ref;
27898         ser_ref.datalen = ser->arr_len;
27899         ser_ref.data = ser->elems /* XXX ser leaks */;
27900         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
27901         *ret_conv = OpenChannel_read(ser_ref);
27902         return (uintptr_t)ret_conv;
27903 }
27904
27905 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
27906         LDKRevokeAndACK obj_conv;
27907         obj_conv.inner = (void*)(obj & (~1));
27908         obj_conv.is_owned = false;
27909         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27910         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
27911         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27912         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27913         CVec_u8Z_free(ret_var);
27914         return ret_arr;
27915 }
27916
27917 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
27918         LDKu8slice ser_ref;
27919         ser_ref.datalen = ser->arr_len;
27920         ser_ref.data = ser->elems /* XXX ser leaks */;
27921         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
27922         *ret_conv = RevokeAndACK_read(ser_ref);
27923         return (uintptr_t)ret_conv;
27924 }
27925
27926 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
27927         LDKShutdown obj_conv;
27928         obj_conv.inner = (void*)(obj & (~1));
27929         obj_conv.is_owned = false;
27930         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27931         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
27932         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27933         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27934         CVec_u8Z_free(ret_var);
27935         return ret_arr;
27936 }
27937
27938 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
27939         LDKu8slice ser_ref;
27940         ser_ref.datalen = ser->arr_len;
27941         ser_ref.data = ser->elems /* XXX ser leaks */;
27942         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
27943         *ret_conv = Shutdown_read(ser_ref);
27944         return (uintptr_t)ret_conv;
27945 }
27946
27947 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
27948         LDKUpdateFailHTLC obj_conv;
27949         obj_conv.inner = (void*)(obj & (~1));
27950         obj_conv.is_owned = false;
27951         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27952         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
27953         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27954         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27955         CVec_u8Z_free(ret_var);
27956         return ret_arr;
27957 }
27958
27959 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
27960         LDKu8slice ser_ref;
27961         ser_ref.datalen = ser->arr_len;
27962         ser_ref.data = ser->elems /* XXX ser leaks */;
27963         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
27964         *ret_conv = UpdateFailHTLC_read(ser_ref);
27965         return (uintptr_t)ret_conv;
27966 }
27967
27968 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
27969         LDKUpdateFailMalformedHTLC obj_conv;
27970         obj_conv.inner = (void*)(obj & (~1));
27971         obj_conv.is_owned = false;
27972         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27973         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
27974         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27975         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27976         CVec_u8Z_free(ret_var);
27977         return ret_arr;
27978 }
27979
27980 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
27981         LDKu8slice ser_ref;
27982         ser_ref.datalen = ser->arr_len;
27983         ser_ref.data = ser->elems /* XXX ser leaks */;
27984         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
27985         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
27986         return (uintptr_t)ret_conv;
27987 }
27988
27989 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
27990         LDKUpdateFee obj_conv;
27991         obj_conv.inner = (void*)(obj & (~1));
27992         obj_conv.is_owned = false;
27993         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27994         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
27995         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27996         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27997         CVec_u8Z_free(ret_var);
27998         return ret_arr;
27999 }
28000
28001 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
28002         LDKu8slice ser_ref;
28003         ser_ref.datalen = ser->arr_len;
28004         ser_ref.data = ser->elems /* XXX ser leaks */;
28005         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
28006         *ret_conv = UpdateFee_read(ser_ref);
28007         return (uintptr_t)ret_conv;
28008 }
28009
28010 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
28011         LDKUpdateFulfillHTLC obj_conv;
28012         obj_conv.inner = (void*)(obj & (~1));
28013         obj_conv.is_owned = false;
28014         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28015         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
28016         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28017         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28018         CVec_u8Z_free(ret_var);
28019         return ret_arr;
28020 }
28021
28022 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
28023         LDKu8slice ser_ref;
28024         ser_ref.datalen = ser->arr_len;
28025         ser_ref.data = ser->elems /* XXX ser leaks */;
28026         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
28027         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
28028         return (uintptr_t)ret_conv;
28029 }
28030
28031 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
28032         LDKUpdateAddHTLC obj_conv;
28033         obj_conv.inner = (void*)(obj & (~1));
28034         obj_conv.is_owned = false;
28035         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28036         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
28037         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28038         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28039         CVec_u8Z_free(ret_var);
28040         return ret_arr;
28041 }
28042
28043 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
28044         LDKu8slice ser_ref;
28045         ser_ref.datalen = ser->arr_len;
28046         ser_ref.data = ser->elems /* XXX ser leaks */;
28047         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
28048         *ret_conv = UpdateAddHTLC_read(ser_ref);
28049         return (uintptr_t)ret_conv;
28050 }
28051
28052 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
28053         LDKPing obj_conv;
28054         obj_conv.inner = (void*)(obj & (~1));
28055         obj_conv.is_owned = false;
28056         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28057         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
28058         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28059         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28060         CVec_u8Z_free(ret_var);
28061         return ret_arr;
28062 }
28063
28064 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
28065         LDKu8slice ser_ref;
28066         ser_ref.datalen = ser->arr_len;
28067         ser_ref.data = ser->elems /* XXX ser leaks */;
28068         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
28069         *ret_conv = Ping_read(ser_ref);
28070         return (uintptr_t)ret_conv;
28071 }
28072
28073 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
28074         LDKPong obj_conv;
28075         obj_conv.inner = (void*)(obj & (~1));
28076         obj_conv.is_owned = false;
28077         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28078         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
28079         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28080         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28081         CVec_u8Z_free(ret_var);
28082         return ret_arr;
28083 }
28084
28085 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
28086         LDKu8slice ser_ref;
28087         ser_ref.datalen = ser->arr_len;
28088         ser_ref.data = ser->elems /* XXX ser leaks */;
28089         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
28090         *ret_conv = Pong_read(ser_ref);
28091         return (uintptr_t)ret_conv;
28092 }
28093
28094 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
28095         LDKUnsignedChannelAnnouncement obj_conv;
28096         obj_conv.inner = (void*)(obj & (~1));
28097         obj_conv.is_owned = false;
28098         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28099         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
28100         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28101         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28102         CVec_u8Z_free(ret_var);
28103         return ret_arr;
28104 }
28105
28106 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
28107         LDKu8slice ser_ref;
28108         ser_ref.datalen = ser->arr_len;
28109         ser_ref.data = ser->elems /* XXX ser leaks */;
28110         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
28111         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
28112         return (uintptr_t)ret_conv;
28113 }
28114
28115 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
28116         LDKChannelAnnouncement obj_conv;
28117         obj_conv.inner = (void*)(obj & (~1));
28118         obj_conv.is_owned = false;
28119         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28120         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
28121         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28122         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28123         CVec_u8Z_free(ret_var);
28124         return ret_arr;
28125 }
28126
28127 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
28128         LDKu8slice ser_ref;
28129         ser_ref.datalen = ser->arr_len;
28130         ser_ref.data = ser->elems /* XXX ser leaks */;
28131         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
28132         *ret_conv = ChannelAnnouncement_read(ser_ref);
28133         return (uintptr_t)ret_conv;
28134 }
28135
28136 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
28137         LDKUnsignedChannelUpdate obj_conv;
28138         obj_conv.inner = (void*)(obj & (~1));
28139         obj_conv.is_owned = false;
28140         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28141         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
28142         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28143         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28144         CVec_u8Z_free(ret_var);
28145         return ret_arr;
28146 }
28147
28148 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
28149         LDKu8slice ser_ref;
28150         ser_ref.datalen = ser->arr_len;
28151         ser_ref.data = ser->elems /* XXX ser leaks */;
28152         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
28153         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
28154         return (uintptr_t)ret_conv;
28155 }
28156
28157 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
28158         LDKChannelUpdate obj_conv;
28159         obj_conv.inner = (void*)(obj & (~1));
28160         obj_conv.is_owned = false;
28161         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28162         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
28163         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28164         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28165         CVec_u8Z_free(ret_var);
28166         return ret_arr;
28167 }
28168
28169 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
28170         LDKu8slice ser_ref;
28171         ser_ref.datalen = ser->arr_len;
28172         ser_ref.data = ser->elems /* XXX ser leaks */;
28173         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
28174         *ret_conv = ChannelUpdate_read(ser_ref);
28175         return (uintptr_t)ret_conv;
28176 }
28177
28178 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
28179         LDKErrorMessage obj_conv;
28180         obj_conv.inner = (void*)(obj & (~1));
28181         obj_conv.is_owned = false;
28182         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28183         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
28184         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28185         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28186         CVec_u8Z_free(ret_var);
28187         return ret_arr;
28188 }
28189
28190 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
28191         LDKu8slice ser_ref;
28192         ser_ref.datalen = ser->arr_len;
28193         ser_ref.data = ser->elems /* XXX ser leaks */;
28194         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
28195         *ret_conv = ErrorMessage_read(ser_ref);
28196         return (uintptr_t)ret_conv;
28197 }
28198
28199 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
28200         LDKUnsignedNodeAnnouncement obj_conv;
28201         obj_conv.inner = (void*)(obj & (~1));
28202         obj_conv.is_owned = false;
28203         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28204         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
28205         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28206         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28207         CVec_u8Z_free(ret_var);
28208         return ret_arr;
28209 }
28210
28211 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
28212         LDKu8slice ser_ref;
28213         ser_ref.datalen = ser->arr_len;
28214         ser_ref.data = ser->elems /* XXX ser leaks */;
28215         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
28216         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
28217         return (uintptr_t)ret_conv;
28218 }
28219
28220 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
28221         LDKNodeAnnouncement obj_conv;
28222         obj_conv.inner = (void*)(obj & (~1));
28223         obj_conv.is_owned = false;
28224         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28225         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
28226         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28227         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28228         CVec_u8Z_free(ret_var);
28229         return ret_arr;
28230 }
28231
28232 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
28233         LDKu8slice ser_ref;
28234         ser_ref.datalen = ser->arr_len;
28235         ser_ref.data = ser->elems /* XXX ser leaks */;
28236         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
28237         *ret_conv = NodeAnnouncement_read(ser_ref);
28238         return (uintptr_t)ret_conv;
28239 }
28240
28241 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
28242         LDKu8slice ser_ref;
28243         ser_ref.datalen = ser->arr_len;
28244         ser_ref.data = ser->elems /* XXX ser leaks */;
28245         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
28246         *ret_conv = QueryShortChannelIds_read(ser_ref);
28247         return (uintptr_t)ret_conv;
28248 }
28249
28250 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
28251         LDKQueryShortChannelIds obj_conv;
28252         obj_conv.inner = (void*)(obj & (~1));
28253         obj_conv.is_owned = false;
28254         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28255         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
28256         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28257         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28258         CVec_u8Z_free(ret_var);
28259         return ret_arr;
28260 }
28261
28262 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
28263         LDKReplyShortChannelIdsEnd obj_conv;
28264         obj_conv.inner = (void*)(obj & (~1));
28265         obj_conv.is_owned = false;
28266         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28267         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
28268         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28269         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28270         CVec_u8Z_free(ret_var);
28271         return ret_arr;
28272 }
28273
28274 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
28275         LDKu8slice ser_ref;
28276         ser_ref.datalen = ser->arr_len;
28277         ser_ref.data = ser->elems /* XXX ser leaks */;
28278         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
28279         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
28280         return (uintptr_t)ret_conv;
28281 }
28282
28283 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
28284         LDKQueryChannelRange this_arg_conv;
28285         this_arg_conv.inner = (void*)(this_arg & (~1));
28286         this_arg_conv.is_owned = false;
28287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28288         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
28289         return ret_val;
28290 }
28291
28292 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
28293         LDKQueryChannelRange obj_conv;
28294         obj_conv.inner = (void*)(obj & (~1));
28295         obj_conv.is_owned = false;
28296         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28297         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
28298         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28299         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28300         CVec_u8Z_free(ret_var);
28301         return ret_arr;
28302 }
28303
28304 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
28305         LDKu8slice ser_ref;
28306         ser_ref.datalen = ser->arr_len;
28307         ser_ref.data = ser->elems /* XXX ser leaks */;
28308         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
28309         *ret_conv = QueryChannelRange_read(ser_ref);
28310         return (uintptr_t)ret_conv;
28311 }
28312
28313 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
28314         LDKu8slice ser_ref;
28315         ser_ref.datalen = ser->arr_len;
28316         ser_ref.data = ser->elems /* XXX ser leaks */;
28317         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
28318         *ret_conv = ReplyChannelRange_read(ser_ref);
28319         return (uintptr_t)ret_conv;
28320 }
28321
28322 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
28323         LDKReplyChannelRange obj_conv;
28324         obj_conv.inner = (void*)(obj & (~1));
28325         obj_conv.is_owned = false;
28326         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28327         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
28328         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28329         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28330         CVec_u8Z_free(ret_var);
28331         return ret_arr;
28332 }
28333
28334 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
28335         LDKGossipTimestampFilter obj_conv;
28336         obj_conv.inner = (void*)(obj & (~1));
28337         obj_conv.is_owned = false;
28338         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28339         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
28340         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28341         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28342         CVec_u8Z_free(ret_var);
28343         return ret_arr;
28344 }
28345
28346 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
28347         LDKu8slice ser_ref;
28348         ser_ref.datalen = ser->arr_len;
28349         ser_ref.data = ser->elems /* XXX ser leaks */;
28350         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
28351         *ret_conv = GossipTimestampFilter_read(ser_ref);
28352         return (uintptr_t)ret_conv;
28353 }
28354
28355 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
28356         if ((this_ptr & 1) != 0) return;
28357         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28358         CHECK_ACCESS(this_ptr_ptr);
28359         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
28360         FREE((void*)this_ptr);
28361         CustomMessageHandler_free(this_ptr_conv);
28362 }
28363
28364 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
28365         LDKIgnoringMessageHandler this_obj_conv;
28366         this_obj_conv.inner = (void*)(this_obj & (~1));
28367         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28369         IgnoringMessageHandler_free(this_obj_conv);
28370 }
28371
28372 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
28373         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
28374         uintptr_t ret_ref = 0;
28375         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28376         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28378         ret_ref = (uintptr_t)ret_var.inner;
28379         if (ret_var.is_owned) {
28380                 ret_ref |= 1;
28381         }
28382         return ret_ref;
28383 }
28384
28385 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
28386         LDKIgnoringMessageHandler this_arg_conv;
28387         this_arg_conv.inner = (void*)(this_arg & (~1));
28388         this_arg_conv.is_owned = false;
28389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28390         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
28391         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
28392         return (uintptr_t)ret_ret;
28393 }
28394
28395 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
28396         LDKIgnoringMessageHandler this_arg_conv;
28397         this_arg_conv.inner = (void*)(this_arg & (~1));
28398         this_arg_conv.is_owned = false;
28399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28400         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
28401         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
28402         return (uintptr_t)ret_ret;
28403 }
28404
28405 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
28406         LDKIgnoringMessageHandler this_arg_conv;
28407         this_arg_conv.inner = (void*)(this_arg & (~1));
28408         this_arg_conv.is_owned = false;
28409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28410         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
28411         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
28412         return (uintptr_t)ret_ret;
28413 }
28414
28415 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
28416         LDKIgnoringMessageHandler this_arg_conv;
28417         this_arg_conv.inner = (void*)(this_arg & (~1));
28418         this_arg_conv.is_owned = false;
28419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28420         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
28421         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
28422         return (uintptr_t)ret_ret;
28423 }
28424
28425 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
28426         LDKErroringMessageHandler this_obj_conv;
28427         this_obj_conv.inner = (void*)(this_obj & (~1));
28428         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28430         ErroringMessageHandler_free(this_obj_conv);
28431 }
28432
28433 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
28434         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
28435         uintptr_t ret_ref = 0;
28436         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28437         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28439         ret_ref = (uintptr_t)ret_var.inner;
28440         if (ret_var.is_owned) {
28441                 ret_ref |= 1;
28442         }
28443         return ret_ref;
28444 }
28445
28446 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
28447         LDKErroringMessageHandler this_arg_conv;
28448         this_arg_conv.inner = (void*)(this_arg & (~1));
28449         this_arg_conv.is_owned = false;
28450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28451         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
28452         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
28453         return (uintptr_t)ret_ret;
28454 }
28455
28456 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
28457         LDKErroringMessageHandler this_arg_conv;
28458         this_arg_conv.inner = (void*)(this_arg & (~1));
28459         this_arg_conv.is_owned = false;
28460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28461         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
28462         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
28463         return (uintptr_t)ret_ret;
28464 }
28465
28466 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
28467         LDKMessageHandler this_obj_conv;
28468         this_obj_conv.inner = (void*)(this_obj & (~1));
28469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28471         MessageHandler_free(this_obj_conv);
28472 }
28473
28474 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
28475         LDKMessageHandler this_ptr_conv;
28476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28477         this_ptr_conv.is_owned = false;
28478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28479         // WARNING: This object doesn't live past this scope, needs clone!
28480         uintptr_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
28481         return ret_ret;
28482 }
28483
28484 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
28485         LDKMessageHandler this_ptr_conv;
28486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28487         this_ptr_conv.is_owned = false;
28488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28489         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28490         CHECK_ACCESS(val_ptr);
28491         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
28492         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
28493 }
28494
28495 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
28496         LDKMessageHandler this_ptr_conv;
28497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28498         this_ptr_conv.is_owned = false;
28499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28500         // WARNING: This object doesn't live past this scope, needs clone!
28501         uintptr_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
28502         return ret_ret;
28503 }
28504
28505 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
28506         LDKMessageHandler this_ptr_conv;
28507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28508         this_ptr_conv.is_owned = false;
28509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28510         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28511         CHECK_ACCESS(val_ptr);
28512         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
28513         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
28514 }
28515
28516 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
28517         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
28518         CHECK_ACCESS(chan_handler_arg_ptr);
28519         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
28520         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
28521         CHECK_ACCESS(route_handler_arg_ptr);
28522         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
28523         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
28524         uintptr_t ret_ref = 0;
28525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28528         ret_ref = (uintptr_t)ret_var.inner;
28529         if (ret_var.is_owned) {
28530                 ret_ref |= 1;
28531         }
28532         return ret_ref;
28533 }
28534
28535 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
28536         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
28537         *ret_ret = SocketDescriptor_clone(arg);
28538         return (uintptr_t)ret_ret;
28539 }
28540 intptr_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
28541         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
28542         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28543         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
28544         intptr_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
28545         return ret_val;
28546 }
28547
28548 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
28549         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
28550         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
28551         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
28552         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
28553         *ret_ret = SocketDescriptor_clone(orig_conv);
28554         return (uintptr_t)ret_ret;
28555 }
28556
28557 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
28558         if ((this_ptr & 1) != 0) return;
28559         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28560         CHECK_ACCESS(this_ptr_ptr);
28561         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
28562         FREE((void*)this_ptr);
28563         SocketDescriptor_free(this_ptr_conv);
28564 }
28565
28566 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
28567         LDKPeerHandleError this_obj_conv;
28568         this_obj_conv.inner = (void*)(this_obj & (~1));
28569         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28571         PeerHandleError_free(this_obj_conv);
28572 }
28573
28574 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
28575         LDKPeerHandleError this_ptr_conv;
28576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28577         this_ptr_conv.is_owned = false;
28578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28579         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
28580         return ret_val;
28581 }
28582
28583 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
28584         LDKPeerHandleError this_ptr_conv;
28585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28586         this_ptr_conv.is_owned = false;
28587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28588         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
28589 }
28590
28591 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
28592         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
28593         uintptr_t ret_ref = 0;
28594         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28595         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28597         ret_ref = (uintptr_t)ret_var.inner;
28598         if (ret_var.is_owned) {
28599                 ret_ref |= 1;
28600         }
28601         return ret_ref;
28602 }
28603
28604 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
28605         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
28606 uintptr_t ret_ref = 0;
28607 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28608 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28609 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28610 ret_ref = (uintptr_t)ret_var.inner;
28611 if (ret_var.is_owned) {
28612         ret_ref |= 1;
28613 }
28614         return ret_ref;
28615 }
28616 intptr_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
28617         LDKPeerHandleError arg_conv;
28618         arg_conv.inner = (void*)(arg & (~1));
28619         arg_conv.is_owned = false;
28620         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28621         intptr_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
28622         return ret_val;
28623 }
28624
28625 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
28626         LDKPeerHandleError orig_conv;
28627         orig_conv.inner = (void*)(orig & (~1));
28628         orig_conv.is_owned = false;
28629         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28630         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
28631         uintptr_t ret_ref = 0;
28632         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28633         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28635         ret_ref = (uintptr_t)ret_var.inner;
28636         if (ret_var.is_owned) {
28637                 ret_ref |= 1;
28638         }
28639         return ret_ref;
28640 }
28641
28642 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
28643         LDKPeerManager this_obj_conv;
28644         this_obj_conv.inner = (void*)(this_obj & (~1));
28645         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28647         PeerManager_free(this_obj_conv);
28648 }
28649
28650 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) {
28651         LDKMessageHandler message_handler_conv;
28652         message_handler_conv.inner = (void*)(message_handler & (~1));
28653         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
28654         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
28655         // Warning: we need a move here but no clone is available for LDKMessageHandler
28656         LDKSecretKey our_node_secret_ref;
28657         CHECK(our_node_secret->arr_len == 32);
28658         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
28659         unsigned char ephemeral_random_data_arr[32];
28660         CHECK(ephemeral_random_data->arr_len == 32);
28661         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
28662         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
28663         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
28664         CHECK_ACCESS(logger_ptr);
28665         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28666         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
28667         CHECK_ACCESS(custom_message_handler_ptr);
28668         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
28669         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
28670         uintptr_t ret_ref = 0;
28671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28674         ret_ref = (uintptr_t)ret_var.inner;
28675         if (ret_var.is_owned) {
28676                 ret_ref |= 1;
28677         }
28678         return ret_ref;
28679 }
28680
28681 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
28682         LDKPeerManager this_arg_conv;
28683         this_arg_conv.inner = (void*)(this_arg & (~1));
28684         this_arg_conv.is_owned = false;
28685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28686         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
28687         ptrArray ret_arr = NULL;
28688         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
28689         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
28690         for (size_t m = 0; m < ret_var.datalen; m++) {
28691                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
28692                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
28693                 ret_arr_ptr[m] = ret_conv_12_arr;
28694         }
28695         
28696         FREE(ret_var.data);
28697         return ret_arr;
28698 }
28699
28700 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) {
28701         LDKPeerManager this_arg_conv;
28702         this_arg_conv.inner = (void*)(this_arg & (~1));
28703         this_arg_conv.is_owned = false;
28704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28705         LDKPublicKey their_node_id_ref;
28706         CHECK(their_node_id->arr_len == 33);
28707         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
28708         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
28709         CHECK_ACCESS(descriptor_ptr);
28710         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
28711         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
28712         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
28713         return (uintptr_t)ret_conv;
28714 }
28715
28716 uint32_t  __attribute__((export_name("TS_PeerManager_new_inbound_connection"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
28717         LDKPeerManager this_arg_conv;
28718         this_arg_conv.inner = (void*)(this_arg & (~1));
28719         this_arg_conv.is_owned = false;
28720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28721         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
28722         CHECK_ACCESS(descriptor_ptr);
28723         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
28724         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
28725         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
28726         return (uintptr_t)ret_conv;
28727 }
28728
28729 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
28730         LDKPeerManager this_arg_conv;
28731         this_arg_conv.inner = (void*)(this_arg & (~1));
28732         this_arg_conv.is_owned = false;
28733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28734         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
28735         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
28736         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
28737         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
28738         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
28739         return (uintptr_t)ret_conv;
28740 }
28741
28742 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
28743         LDKPeerManager this_arg_conv;
28744         this_arg_conv.inner = (void*)(this_arg & (~1));
28745         this_arg_conv.is_owned = false;
28746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28747         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
28748         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
28749         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
28750         LDKu8slice data_ref;
28751         data_ref.datalen = data->arr_len;
28752         data_ref.data = data->elems /* XXX data leaks */;
28753         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
28754         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
28755         return (uintptr_t)ret_conv;
28756 }
28757
28758 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
28759         LDKPeerManager this_arg_conv;
28760         this_arg_conv.inner = (void*)(this_arg & (~1));
28761         this_arg_conv.is_owned = false;
28762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28763         PeerManager_process_events(&this_arg_conv);
28764 }
28765
28766 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
28767         LDKPeerManager this_arg_conv;
28768         this_arg_conv.inner = (void*)(this_arg & (~1));
28769         this_arg_conv.is_owned = false;
28770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28771         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
28772         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
28773         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
28774         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
28775 }
28776
28777 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) {
28778         LDKPeerManager this_arg_conv;
28779         this_arg_conv.inner = (void*)(this_arg & (~1));
28780         this_arg_conv.is_owned = false;
28781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28782         LDKPublicKey node_id_ref;
28783         CHECK(node_id->arr_len == 33);
28784         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
28785         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
28786 }
28787
28788 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
28789         LDKPeerManager this_arg_conv;
28790         this_arg_conv.inner = (void*)(this_arg & (~1));
28791         this_arg_conv.is_owned = false;
28792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28793         PeerManager_disconnect_all_peers(&this_arg_conv);
28794 }
28795
28796 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
28797         LDKPeerManager this_arg_conv;
28798         this_arg_conv.inner = (void*)(this_arg & (~1));
28799         this_arg_conv.is_owned = false;
28800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28801         PeerManager_timer_tick_occurred(&this_arg_conv);
28802 }
28803
28804 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
28805         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
28806         return ret_val;
28807 }
28808
28809 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
28810         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
28811         return ret_val;
28812 }
28813
28814 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
28815         unsigned char commitment_seed_arr[32];
28816         CHECK(commitment_seed->arr_len == 32);
28817         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
28818         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
28819         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28820         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
28821         return ret_arr;
28822 }
28823
28824 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) {
28825         LDKCVec_u8Z to_holder_script_ref;
28826         to_holder_script_ref.datalen = to_holder_script->arr_len;
28827         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
28828         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
28829         LDKCVec_u8Z to_counterparty_script_ref;
28830         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
28831         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
28832         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
28833         LDKOutPoint funding_outpoint_conv;
28834         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
28835         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
28836         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
28837         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
28838         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);
28839         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28840         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28841         Transaction_free(ret_var);
28842         return ret_arr;
28843 }
28844
28845 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
28846         LDKPublicKey per_commitment_point_ref;
28847         CHECK(per_commitment_point->arr_len == 33);
28848         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
28849         unsigned char base_secret_arr[32];
28850         CHECK(base_secret->arr_len == 32);
28851         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
28852         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
28853         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
28854         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
28855         return (uintptr_t)ret_conv;
28856 }
28857
28858 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
28859         LDKPublicKey per_commitment_point_ref;
28860         CHECK(per_commitment_point->arr_len == 33);
28861         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
28862         LDKPublicKey base_point_ref;
28863         CHECK(base_point->arr_len == 33);
28864         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
28865         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
28866         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
28867         return (uintptr_t)ret_conv;
28868 }
28869
28870 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) {
28871         unsigned char per_commitment_secret_arr[32];
28872         CHECK(per_commitment_secret->arr_len == 32);
28873         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
28874         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
28875         unsigned char countersignatory_revocation_base_secret_arr[32];
28876         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
28877         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
28878         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
28879         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
28880         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
28881         return (uintptr_t)ret_conv;
28882 }
28883
28884 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) {
28885         LDKPublicKey per_commitment_point_ref;
28886         CHECK(per_commitment_point->arr_len == 33);
28887         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
28888         LDKPublicKey countersignatory_revocation_base_point_ref;
28889         CHECK(countersignatory_revocation_base_point->arr_len == 33);
28890         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
28891         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
28892         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
28893         return (uintptr_t)ret_conv;
28894 }
28895
28896 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
28897         LDKTxCreationKeys this_obj_conv;
28898         this_obj_conv.inner = (void*)(this_obj & (~1));
28899         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28901         TxCreationKeys_free(this_obj_conv);
28902 }
28903
28904 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
28905         LDKTxCreationKeys this_ptr_conv;
28906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28907         this_ptr_conv.is_owned = false;
28908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28909         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28910         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28911         return ret_arr;
28912 }
28913
28914 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
28915         LDKTxCreationKeys this_ptr_conv;
28916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28917         this_ptr_conv.is_owned = false;
28918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28919         LDKPublicKey val_ref;
28920         CHECK(val->arr_len == 33);
28921         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28922         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
28923 }
28924
28925 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
28926         LDKTxCreationKeys this_ptr_conv;
28927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28928         this_ptr_conv.is_owned = false;
28929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28930         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28931         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
28932         return ret_arr;
28933 }
28934
28935 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
28936         LDKTxCreationKeys this_ptr_conv;
28937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28938         this_ptr_conv.is_owned = false;
28939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28940         LDKPublicKey val_ref;
28941         CHECK(val->arr_len == 33);
28942         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28943         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
28944 }
28945
28946 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
28947         LDKTxCreationKeys this_ptr_conv;
28948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28949         this_ptr_conv.is_owned = false;
28950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28951         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28952         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
28953         return ret_arr;
28954 }
28955
28956 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
28957         LDKTxCreationKeys this_ptr_conv;
28958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28959         this_ptr_conv.is_owned = false;
28960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28961         LDKPublicKey val_ref;
28962         CHECK(val->arr_len == 33);
28963         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28964         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
28965 }
28966
28967 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
28968         LDKTxCreationKeys this_ptr_conv;
28969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28970         this_ptr_conv.is_owned = false;
28971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28972         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28973         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
28974         return ret_arr;
28975 }
28976
28977 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
28978         LDKTxCreationKeys this_ptr_conv;
28979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28980         this_ptr_conv.is_owned = false;
28981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28982         LDKPublicKey val_ref;
28983         CHECK(val->arr_len == 33);
28984         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28985         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
28986 }
28987
28988 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
28989         LDKTxCreationKeys this_ptr_conv;
28990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28991         this_ptr_conv.is_owned = false;
28992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28993         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28994         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
28995         return ret_arr;
28996 }
28997
28998 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) {
28999         LDKTxCreationKeys this_ptr_conv;
29000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29001         this_ptr_conv.is_owned = false;
29002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29003         LDKPublicKey val_ref;
29004         CHECK(val->arr_len == 33);
29005         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29006         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
29007 }
29008
29009 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) {
29010         LDKPublicKey per_commitment_point_arg_ref;
29011         CHECK(per_commitment_point_arg->arr_len == 33);
29012         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
29013         LDKPublicKey revocation_key_arg_ref;
29014         CHECK(revocation_key_arg->arr_len == 33);
29015         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
29016         LDKPublicKey broadcaster_htlc_key_arg_ref;
29017         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
29018         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
29019         LDKPublicKey countersignatory_htlc_key_arg_ref;
29020         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
29021         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
29022         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
29023         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
29024         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
29025         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);
29026         uintptr_t ret_ref = 0;
29027         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29028         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29030         ret_ref = (uintptr_t)ret_var.inner;
29031         if (ret_var.is_owned) {
29032                 ret_ref |= 1;
29033         }
29034         return ret_ref;
29035 }
29036
29037 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
29038         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
29039 uintptr_t ret_ref = 0;
29040 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29041 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29042 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29043 ret_ref = (uintptr_t)ret_var.inner;
29044 if (ret_var.is_owned) {
29045         ret_ref |= 1;
29046 }
29047         return ret_ref;
29048 }
29049 intptr_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
29050         LDKTxCreationKeys arg_conv;
29051         arg_conv.inner = (void*)(arg & (~1));
29052         arg_conv.is_owned = false;
29053         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29054         intptr_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
29055         return ret_val;
29056 }
29057
29058 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
29059         LDKTxCreationKeys orig_conv;
29060         orig_conv.inner = (void*)(orig & (~1));
29061         orig_conv.is_owned = false;
29062         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29063         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
29064         uintptr_t ret_ref = 0;
29065         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29066         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29068         ret_ref = (uintptr_t)ret_var.inner;
29069         if (ret_var.is_owned) {
29070                 ret_ref |= 1;
29071         }
29072         return ret_ref;
29073 }
29074
29075 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
29076         LDKTxCreationKeys obj_conv;
29077         obj_conv.inner = (void*)(obj & (~1));
29078         obj_conv.is_owned = false;
29079         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29080         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
29081         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29082         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29083         CVec_u8Z_free(ret_var);
29084         return ret_arr;
29085 }
29086
29087 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
29088         LDKu8slice ser_ref;
29089         ser_ref.datalen = ser->arr_len;
29090         ser_ref.data = ser->elems /* XXX ser leaks */;
29091         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
29092         *ret_conv = TxCreationKeys_read(ser_ref);
29093         return (uintptr_t)ret_conv;
29094 }
29095
29096 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
29097         LDKChannelPublicKeys this_obj_conv;
29098         this_obj_conv.inner = (void*)(this_obj & (~1));
29099         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29101         ChannelPublicKeys_free(this_obj_conv);
29102 }
29103
29104 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
29105         LDKChannelPublicKeys this_ptr_conv;
29106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29107         this_ptr_conv.is_owned = false;
29108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29109         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29110         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
29111         return ret_arr;
29112 }
29113
29114 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
29115         LDKChannelPublicKeys this_ptr_conv;
29116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29117         this_ptr_conv.is_owned = false;
29118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29119         LDKPublicKey val_ref;
29120         CHECK(val->arr_len == 33);
29121         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29122         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
29123 }
29124
29125 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
29126         LDKChannelPublicKeys this_ptr_conv;
29127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29128         this_ptr_conv.is_owned = false;
29129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29130         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29131         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
29132         return ret_arr;
29133 }
29134
29135 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
29136         LDKChannelPublicKeys 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         LDKPublicKey val_ref;
29141         CHECK(val->arr_len == 33);
29142         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29143         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
29144 }
29145
29146 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
29147         LDKChannelPublicKeys this_ptr_conv;
29148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29149         this_ptr_conv.is_owned = false;
29150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29151         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29152         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
29153         return ret_arr;
29154 }
29155
29156 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
29157         LDKChannelPublicKeys this_ptr_conv;
29158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29159         this_ptr_conv.is_owned = false;
29160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29161         LDKPublicKey val_ref;
29162         CHECK(val->arr_len == 33);
29163         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29164         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
29165 }
29166
29167 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
29168         LDKChannelPublicKeys this_ptr_conv;
29169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29170         this_ptr_conv.is_owned = false;
29171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29172         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29173         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
29174         return ret_arr;
29175 }
29176
29177 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
29178         LDKChannelPublicKeys this_ptr_conv;
29179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29180         this_ptr_conv.is_owned = false;
29181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29182         LDKPublicKey val_ref;
29183         CHECK(val->arr_len == 33);
29184         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29185         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
29186 }
29187
29188 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
29189         LDKChannelPublicKeys this_ptr_conv;
29190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29191         this_ptr_conv.is_owned = false;
29192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29193         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29194         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
29195         return ret_arr;
29196 }
29197
29198 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
29199         LDKChannelPublicKeys this_ptr_conv;
29200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29201         this_ptr_conv.is_owned = false;
29202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29203         LDKPublicKey val_ref;
29204         CHECK(val->arr_len == 33);
29205         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29206         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
29207 }
29208
29209 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) {
29210         LDKPublicKey funding_pubkey_arg_ref;
29211         CHECK(funding_pubkey_arg->arr_len == 33);
29212         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
29213         LDKPublicKey revocation_basepoint_arg_ref;
29214         CHECK(revocation_basepoint_arg->arr_len == 33);
29215         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
29216         LDKPublicKey payment_point_arg_ref;
29217         CHECK(payment_point_arg->arr_len == 33);
29218         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
29219         LDKPublicKey delayed_payment_basepoint_arg_ref;
29220         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
29221         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
29222         LDKPublicKey htlc_basepoint_arg_ref;
29223         CHECK(htlc_basepoint_arg->arr_len == 33);
29224         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
29225         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);
29226         uintptr_t ret_ref = 0;
29227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29230         ret_ref = (uintptr_t)ret_var.inner;
29231         if (ret_var.is_owned) {
29232                 ret_ref |= 1;
29233         }
29234         return ret_ref;
29235 }
29236
29237 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
29238         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
29239 uintptr_t ret_ref = 0;
29240 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29241 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29242 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29243 ret_ref = (uintptr_t)ret_var.inner;
29244 if (ret_var.is_owned) {
29245         ret_ref |= 1;
29246 }
29247         return ret_ref;
29248 }
29249 intptr_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
29250         LDKChannelPublicKeys arg_conv;
29251         arg_conv.inner = (void*)(arg & (~1));
29252         arg_conv.is_owned = false;
29253         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29254         intptr_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
29255         return ret_val;
29256 }
29257
29258 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
29259         LDKChannelPublicKeys orig_conv;
29260         orig_conv.inner = (void*)(orig & (~1));
29261         orig_conv.is_owned = false;
29262         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29263         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
29264         uintptr_t ret_ref = 0;
29265         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29266         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29268         ret_ref = (uintptr_t)ret_var.inner;
29269         if (ret_var.is_owned) {
29270                 ret_ref |= 1;
29271         }
29272         return ret_ref;
29273 }
29274
29275 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
29276         LDKChannelPublicKeys obj_conv;
29277         obj_conv.inner = (void*)(obj & (~1));
29278         obj_conv.is_owned = false;
29279         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29280         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
29281         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29282         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29283         CVec_u8Z_free(ret_var);
29284         return ret_arr;
29285 }
29286
29287 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
29288         LDKu8slice ser_ref;
29289         ser_ref.datalen = ser->arr_len;
29290         ser_ref.data = ser->elems /* XXX ser leaks */;
29291         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
29292         *ret_conv = ChannelPublicKeys_read(ser_ref);
29293         return (uintptr_t)ret_conv;
29294 }
29295
29296 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) {
29297         LDKPublicKey per_commitment_point_ref;
29298         CHECK(per_commitment_point->arr_len == 33);
29299         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
29300         LDKPublicKey broadcaster_delayed_payment_base_ref;
29301         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
29302         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
29303         LDKPublicKey broadcaster_htlc_base_ref;
29304         CHECK(broadcaster_htlc_base->arr_len == 33);
29305         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
29306         LDKPublicKey countersignatory_revocation_base_ref;
29307         CHECK(countersignatory_revocation_base->arr_len == 33);
29308         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
29309         LDKPublicKey countersignatory_htlc_base_ref;
29310         CHECK(countersignatory_htlc_base->arr_len == 33);
29311         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
29312         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
29313         *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);
29314         return (uintptr_t)ret_conv;
29315 }
29316
29317 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) {
29318         LDKPublicKey per_commitment_point_ref;
29319         CHECK(per_commitment_point->arr_len == 33);
29320         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
29321         LDKChannelPublicKeys broadcaster_keys_conv;
29322         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
29323         broadcaster_keys_conv.is_owned = false;
29324         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
29325         LDKChannelPublicKeys countersignatory_keys_conv;
29326         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
29327         countersignatory_keys_conv.is_owned = false;
29328         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
29329         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
29330         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
29331         return (uintptr_t)ret_conv;
29332 }
29333
29334 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) {
29335         LDKPublicKey revocation_key_ref;
29336         CHECK(revocation_key->arr_len == 33);
29337         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
29338         LDKPublicKey broadcaster_delayed_payment_key_ref;
29339         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
29340         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
29341         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
29342         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29343         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29344         CVec_u8Z_free(ret_var);
29345         return ret_arr;
29346 }
29347
29348 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
29349         LDKHTLCOutputInCommitment this_obj_conv;
29350         this_obj_conv.inner = (void*)(this_obj & (~1));
29351         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29353         HTLCOutputInCommitment_free(this_obj_conv);
29354 }
29355
29356 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
29357         LDKHTLCOutputInCommitment this_ptr_conv;
29358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29359         this_ptr_conv.is_owned = false;
29360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29361         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
29362         return ret_val;
29363 }
29364
29365 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
29366         LDKHTLCOutputInCommitment this_ptr_conv;
29367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29368         this_ptr_conv.is_owned = false;
29369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29370         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
29371 }
29372
29373 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
29374         LDKHTLCOutputInCommitment this_ptr_conv;
29375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29376         this_ptr_conv.is_owned = false;
29377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29378         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
29379         return ret_val;
29380 }
29381
29382 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
29383         LDKHTLCOutputInCommitment this_ptr_conv;
29384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29385         this_ptr_conv.is_owned = false;
29386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29387         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
29388 }
29389
29390 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
29391         LDKHTLCOutputInCommitment this_ptr_conv;
29392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29393         this_ptr_conv.is_owned = false;
29394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29395         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
29396         return ret_val;
29397 }
29398
29399 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
29400         LDKHTLCOutputInCommitment this_ptr_conv;
29401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29402         this_ptr_conv.is_owned = false;
29403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29404         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
29405 }
29406
29407 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
29408         LDKHTLCOutputInCommitment this_ptr_conv;
29409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29410         this_ptr_conv.is_owned = false;
29411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29412         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29413         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
29414         return ret_arr;
29415 }
29416
29417 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
29418         LDKHTLCOutputInCommitment this_ptr_conv;
29419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29420         this_ptr_conv.is_owned = false;
29421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29422         LDKThirtyTwoBytes val_ref;
29423         CHECK(val->arr_len == 32);
29424         memcpy(val_ref.data, val->elems, 32); FREE(val);
29425         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
29426 }
29427
29428 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
29429         LDKHTLCOutputInCommitment this_ptr_conv;
29430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29431         this_ptr_conv.is_owned = false;
29432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29433         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
29434         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
29435         uintptr_t ret_ref = (uintptr_t)ret_copy;
29436         return ret_ref;
29437 }
29438
29439 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
29440         LDKHTLCOutputInCommitment this_ptr_conv;
29441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29442         this_ptr_conv.is_owned = false;
29443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29444         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29445         CHECK_ACCESS(val_ptr);
29446         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
29447         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
29448         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
29449 }
29450
29451 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) {
29452         LDKThirtyTwoBytes payment_hash_arg_ref;
29453         CHECK(payment_hash_arg->arr_len == 32);
29454         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
29455         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
29456         CHECK_ACCESS(transaction_output_index_arg_ptr);
29457         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
29458         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
29459         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
29460         uintptr_t ret_ref = 0;
29461         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29462         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29464         ret_ref = (uintptr_t)ret_var.inner;
29465         if (ret_var.is_owned) {
29466                 ret_ref |= 1;
29467         }
29468         return ret_ref;
29469 }
29470
29471 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
29472         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
29473 uintptr_t ret_ref = 0;
29474 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29475 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29476 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29477 ret_ref = (uintptr_t)ret_var.inner;
29478 if (ret_var.is_owned) {
29479         ret_ref |= 1;
29480 }
29481         return ret_ref;
29482 }
29483 intptr_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
29484         LDKHTLCOutputInCommitment arg_conv;
29485         arg_conv.inner = (void*)(arg & (~1));
29486         arg_conv.is_owned = false;
29487         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29488         intptr_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
29489         return ret_val;
29490 }
29491
29492 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
29493         LDKHTLCOutputInCommitment orig_conv;
29494         orig_conv.inner = (void*)(orig & (~1));
29495         orig_conv.is_owned = false;
29496         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29497         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
29498         uintptr_t ret_ref = 0;
29499         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29500         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29502         ret_ref = (uintptr_t)ret_var.inner;
29503         if (ret_var.is_owned) {
29504                 ret_ref |= 1;
29505         }
29506         return ret_ref;
29507 }
29508
29509 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
29510         LDKHTLCOutputInCommitment obj_conv;
29511         obj_conv.inner = (void*)(obj & (~1));
29512         obj_conv.is_owned = false;
29513         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29514         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
29515         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29516         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29517         CVec_u8Z_free(ret_var);
29518         return ret_arr;
29519 }
29520
29521 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
29522         LDKu8slice ser_ref;
29523         ser_ref.datalen = ser->arr_len;
29524         ser_ref.data = ser->elems /* XXX ser leaks */;
29525         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
29526         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
29527         return (uintptr_t)ret_conv;
29528 }
29529
29530 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
29531         LDKHTLCOutputInCommitment htlc_conv;
29532         htlc_conv.inner = (void*)(htlc & (~1));
29533         htlc_conv.is_owned = false;
29534         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
29535         LDKTxCreationKeys keys_conv;
29536         keys_conv.inner = (void*)(keys & (~1));
29537         keys_conv.is_owned = false;
29538         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
29539         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
29540         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29541         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29542         CVec_u8Z_free(ret_var);
29543         return ret_arr;
29544 }
29545
29546 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
29547         LDKPublicKey broadcaster_ref;
29548         CHECK(broadcaster->arr_len == 33);
29549         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
29550         LDKPublicKey countersignatory_ref;
29551         CHECK(countersignatory->arr_len == 33);
29552         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
29553         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
29554         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29555         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29556         CVec_u8Z_free(ret_var);
29557         return ret_arr;
29558 }
29559
29560 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) {
29561         unsigned char commitment_txid_arr[32];
29562         CHECK(commitment_txid->arr_len == 32);
29563         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
29564         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
29565         LDKHTLCOutputInCommitment htlc_conv;
29566         htlc_conv.inner = (void*)(htlc & (~1));
29567         htlc_conv.is_owned = false;
29568         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
29569         LDKPublicKey broadcaster_delayed_payment_key_ref;
29570         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
29571         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
29572         LDKPublicKey revocation_key_ref;
29573         CHECK(revocation_key->arr_len == 33);
29574         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
29575         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);
29576         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29577         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29578         Transaction_free(ret_var);
29579         return ret_arr;
29580 }
29581
29582 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
29583         LDKPublicKey funding_pubkey_ref;
29584         CHECK(funding_pubkey->arr_len == 33);
29585         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
29586         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
29587         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29588         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29589         CVec_u8Z_free(ret_var);
29590         return ret_arr;
29591 }
29592
29593 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
29594         LDKChannelTransactionParameters this_obj_conv;
29595         this_obj_conv.inner = (void*)(this_obj & (~1));
29596         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29598         ChannelTransactionParameters_free(this_obj_conv);
29599 }
29600
29601 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
29602         LDKChannelTransactionParameters this_ptr_conv;
29603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29604         this_ptr_conv.is_owned = false;
29605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29606         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
29607         uintptr_t ret_ref = 0;
29608         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29609         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29611         ret_ref = (uintptr_t)ret_var.inner;
29612         if (ret_var.is_owned) {
29613                 ret_ref |= 1;
29614         }
29615         return ret_ref;
29616 }
29617
29618 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
29619         LDKChannelTransactionParameters this_ptr_conv;
29620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29621         this_ptr_conv.is_owned = false;
29622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29623         LDKChannelPublicKeys val_conv;
29624         val_conv.inner = (void*)(val & (~1));
29625         val_conv.is_owned = (val & 1) || (val == 0);
29626         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29627         val_conv = ChannelPublicKeys_clone(&val_conv);
29628         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
29629 }
29630
29631 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
29632         LDKChannelTransactionParameters this_ptr_conv;
29633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29634         this_ptr_conv.is_owned = false;
29635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29636         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
29637         return ret_val;
29638 }
29639
29640 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) {
29641         LDKChannelTransactionParameters this_ptr_conv;
29642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29643         this_ptr_conv.is_owned = false;
29644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29645         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
29646 }
29647
29648 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
29649         LDKChannelTransactionParameters this_ptr_conv;
29650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29651         this_ptr_conv.is_owned = false;
29652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29653         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
29654         return ret_val;
29655 }
29656
29657 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
29658         LDKChannelTransactionParameters this_ptr_conv;
29659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29660         this_ptr_conv.is_owned = false;
29661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29662         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
29663 }
29664
29665 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
29666         LDKChannelTransactionParameters this_ptr_conv;
29667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29668         this_ptr_conv.is_owned = false;
29669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29670         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
29671         uintptr_t ret_ref = 0;
29672         if ((uintptr_t)ret_var.inner > 4096) {
29673                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29674                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29676                 ret_ref = (uintptr_t)ret_var.inner;
29677                 if (ret_var.is_owned) {
29678                         ret_ref |= 1;
29679                 }
29680         }
29681         return ret_ref;
29682 }
29683
29684 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
29685         LDKChannelTransactionParameters this_ptr_conv;
29686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29687         this_ptr_conv.is_owned = false;
29688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29689         LDKCounterpartyChannelTransactionParameters val_conv;
29690         val_conv.inner = (void*)(val & (~1));
29691         val_conv.is_owned = (val & 1) || (val == 0);
29692         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29693         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
29694         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
29695 }
29696
29697 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
29698         LDKChannelTransactionParameters this_ptr_conv;
29699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29700         this_ptr_conv.is_owned = false;
29701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29702         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
29703         uintptr_t ret_ref = 0;
29704         if ((uintptr_t)ret_var.inner > 4096) {
29705                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29706                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29708                 ret_ref = (uintptr_t)ret_var.inner;
29709                 if (ret_var.is_owned) {
29710                         ret_ref |= 1;
29711                 }
29712         }
29713         return ret_ref;
29714 }
29715
29716 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
29717         LDKChannelTransactionParameters this_ptr_conv;
29718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29719         this_ptr_conv.is_owned = false;
29720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29721         LDKOutPoint val_conv;
29722         val_conv.inner = (void*)(val & (~1));
29723         val_conv.is_owned = (val & 1) || (val == 0);
29724         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29725         val_conv = OutPoint_clone(&val_conv);
29726         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
29727 }
29728
29729 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
29730         LDKChannelTransactionParameters this_ptr_conv;
29731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29732         this_ptr_conv.is_owned = false;
29733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29734         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
29735         return ret_conv;
29736 }
29737
29738 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
29739         LDKChannelTransactionParameters 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         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
29744         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
29745 }
29746
29747 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) {
29748         LDKChannelPublicKeys holder_pubkeys_arg_conv;
29749         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
29750         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
29751         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
29752         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
29753         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
29754         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
29755         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
29756         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
29757         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
29758         LDKOutPoint funding_outpoint_arg_conv;
29759         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
29760         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
29761         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
29762         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
29763         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
29764         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);
29765         uintptr_t ret_ref = 0;
29766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29769         ret_ref = (uintptr_t)ret_var.inner;
29770         if (ret_var.is_owned) {
29771                 ret_ref |= 1;
29772         }
29773         return ret_ref;
29774 }
29775
29776 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
29777         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
29778 uintptr_t ret_ref = 0;
29779 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29780 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29781 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29782 ret_ref = (uintptr_t)ret_var.inner;
29783 if (ret_var.is_owned) {
29784         ret_ref |= 1;
29785 }
29786         return ret_ref;
29787 }
29788 intptr_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
29789         LDKChannelTransactionParameters arg_conv;
29790         arg_conv.inner = (void*)(arg & (~1));
29791         arg_conv.is_owned = false;
29792         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29793         intptr_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
29794         return ret_val;
29795 }
29796
29797 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
29798         LDKChannelTransactionParameters orig_conv;
29799         orig_conv.inner = (void*)(orig & (~1));
29800         orig_conv.is_owned = false;
29801         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29802         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
29803         uintptr_t ret_ref = 0;
29804         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29805         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29807         ret_ref = (uintptr_t)ret_var.inner;
29808         if (ret_var.is_owned) {
29809                 ret_ref |= 1;
29810         }
29811         return ret_ref;
29812 }
29813
29814 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
29815         LDKCounterpartyChannelTransactionParameters this_obj_conv;
29816         this_obj_conv.inner = (void*)(this_obj & (~1));
29817         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29819         CounterpartyChannelTransactionParameters_free(this_obj_conv);
29820 }
29821
29822 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
29823         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29825         this_ptr_conv.is_owned = false;
29826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29827         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
29828         uintptr_t ret_ref = 0;
29829         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29830         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29832         ret_ref = (uintptr_t)ret_var.inner;
29833         if (ret_var.is_owned) {
29834                 ret_ref |= 1;
29835         }
29836         return ret_ref;
29837 }
29838
29839 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
29840         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29842         this_ptr_conv.is_owned = false;
29843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29844         LDKChannelPublicKeys val_conv;
29845         val_conv.inner = (void*)(val & (~1));
29846         val_conv.is_owned = (val & 1) || (val == 0);
29847         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29848         val_conv = ChannelPublicKeys_clone(&val_conv);
29849         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
29850 }
29851
29852 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
29853         LDKCounterpartyChannelTransactionParameters 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         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
29858         return ret_val;
29859 }
29860
29861 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
29862         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29864         this_ptr_conv.is_owned = false;
29865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29866         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
29867 }
29868
29869 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
29870         LDKChannelPublicKeys pubkeys_arg_conv;
29871         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
29872         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
29873         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
29874         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
29875         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
29876         uintptr_t ret_ref = 0;
29877         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29878         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29880         ret_ref = (uintptr_t)ret_var.inner;
29881         if (ret_var.is_owned) {
29882                 ret_ref |= 1;
29883         }
29884         return ret_ref;
29885 }
29886
29887 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
29888         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
29889 uintptr_t ret_ref = 0;
29890 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29891 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29892 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29893 ret_ref = (uintptr_t)ret_var.inner;
29894 if (ret_var.is_owned) {
29895         ret_ref |= 1;
29896 }
29897         return ret_ref;
29898 }
29899 intptr_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
29900         LDKCounterpartyChannelTransactionParameters arg_conv;
29901         arg_conv.inner = (void*)(arg & (~1));
29902         arg_conv.is_owned = false;
29903         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29904         intptr_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
29905         return ret_val;
29906 }
29907
29908 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
29909         LDKCounterpartyChannelTransactionParameters orig_conv;
29910         orig_conv.inner = (void*)(orig & (~1));
29911         orig_conv.is_owned = false;
29912         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29913         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
29914         uintptr_t ret_ref = 0;
29915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29918         ret_ref = (uintptr_t)ret_var.inner;
29919         if (ret_var.is_owned) {
29920                 ret_ref |= 1;
29921         }
29922         return ret_ref;
29923 }
29924
29925 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
29926         LDKChannelTransactionParameters this_arg_conv;
29927         this_arg_conv.inner = (void*)(this_arg & (~1));
29928         this_arg_conv.is_owned = false;
29929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29930         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
29931         return ret_val;
29932 }
29933
29934 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
29935         LDKChannelTransactionParameters this_arg_conv;
29936         this_arg_conv.inner = (void*)(this_arg & (~1));
29937         this_arg_conv.is_owned = false;
29938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29939         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
29940         uintptr_t ret_ref = 0;
29941         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29942         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29944         ret_ref = (uintptr_t)ret_var.inner;
29945         if (ret_var.is_owned) {
29946                 ret_ref |= 1;
29947         }
29948         return ret_ref;
29949 }
29950
29951 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
29952         LDKChannelTransactionParameters this_arg_conv;
29953         this_arg_conv.inner = (void*)(this_arg & (~1));
29954         this_arg_conv.is_owned = false;
29955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29956         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
29957         uintptr_t ret_ref = 0;
29958         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29959         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29961         ret_ref = (uintptr_t)ret_var.inner;
29962         if (ret_var.is_owned) {
29963                 ret_ref |= 1;
29964         }
29965         return ret_ref;
29966 }
29967
29968 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
29969         LDKCounterpartyChannelTransactionParameters obj_conv;
29970         obj_conv.inner = (void*)(obj & (~1));
29971         obj_conv.is_owned = false;
29972         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29973         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
29974         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29975         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29976         CVec_u8Z_free(ret_var);
29977         return ret_arr;
29978 }
29979
29980 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
29981         LDKu8slice ser_ref;
29982         ser_ref.datalen = ser->arr_len;
29983         ser_ref.data = ser->elems /* XXX ser leaks */;
29984         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
29985         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
29986         return (uintptr_t)ret_conv;
29987 }
29988
29989 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
29990         LDKChannelTransactionParameters obj_conv;
29991         obj_conv.inner = (void*)(obj & (~1));
29992         obj_conv.is_owned = false;
29993         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29994         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
29995         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29996         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29997         CVec_u8Z_free(ret_var);
29998         return ret_arr;
29999 }
30000
30001 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
30002         LDKu8slice ser_ref;
30003         ser_ref.datalen = ser->arr_len;
30004         ser_ref.data = ser->elems /* XXX ser leaks */;
30005         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
30006         *ret_conv = ChannelTransactionParameters_read(ser_ref);
30007         return (uintptr_t)ret_conv;
30008 }
30009
30010 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
30011         LDKDirectedChannelTransactionParameters this_obj_conv;
30012         this_obj_conv.inner = (void*)(this_obj & (~1));
30013         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30015         DirectedChannelTransactionParameters_free(this_obj_conv);
30016 }
30017
30018 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
30019         LDKDirectedChannelTransactionParameters this_arg_conv;
30020         this_arg_conv.inner = (void*)(this_arg & (~1));
30021         this_arg_conv.is_owned = false;
30022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30023         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
30024         uintptr_t ret_ref = 0;
30025         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30026         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30028         ret_ref = (uintptr_t)ret_var.inner;
30029         if (ret_var.is_owned) {
30030                 ret_ref |= 1;
30031         }
30032         return ret_ref;
30033 }
30034
30035 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
30036         LDKDirectedChannelTransactionParameters this_arg_conv;
30037         this_arg_conv.inner = (void*)(this_arg & (~1));
30038         this_arg_conv.is_owned = false;
30039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30040         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
30041         uintptr_t ret_ref = 0;
30042         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30043         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30045         ret_ref = (uintptr_t)ret_var.inner;
30046         if (ret_var.is_owned) {
30047                 ret_ref |= 1;
30048         }
30049         return ret_ref;
30050 }
30051
30052 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
30053         LDKDirectedChannelTransactionParameters this_arg_conv;
30054         this_arg_conv.inner = (void*)(this_arg & (~1));
30055         this_arg_conv.is_owned = false;
30056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30057         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
30058         return ret_val;
30059 }
30060
30061 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
30062         LDKDirectedChannelTransactionParameters this_arg_conv;
30063         this_arg_conv.inner = (void*)(this_arg & (~1));
30064         this_arg_conv.is_owned = false;
30065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30066         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
30067         return ret_val;
30068 }
30069
30070 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
30071         LDKDirectedChannelTransactionParameters this_arg_conv;
30072         this_arg_conv.inner = (void*)(this_arg & (~1));
30073         this_arg_conv.is_owned = false;
30074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30075         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
30076         uintptr_t ret_ref = 0;
30077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30080         ret_ref = (uintptr_t)ret_var.inner;
30081         if (ret_var.is_owned) {
30082                 ret_ref |= 1;
30083         }
30084         return ret_ref;
30085 }
30086
30087 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
30088         LDKDirectedChannelTransactionParameters this_arg_conv;
30089         this_arg_conv.inner = (void*)(this_arg & (~1));
30090         this_arg_conv.is_owned = false;
30091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30092         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
30093         return ret_val;
30094 }
30095
30096 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
30097         LDKHolderCommitmentTransaction this_obj_conv;
30098         this_obj_conv.inner = (void*)(this_obj & (~1));
30099         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30101         HolderCommitmentTransaction_free(this_obj_conv);
30102 }
30103
30104 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
30105         LDKHolderCommitmentTransaction this_ptr_conv;
30106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30107         this_ptr_conv.is_owned = false;
30108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30109         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30110         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
30111         return ret_arr;
30112 }
30113
30114 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
30115         LDKHolderCommitmentTransaction this_ptr_conv;
30116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30117         this_ptr_conv.is_owned = false;
30118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30119         LDKSignature val_ref;
30120         CHECK(val->arr_len == 64);
30121         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30122         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
30123 }
30124
30125 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
30126         LDKHolderCommitmentTransaction this_ptr_conv;
30127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30128         this_ptr_conv.is_owned = false;
30129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30130         LDKCVec_SignatureZ val_constr;
30131         val_constr.datalen = val->arr_len;
30132         if (val_constr.datalen > 0)
30133                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30134         else
30135                 val_constr.data = NULL;
30136         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
30137         for (size_t m = 0; m < val_constr.datalen; m++) {
30138                 int8_tArray val_conv_12 = val_vals[m];
30139                 LDKSignature val_conv_12_ref;
30140                 CHECK(val_conv_12->arr_len == 64);
30141                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
30142                 val_constr.data[m] = val_conv_12_ref;
30143         }
30144         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
30145 }
30146
30147 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
30148         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
30149 uintptr_t ret_ref = 0;
30150 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30151 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30152 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30153 ret_ref = (uintptr_t)ret_var.inner;
30154 if (ret_var.is_owned) {
30155         ret_ref |= 1;
30156 }
30157         return ret_ref;
30158 }
30159 intptr_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
30160         LDKHolderCommitmentTransaction arg_conv;
30161         arg_conv.inner = (void*)(arg & (~1));
30162         arg_conv.is_owned = false;
30163         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30164         intptr_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
30165         return ret_val;
30166 }
30167
30168 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
30169         LDKHolderCommitmentTransaction orig_conv;
30170         orig_conv.inner = (void*)(orig & (~1));
30171         orig_conv.is_owned = false;
30172         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30173         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
30174         uintptr_t ret_ref = 0;
30175         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30176         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30178         ret_ref = (uintptr_t)ret_var.inner;
30179         if (ret_var.is_owned) {
30180                 ret_ref |= 1;
30181         }
30182         return ret_ref;
30183 }
30184
30185 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
30186         LDKHolderCommitmentTransaction obj_conv;
30187         obj_conv.inner = (void*)(obj & (~1));
30188         obj_conv.is_owned = false;
30189         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30190         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
30191         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30192         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30193         CVec_u8Z_free(ret_var);
30194         return ret_arr;
30195 }
30196
30197 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
30198         LDKu8slice ser_ref;
30199         ser_ref.datalen = ser->arr_len;
30200         ser_ref.data = ser->elems /* XXX ser leaks */;
30201         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
30202         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
30203         return (uintptr_t)ret_conv;
30204 }
30205
30206 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) {
30207         LDKCommitmentTransaction commitment_tx_conv;
30208         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
30209         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
30210         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
30211         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
30212         LDKSignature counterparty_sig_ref;
30213         CHECK(counterparty_sig->arr_len == 64);
30214         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
30215         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
30216         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
30217         if (counterparty_htlc_sigs_constr.datalen > 0)
30218                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30219         else
30220                 counterparty_htlc_sigs_constr.data = NULL;
30221         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems /* XXX counterparty_htlc_sigs leaks */;
30222         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
30223                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
30224                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
30225                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
30226                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
30227                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
30228         }
30229         LDKPublicKey holder_funding_key_ref;
30230         CHECK(holder_funding_key->arr_len == 33);
30231         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
30232         LDKPublicKey counterparty_funding_key_ref;
30233         CHECK(counterparty_funding_key->arr_len == 33);
30234         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
30235         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
30236         uintptr_t ret_ref = 0;
30237         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30238         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30240         ret_ref = (uintptr_t)ret_var.inner;
30241         if (ret_var.is_owned) {
30242                 ret_ref |= 1;
30243         }
30244         return ret_ref;
30245 }
30246
30247 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
30248         LDKBuiltCommitmentTransaction this_obj_conv;
30249         this_obj_conv.inner = (void*)(this_obj & (~1));
30250         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30252         BuiltCommitmentTransaction_free(this_obj_conv);
30253 }
30254
30255 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
30256         LDKBuiltCommitmentTransaction this_ptr_conv;
30257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30258         this_ptr_conv.is_owned = false;
30259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30260         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
30261         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30262         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30263         Transaction_free(ret_var);
30264         return ret_arr;
30265 }
30266
30267 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
30268         LDKBuiltCommitmentTransaction this_ptr_conv;
30269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30270         this_ptr_conv.is_owned = false;
30271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30272         LDKTransaction val_ref;
30273         val_ref.datalen = val->arr_len;
30274         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
30275         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
30276         val_ref.data_is_owned = true;
30277         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
30278 }
30279
30280 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
30281         LDKBuiltCommitmentTransaction this_ptr_conv;
30282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30283         this_ptr_conv.is_owned = false;
30284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30285         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30286         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
30287         return ret_arr;
30288 }
30289
30290 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
30291         LDKBuiltCommitmentTransaction this_ptr_conv;
30292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30293         this_ptr_conv.is_owned = false;
30294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30295         LDKThirtyTwoBytes val_ref;
30296         CHECK(val->arr_len == 32);
30297         memcpy(val_ref.data, val->elems, 32); FREE(val);
30298         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
30299 }
30300
30301 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
30302         LDKTransaction transaction_arg_ref;
30303         transaction_arg_ref.datalen = transaction_arg->arr_len;
30304         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
30305         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
30306         transaction_arg_ref.data_is_owned = true;
30307         LDKThirtyTwoBytes txid_arg_ref;
30308         CHECK(txid_arg->arr_len == 32);
30309         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
30310         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
30311         uintptr_t ret_ref = 0;
30312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30315         ret_ref = (uintptr_t)ret_var.inner;
30316         if (ret_var.is_owned) {
30317                 ret_ref |= 1;
30318         }
30319         return ret_ref;
30320 }
30321
30322 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
30323         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
30324 uintptr_t ret_ref = 0;
30325 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30326 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30327 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30328 ret_ref = (uintptr_t)ret_var.inner;
30329 if (ret_var.is_owned) {
30330         ret_ref |= 1;
30331 }
30332         return ret_ref;
30333 }
30334 intptr_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
30335         LDKBuiltCommitmentTransaction arg_conv;
30336         arg_conv.inner = (void*)(arg & (~1));
30337         arg_conv.is_owned = false;
30338         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30339         intptr_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
30340         return ret_val;
30341 }
30342
30343 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
30344         LDKBuiltCommitmentTransaction orig_conv;
30345         orig_conv.inner = (void*)(orig & (~1));
30346         orig_conv.is_owned = false;
30347         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30348         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
30349         uintptr_t ret_ref = 0;
30350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30353         ret_ref = (uintptr_t)ret_var.inner;
30354         if (ret_var.is_owned) {
30355                 ret_ref |= 1;
30356         }
30357         return ret_ref;
30358 }
30359
30360 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
30361         LDKBuiltCommitmentTransaction obj_conv;
30362         obj_conv.inner = (void*)(obj & (~1));
30363         obj_conv.is_owned = false;
30364         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30365         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
30366         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30367         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30368         CVec_u8Z_free(ret_var);
30369         return ret_arr;
30370 }
30371
30372 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
30373         LDKu8slice ser_ref;
30374         ser_ref.datalen = ser->arr_len;
30375         ser_ref.data = ser->elems /* XXX ser leaks */;
30376         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
30377         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
30378         return (uintptr_t)ret_conv;
30379 }
30380
30381 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) {
30382         LDKBuiltCommitmentTransaction this_arg_conv;
30383         this_arg_conv.inner = (void*)(this_arg & (~1));
30384         this_arg_conv.is_owned = false;
30385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30386         LDKu8slice funding_redeemscript_ref;
30387         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
30388         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
30389         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30390         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
30391         return ret_arr;
30392 }
30393
30394 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) {
30395         LDKBuiltCommitmentTransaction this_arg_conv;
30396         this_arg_conv.inner = (void*)(this_arg & (~1));
30397         this_arg_conv.is_owned = false;
30398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30399         unsigned char funding_key_arr[32];
30400         CHECK(funding_key->arr_len == 32);
30401         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
30402         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
30403         LDKu8slice funding_redeemscript_ref;
30404         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
30405         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
30406         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30407         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
30408         return ret_arr;
30409 }
30410
30411 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
30412         LDKClosingTransaction this_obj_conv;
30413         this_obj_conv.inner = (void*)(this_obj & (~1));
30414         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30416         ClosingTransaction_free(this_obj_conv);
30417 }
30418
30419 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
30420         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
30421 uintptr_t ret_ref = 0;
30422 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30423 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30424 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30425 ret_ref = (uintptr_t)ret_var.inner;
30426 if (ret_var.is_owned) {
30427         ret_ref |= 1;
30428 }
30429         return ret_ref;
30430 }
30431 intptr_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
30432         LDKClosingTransaction arg_conv;
30433         arg_conv.inner = (void*)(arg & (~1));
30434         arg_conv.is_owned = false;
30435         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30436         intptr_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
30437         return ret_val;
30438 }
30439
30440 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
30441         LDKClosingTransaction orig_conv;
30442         orig_conv.inner = (void*)(orig & (~1));
30443         orig_conv.is_owned = false;
30444         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30445         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
30446         uintptr_t ret_ref = 0;
30447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30450         ret_ref = (uintptr_t)ret_var.inner;
30451         if (ret_var.is_owned) {
30452                 ret_ref |= 1;
30453         }
30454         return ret_ref;
30455 }
30456
30457 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
30458         LDKClosingTransaction o_conv;
30459         o_conv.inner = (void*)(o & (~1));
30460         o_conv.is_owned = false;
30461         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
30462         int64_t ret_val = ClosingTransaction_hash(&o_conv);
30463         return ret_val;
30464 }
30465
30466 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) {
30467         LDKCVec_u8Z to_holder_script_ref;
30468         to_holder_script_ref.datalen = to_holder_script->arr_len;
30469         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
30470         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
30471         LDKCVec_u8Z to_counterparty_script_ref;
30472         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
30473         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
30474         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
30475         LDKOutPoint funding_outpoint_conv;
30476         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
30477         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
30478         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
30479         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
30480         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
30481         uintptr_t ret_ref = 0;
30482         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30483         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30485         ret_ref = (uintptr_t)ret_var.inner;
30486         if (ret_var.is_owned) {
30487                 ret_ref |= 1;
30488         }
30489         return ret_ref;
30490 }
30491
30492 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
30493         LDKClosingTransaction this_arg_conv;
30494         this_arg_conv.inner = (void*)(this_arg & (~1));
30495         this_arg_conv.is_owned = false;
30496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30497         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
30498         uintptr_t ret_ref = 0;
30499         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30500         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30502         ret_ref = (uintptr_t)ret_var.inner;
30503         if (ret_var.is_owned) {
30504                 ret_ref |= 1;
30505         }
30506         return ret_ref;
30507 }
30508
30509 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
30510         LDKClosingTransaction this_arg_conv;
30511         this_arg_conv.inner = (void*)(this_arg & (~1));
30512         this_arg_conv.is_owned = false;
30513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30514         LDKOutPoint funding_outpoint_conv;
30515         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
30516         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
30517         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
30518         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
30519         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
30520         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
30521         return (uintptr_t)ret_conv;
30522 }
30523
30524 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
30525         LDKClosingTransaction this_arg_conv;
30526         this_arg_conv.inner = (void*)(this_arg & (~1));
30527         this_arg_conv.is_owned = false;
30528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30529         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
30530         return ret_val;
30531 }
30532
30533 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
30534         LDKClosingTransaction this_arg_conv;
30535         this_arg_conv.inner = (void*)(this_arg & (~1));
30536         this_arg_conv.is_owned = false;
30537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30538         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
30539         return ret_val;
30540 }
30541
30542 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
30543         LDKClosingTransaction this_arg_conv;
30544         this_arg_conv.inner = (void*)(this_arg & (~1));
30545         this_arg_conv.is_owned = false;
30546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30547         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
30548         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30549         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30550         return ret_arr;
30551 }
30552
30553 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
30554         LDKClosingTransaction this_arg_conv;
30555         this_arg_conv.inner = (void*)(this_arg & (~1));
30556         this_arg_conv.is_owned = false;
30557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30558         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
30559         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30560         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30561         return ret_arr;
30562 }
30563
30564 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
30565         LDKTrustedClosingTransaction this_obj_conv;
30566         this_obj_conv.inner = (void*)(this_obj & (~1));
30567         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30569         TrustedClosingTransaction_free(this_obj_conv);
30570 }
30571
30572 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
30573         LDKTrustedClosingTransaction this_arg_conv;
30574         this_arg_conv.inner = (void*)(this_arg & (~1));
30575         this_arg_conv.is_owned = false;
30576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30577         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
30578         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30579         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30580         Transaction_free(ret_var);
30581         return ret_arr;
30582 }
30583
30584 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) {
30585         LDKTrustedClosingTransaction this_arg_conv;
30586         this_arg_conv.inner = (void*)(this_arg & (~1));
30587         this_arg_conv.is_owned = false;
30588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30589         LDKu8slice funding_redeemscript_ref;
30590         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
30591         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
30592         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30593         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
30594         return ret_arr;
30595 }
30596
30597 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) {
30598         LDKTrustedClosingTransaction this_arg_conv;
30599         this_arg_conv.inner = (void*)(this_arg & (~1));
30600         this_arg_conv.is_owned = false;
30601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30602         unsigned char funding_key_arr[32];
30603         CHECK(funding_key->arr_len == 32);
30604         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
30605         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
30606         LDKu8slice funding_redeemscript_ref;
30607         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
30608         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
30609         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30610         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
30611         return ret_arr;
30612 }
30613
30614 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
30615         LDKCommitmentTransaction this_obj_conv;
30616         this_obj_conv.inner = (void*)(this_obj & (~1));
30617         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30619         CommitmentTransaction_free(this_obj_conv);
30620 }
30621
30622 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
30623         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
30624 uintptr_t ret_ref = 0;
30625 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30626 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30627 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30628 ret_ref = (uintptr_t)ret_var.inner;
30629 if (ret_var.is_owned) {
30630         ret_ref |= 1;
30631 }
30632         return ret_ref;
30633 }
30634 intptr_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
30635         LDKCommitmentTransaction arg_conv;
30636         arg_conv.inner = (void*)(arg & (~1));
30637         arg_conv.is_owned = false;
30638         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30639         intptr_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
30640         return ret_val;
30641 }
30642
30643 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
30644         LDKCommitmentTransaction orig_conv;
30645         orig_conv.inner = (void*)(orig & (~1));
30646         orig_conv.is_owned = false;
30647         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30648         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
30649         uintptr_t ret_ref = 0;
30650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30653         ret_ref = (uintptr_t)ret_var.inner;
30654         if (ret_var.is_owned) {
30655                 ret_ref |= 1;
30656         }
30657         return ret_ref;
30658 }
30659
30660 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
30661         LDKCommitmentTransaction obj_conv;
30662         obj_conv.inner = (void*)(obj & (~1));
30663         obj_conv.is_owned = false;
30664         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30665         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
30666         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30667         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30668         CVec_u8Z_free(ret_var);
30669         return ret_arr;
30670 }
30671
30672 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
30673         LDKu8slice ser_ref;
30674         ser_ref.datalen = ser->arr_len;
30675         ser_ref.data = ser->elems /* XXX ser leaks */;
30676         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
30677         *ret_conv = CommitmentTransaction_read(ser_ref);
30678         return (uintptr_t)ret_conv;
30679 }
30680
30681 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
30682         LDKCommitmentTransaction this_arg_conv;
30683         this_arg_conv.inner = (void*)(this_arg & (~1));
30684         this_arg_conv.is_owned = false;
30685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30686         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
30687         return ret_val;
30688 }
30689
30690 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
30691         LDKCommitmentTransaction this_arg_conv;
30692         this_arg_conv.inner = (void*)(this_arg & (~1));
30693         this_arg_conv.is_owned = false;
30694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30695         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
30696         return ret_val;
30697 }
30698
30699 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
30700         LDKCommitmentTransaction this_arg_conv;
30701         this_arg_conv.inner = (void*)(this_arg & (~1));
30702         this_arg_conv.is_owned = false;
30703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30704         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
30705         return ret_val;
30706 }
30707
30708 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
30709         LDKCommitmentTransaction this_arg_conv;
30710         this_arg_conv.inner = (void*)(this_arg & (~1));
30711         this_arg_conv.is_owned = false;
30712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30713         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
30714         return ret_val;
30715 }
30716
30717 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
30718         LDKCommitmentTransaction this_arg_conv;
30719         this_arg_conv.inner = (void*)(this_arg & (~1));
30720         this_arg_conv.is_owned = false;
30721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30722         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
30723         uintptr_t ret_ref = 0;
30724         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30725         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30727         ret_ref = (uintptr_t)ret_var.inner;
30728         if (ret_var.is_owned) {
30729                 ret_ref |= 1;
30730         }
30731         return ret_ref;
30732 }
30733
30734 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) {
30735         LDKCommitmentTransaction this_arg_conv;
30736         this_arg_conv.inner = (void*)(this_arg & (~1));
30737         this_arg_conv.is_owned = false;
30738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30739         LDKDirectedChannelTransactionParameters channel_parameters_conv;
30740         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
30741         channel_parameters_conv.is_owned = false;
30742         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
30743         LDKChannelPublicKeys broadcaster_keys_conv;
30744         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
30745         broadcaster_keys_conv.is_owned = false;
30746         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
30747         LDKChannelPublicKeys countersignatory_keys_conv;
30748         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
30749         countersignatory_keys_conv.is_owned = false;
30750         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
30751         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
30752         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
30753         return (uintptr_t)ret_conv;
30754 }
30755
30756 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
30757         LDKTrustedCommitmentTransaction this_obj_conv;
30758         this_obj_conv.inner = (void*)(this_obj & (~1));
30759         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30761         TrustedCommitmentTransaction_free(this_obj_conv);
30762 }
30763
30764 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
30765         LDKTrustedCommitmentTransaction this_arg_conv;
30766         this_arg_conv.inner = (void*)(this_arg & (~1));
30767         this_arg_conv.is_owned = false;
30768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30769         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30770         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
30771         return ret_arr;
30772 }
30773
30774 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
30775         LDKTrustedCommitmentTransaction this_arg_conv;
30776         this_arg_conv.inner = (void*)(this_arg & (~1));
30777         this_arg_conv.is_owned = false;
30778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30779         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
30780         uintptr_t ret_ref = 0;
30781         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30782         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30784         ret_ref = (uintptr_t)ret_var.inner;
30785         if (ret_var.is_owned) {
30786                 ret_ref |= 1;
30787         }
30788         return ret_ref;
30789 }
30790
30791 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
30792         LDKTrustedCommitmentTransaction this_arg_conv;
30793         this_arg_conv.inner = (void*)(this_arg & (~1));
30794         this_arg_conv.is_owned = false;
30795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30796         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
30797         uintptr_t ret_ref = 0;
30798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30801         ret_ref = (uintptr_t)ret_var.inner;
30802         if (ret_var.is_owned) {
30803                 ret_ref |= 1;
30804         }
30805         return ret_ref;
30806 }
30807
30808 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
30809         LDKTrustedCommitmentTransaction this_arg_conv;
30810         this_arg_conv.inner = (void*)(this_arg & (~1));
30811         this_arg_conv.is_owned = false;
30812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30813         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
30814         return ret_val;
30815 }
30816
30817 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) {
30818         LDKTrustedCommitmentTransaction this_arg_conv;
30819         this_arg_conv.inner = (void*)(this_arg & (~1));
30820         this_arg_conv.is_owned = false;
30821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30822         unsigned char htlc_base_key_arr[32];
30823         CHECK(htlc_base_key->arr_len == 32);
30824         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
30825         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
30826         LDKDirectedChannelTransactionParameters channel_parameters_conv;
30827         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
30828         channel_parameters_conv.is_owned = false;
30829         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
30830         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
30831         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
30832         return (uintptr_t)ret_conv;
30833 }
30834
30835 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) {
30836         LDKPublicKey broadcaster_payment_basepoint_ref;
30837         CHECK(broadcaster_payment_basepoint->arr_len == 33);
30838         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
30839         LDKPublicKey countersignatory_payment_basepoint_ref;
30840         CHECK(countersignatory_payment_basepoint->arr_len == 33);
30841         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
30842         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
30843         return ret_val;
30844 }
30845
30846 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
30847         LDKInitFeatures a_conv;
30848         a_conv.inner = (void*)(a & (~1));
30849         a_conv.is_owned = false;
30850         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30851         LDKInitFeatures b_conv;
30852         b_conv.inner = (void*)(b & (~1));
30853         b_conv.is_owned = false;
30854         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30855         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
30856         return ret_val;
30857 }
30858
30859 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
30860         LDKNodeFeatures a_conv;
30861         a_conv.inner = (void*)(a & (~1));
30862         a_conv.is_owned = false;
30863         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30864         LDKNodeFeatures b_conv;
30865         b_conv.inner = (void*)(b & (~1));
30866         b_conv.is_owned = false;
30867         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30868         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
30869         return ret_val;
30870 }
30871
30872 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
30873         LDKChannelFeatures a_conv;
30874         a_conv.inner = (void*)(a & (~1));
30875         a_conv.is_owned = false;
30876         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30877         LDKChannelFeatures b_conv;
30878         b_conv.inner = (void*)(b & (~1));
30879         b_conv.is_owned = false;
30880         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30881         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
30882         return ret_val;
30883 }
30884
30885 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
30886         LDKInvoiceFeatures a_conv;
30887         a_conv.inner = (void*)(a & (~1));
30888         a_conv.is_owned = false;
30889         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30890         LDKInvoiceFeatures b_conv;
30891         b_conv.inner = (void*)(b & (~1));
30892         b_conv.is_owned = false;
30893         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30894         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
30895         return ret_val;
30896 }
30897
30898 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
30899         LDKChannelTypeFeatures a_conv;
30900         a_conv.inner = (void*)(a & (~1));
30901         a_conv.is_owned = false;
30902         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30903         LDKChannelTypeFeatures b_conv;
30904         b_conv.inner = (void*)(b & (~1));
30905         b_conv.is_owned = false;
30906         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30907         jboolean ret_val = ChannelTypeFeatures_eq(&a_conv, &b_conv);
30908         return ret_val;
30909 }
30910
30911 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
30912         LDKInitFeatures ret_var = InitFeatures_clone(arg);
30913 uintptr_t ret_ref = 0;
30914 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30915 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30916 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30917 ret_ref = (uintptr_t)ret_var.inner;
30918 if (ret_var.is_owned) {
30919         ret_ref |= 1;
30920 }
30921         return ret_ref;
30922 }
30923 intptr_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
30924         LDKInitFeatures arg_conv;
30925         arg_conv.inner = (void*)(arg & (~1));
30926         arg_conv.is_owned = false;
30927         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30928         intptr_t ret_val = InitFeatures_clone_ptr(&arg_conv);
30929         return ret_val;
30930 }
30931
30932 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
30933         LDKInitFeatures orig_conv;
30934         orig_conv.inner = (void*)(orig & (~1));
30935         orig_conv.is_owned = false;
30936         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30937         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
30938         uintptr_t ret_ref = 0;
30939         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30940         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30942         ret_ref = (uintptr_t)ret_var.inner;
30943         if (ret_var.is_owned) {
30944                 ret_ref |= 1;
30945         }
30946         return ret_ref;
30947 }
30948
30949 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
30950         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
30951 uintptr_t ret_ref = 0;
30952 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30953 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30954 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30955 ret_ref = (uintptr_t)ret_var.inner;
30956 if (ret_var.is_owned) {
30957         ret_ref |= 1;
30958 }
30959         return ret_ref;
30960 }
30961 intptr_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
30962         LDKNodeFeatures arg_conv;
30963         arg_conv.inner = (void*)(arg & (~1));
30964         arg_conv.is_owned = false;
30965         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30966         intptr_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
30967         return ret_val;
30968 }
30969
30970 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
30971         LDKNodeFeatures orig_conv;
30972         orig_conv.inner = (void*)(orig & (~1));
30973         orig_conv.is_owned = false;
30974         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30975         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
30976         uintptr_t ret_ref = 0;
30977         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30978         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30980         ret_ref = (uintptr_t)ret_var.inner;
30981         if (ret_var.is_owned) {
30982                 ret_ref |= 1;
30983         }
30984         return ret_ref;
30985 }
30986
30987 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
30988         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
30989 uintptr_t ret_ref = 0;
30990 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30991 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30992 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30993 ret_ref = (uintptr_t)ret_var.inner;
30994 if (ret_var.is_owned) {
30995         ret_ref |= 1;
30996 }
30997         return ret_ref;
30998 }
30999 intptr_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
31000         LDKChannelFeatures arg_conv;
31001         arg_conv.inner = (void*)(arg & (~1));
31002         arg_conv.is_owned = false;
31003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31004         intptr_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
31005         return ret_val;
31006 }
31007
31008 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
31009         LDKChannelFeatures orig_conv;
31010         orig_conv.inner = (void*)(orig & (~1));
31011         orig_conv.is_owned = false;
31012         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31013         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
31014         uintptr_t ret_ref = 0;
31015         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31016         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31018         ret_ref = (uintptr_t)ret_var.inner;
31019         if (ret_var.is_owned) {
31020                 ret_ref |= 1;
31021         }
31022         return ret_ref;
31023 }
31024
31025 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
31026         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
31027 uintptr_t ret_ref = 0;
31028 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31029 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31030 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31031 ret_ref = (uintptr_t)ret_var.inner;
31032 if (ret_var.is_owned) {
31033         ret_ref |= 1;
31034 }
31035         return ret_ref;
31036 }
31037 intptr_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
31038         LDKInvoiceFeatures arg_conv;
31039         arg_conv.inner = (void*)(arg & (~1));
31040         arg_conv.is_owned = false;
31041         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31042         intptr_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
31043         return ret_val;
31044 }
31045
31046 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
31047         LDKInvoiceFeatures orig_conv;
31048         orig_conv.inner = (void*)(orig & (~1));
31049         orig_conv.is_owned = false;
31050         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31051         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
31052         uintptr_t ret_ref = 0;
31053         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31054         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31056         ret_ref = (uintptr_t)ret_var.inner;
31057         if (ret_var.is_owned) {
31058                 ret_ref |= 1;
31059         }
31060         return ret_ref;
31061 }
31062
31063 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
31064         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
31065 uintptr_t ret_ref = 0;
31066 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31067 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31068 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31069 ret_ref = (uintptr_t)ret_var.inner;
31070 if (ret_var.is_owned) {
31071         ret_ref |= 1;
31072 }
31073         return ret_ref;
31074 }
31075 intptr_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
31076         LDKChannelTypeFeatures arg_conv;
31077         arg_conv.inner = (void*)(arg & (~1));
31078         arg_conv.is_owned = false;
31079         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31080         intptr_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
31081         return ret_val;
31082 }
31083
31084 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
31085         LDKChannelTypeFeatures orig_conv;
31086         orig_conv.inner = (void*)(orig & (~1));
31087         orig_conv.is_owned = false;
31088         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31089         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
31090         uintptr_t ret_ref = 0;
31091         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31092         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31094         ret_ref = (uintptr_t)ret_var.inner;
31095         if (ret_var.is_owned) {
31096                 ret_ref |= 1;
31097         }
31098         return ret_ref;
31099 }
31100
31101 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
31102         LDKInitFeatures this_obj_conv;
31103         this_obj_conv.inner = (void*)(this_obj & (~1));
31104         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31106         InitFeatures_free(this_obj_conv);
31107 }
31108
31109 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
31110         LDKNodeFeatures this_obj_conv;
31111         this_obj_conv.inner = (void*)(this_obj & (~1));
31112         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31114         NodeFeatures_free(this_obj_conv);
31115 }
31116
31117 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
31118         LDKChannelFeatures this_obj_conv;
31119         this_obj_conv.inner = (void*)(this_obj & (~1));
31120         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31122         ChannelFeatures_free(this_obj_conv);
31123 }
31124
31125 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
31126         LDKInvoiceFeatures this_obj_conv;
31127         this_obj_conv.inner = (void*)(this_obj & (~1));
31128         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31130         InvoiceFeatures_free(this_obj_conv);
31131 }
31132
31133 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
31134         LDKChannelTypeFeatures this_obj_conv;
31135         this_obj_conv.inner = (void*)(this_obj & (~1));
31136         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31138         ChannelTypeFeatures_free(this_obj_conv);
31139 }
31140
31141 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
31142         LDKInitFeatures ret_var = InitFeatures_empty();
31143         uintptr_t ret_ref = 0;
31144         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31145         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31146         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31147         ret_ref = (uintptr_t)ret_var.inner;
31148         if (ret_var.is_owned) {
31149                 ret_ref |= 1;
31150         }
31151         return ret_ref;
31152 }
31153
31154 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
31155         LDKInitFeatures ret_var = InitFeatures_known();
31156         uintptr_t ret_ref = 0;
31157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31160         ret_ref = (uintptr_t)ret_var.inner;
31161         if (ret_var.is_owned) {
31162                 ret_ref |= 1;
31163         }
31164         return ret_ref;
31165 }
31166
31167 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
31168         LDKInitFeatures this_arg_conv;
31169         this_arg_conv.inner = (void*)(this_arg & (~1));
31170         this_arg_conv.is_owned = false;
31171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31172         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
31173         return ret_val;
31174 }
31175
31176 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
31177         LDKNodeFeatures ret_var = NodeFeatures_empty();
31178         uintptr_t ret_ref = 0;
31179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31182         ret_ref = (uintptr_t)ret_var.inner;
31183         if (ret_var.is_owned) {
31184                 ret_ref |= 1;
31185         }
31186         return ret_ref;
31187 }
31188
31189 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
31190         LDKNodeFeatures ret_var = NodeFeatures_known();
31191         uintptr_t ret_ref = 0;
31192         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31193         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31195         ret_ref = (uintptr_t)ret_var.inner;
31196         if (ret_var.is_owned) {
31197                 ret_ref |= 1;
31198         }
31199         return ret_ref;
31200 }
31201
31202 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
31203         LDKNodeFeatures this_arg_conv;
31204         this_arg_conv.inner = (void*)(this_arg & (~1));
31205         this_arg_conv.is_owned = false;
31206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31207         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
31208         return ret_val;
31209 }
31210
31211 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
31212         LDKChannelFeatures ret_var = ChannelFeatures_empty();
31213         uintptr_t ret_ref = 0;
31214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31217         ret_ref = (uintptr_t)ret_var.inner;
31218         if (ret_var.is_owned) {
31219                 ret_ref |= 1;
31220         }
31221         return ret_ref;
31222 }
31223
31224 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
31225         LDKChannelFeatures ret_var = ChannelFeatures_known();
31226         uintptr_t ret_ref = 0;
31227         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31228         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31230         ret_ref = (uintptr_t)ret_var.inner;
31231         if (ret_var.is_owned) {
31232                 ret_ref |= 1;
31233         }
31234         return ret_ref;
31235 }
31236
31237 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
31238         LDKChannelFeatures this_arg_conv;
31239         this_arg_conv.inner = (void*)(this_arg & (~1));
31240         this_arg_conv.is_owned = false;
31241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31242         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
31243         return ret_val;
31244 }
31245
31246 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
31247         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
31248         uintptr_t ret_ref = 0;
31249         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31250         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31252         ret_ref = (uintptr_t)ret_var.inner;
31253         if (ret_var.is_owned) {
31254                 ret_ref |= 1;
31255         }
31256         return ret_ref;
31257 }
31258
31259 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
31260         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
31261         uintptr_t ret_ref = 0;
31262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31265         ret_ref = (uintptr_t)ret_var.inner;
31266         if (ret_var.is_owned) {
31267                 ret_ref |= 1;
31268         }
31269         return ret_ref;
31270 }
31271
31272 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
31273         LDKInvoiceFeatures this_arg_conv;
31274         this_arg_conv.inner = (void*)(this_arg & (~1));
31275         this_arg_conv.is_owned = false;
31276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31277         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
31278         return ret_val;
31279 }
31280
31281 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
31282         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
31283         uintptr_t ret_ref = 0;
31284         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31285         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31287         ret_ref = (uintptr_t)ret_var.inner;
31288         if (ret_var.is_owned) {
31289                 ret_ref |= 1;
31290         }
31291         return ret_ref;
31292 }
31293
31294 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
31295         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
31296         uintptr_t ret_ref = 0;
31297         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31298         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31300         ret_ref = (uintptr_t)ret_var.inner;
31301         if (ret_var.is_owned) {
31302                 ret_ref |= 1;
31303         }
31304         return ret_ref;
31305 }
31306
31307 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
31308         LDKChannelTypeFeatures this_arg_conv;
31309         this_arg_conv.inner = (void*)(this_arg & (~1));
31310         this_arg_conv.is_owned = false;
31311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31312         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
31313         return ret_val;
31314 }
31315
31316 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
31317         LDKInitFeatures obj_conv;
31318         obj_conv.inner = (void*)(obj & (~1));
31319         obj_conv.is_owned = false;
31320         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31321         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
31322         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31323         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31324         CVec_u8Z_free(ret_var);
31325         return ret_arr;
31326 }
31327
31328 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
31329         LDKu8slice ser_ref;
31330         ser_ref.datalen = ser->arr_len;
31331         ser_ref.data = ser->elems /* XXX ser leaks */;
31332         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
31333         *ret_conv = InitFeatures_read(ser_ref);
31334         return (uintptr_t)ret_conv;
31335 }
31336
31337 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
31338         LDKChannelFeatures obj_conv;
31339         obj_conv.inner = (void*)(obj & (~1));
31340         obj_conv.is_owned = false;
31341         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31342         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
31343         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31344         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31345         CVec_u8Z_free(ret_var);
31346         return ret_arr;
31347 }
31348
31349 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
31350         LDKu8slice ser_ref;
31351         ser_ref.datalen = ser->arr_len;
31352         ser_ref.data = ser->elems /* XXX ser leaks */;
31353         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
31354         *ret_conv = ChannelFeatures_read(ser_ref);
31355         return (uintptr_t)ret_conv;
31356 }
31357
31358 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
31359         LDKNodeFeatures obj_conv;
31360         obj_conv.inner = (void*)(obj & (~1));
31361         obj_conv.is_owned = false;
31362         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31363         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
31364         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31365         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31366         CVec_u8Z_free(ret_var);
31367         return ret_arr;
31368 }
31369
31370 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
31371         LDKu8slice ser_ref;
31372         ser_ref.datalen = ser->arr_len;
31373         ser_ref.data = ser->elems /* XXX ser leaks */;
31374         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
31375         *ret_conv = NodeFeatures_read(ser_ref);
31376         return (uintptr_t)ret_conv;
31377 }
31378
31379 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
31380         LDKInvoiceFeatures obj_conv;
31381         obj_conv.inner = (void*)(obj & (~1));
31382         obj_conv.is_owned = false;
31383         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31384         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
31385         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31386         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31387         CVec_u8Z_free(ret_var);
31388         return ret_arr;
31389 }
31390
31391 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
31392         LDKu8slice ser_ref;
31393         ser_ref.datalen = ser->arr_len;
31394         ser_ref.data = ser->elems /* XXX ser leaks */;
31395         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
31396         *ret_conv = InvoiceFeatures_read(ser_ref);
31397         return (uintptr_t)ret_conv;
31398 }
31399
31400 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
31401         LDKChannelTypeFeatures obj_conv;
31402         obj_conv.inner = (void*)(obj & (~1));
31403         obj_conv.is_owned = false;
31404         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31405         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
31406         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31407         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31408         CVec_u8Z_free(ret_var);
31409         return ret_arr;
31410 }
31411
31412 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
31413         LDKu8slice ser_ref;
31414         ser_ref.datalen = ser->arr_len;
31415         ser_ref.data = ser->elems /* XXX ser leaks */;
31416         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
31417         *ret_conv = ChannelTypeFeatures_read(ser_ref);
31418         return (uintptr_t)ret_conv;
31419 }
31420
31421 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
31422         LDKShutdownScript this_obj_conv;
31423         this_obj_conv.inner = (void*)(this_obj & (~1));
31424         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31426         ShutdownScript_free(this_obj_conv);
31427 }
31428
31429 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
31430         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
31431 uintptr_t ret_ref = 0;
31432 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31433 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31434 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31435 ret_ref = (uintptr_t)ret_var.inner;
31436 if (ret_var.is_owned) {
31437         ret_ref |= 1;
31438 }
31439         return ret_ref;
31440 }
31441 intptr_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
31442         LDKShutdownScript arg_conv;
31443         arg_conv.inner = (void*)(arg & (~1));
31444         arg_conv.is_owned = false;
31445         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31446         intptr_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
31447         return ret_val;
31448 }
31449
31450 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
31451         LDKShutdownScript orig_conv;
31452         orig_conv.inner = (void*)(orig & (~1));
31453         orig_conv.is_owned = false;
31454         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31455         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
31456         uintptr_t ret_ref = 0;
31457         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31458         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31460         ret_ref = (uintptr_t)ret_var.inner;
31461         if (ret_var.is_owned) {
31462                 ret_ref |= 1;
31463         }
31464         return ret_ref;
31465 }
31466
31467 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
31468         LDKInvalidShutdownScript this_obj_conv;
31469         this_obj_conv.inner = (void*)(this_obj & (~1));
31470         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31472         InvalidShutdownScript_free(this_obj_conv);
31473 }
31474
31475 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
31476         LDKInvalidShutdownScript this_ptr_conv;
31477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31478         this_ptr_conv.is_owned = false;
31479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31480         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
31481         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31482         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31483         return ret_arr;
31484 }
31485
31486 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
31487         LDKInvalidShutdownScript this_ptr_conv;
31488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31489         this_ptr_conv.is_owned = false;
31490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31491         LDKCVec_u8Z val_ref;
31492         val_ref.datalen = val->arr_len;
31493         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
31494         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
31495         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
31496 }
31497
31498 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
31499         LDKCVec_u8Z script_arg_ref;
31500         script_arg_ref.datalen = script_arg->arr_len;
31501         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
31502         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
31503         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
31504         uintptr_t ret_ref = 0;
31505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31508         ret_ref = (uintptr_t)ret_var.inner;
31509         if (ret_var.is_owned) {
31510                 ret_ref |= 1;
31511         }
31512         return ret_ref;
31513 }
31514
31515 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
31516         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
31517 uintptr_t ret_ref = 0;
31518 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31519 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31520 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31521 ret_ref = (uintptr_t)ret_var.inner;
31522 if (ret_var.is_owned) {
31523         ret_ref |= 1;
31524 }
31525         return ret_ref;
31526 }
31527 intptr_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
31528         LDKInvalidShutdownScript arg_conv;
31529         arg_conv.inner = (void*)(arg & (~1));
31530         arg_conv.is_owned = false;
31531         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31532         intptr_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
31533         return ret_val;
31534 }
31535
31536 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
31537         LDKInvalidShutdownScript orig_conv;
31538         orig_conv.inner = (void*)(orig & (~1));
31539         orig_conv.is_owned = false;
31540         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31541         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
31542         uintptr_t ret_ref = 0;
31543         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31544         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31546         ret_ref = (uintptr_t)ret_var.inner;
31547         if (ret_var.is_owned) {
31548                 ret_ref |= 1;
31549         }
31550         return ret_ref;
31551 }
31552
31553 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
31554         LDKShutdownScript obj_conv;
31555         obj_conv.inner = (void*)(obj & (~1));
31556         obj_conv.is_owned = false;
31557         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31558         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
31559         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31560         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31561         CVec_u8Z_free(ret_var);
31562         return ret_arr;
31563 }
31564
31565 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
31566         LDKu8slice ser_ref;
31567         ser_ref.datalen = ser->arr_len;
31568         ser_ref.data = ser->elems /* XXX ser leaks */;
31569         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
31570         *ret_conv = ShutdownScript_read(ser_ref);
31571         return (uintptr_t)ret_conv;
31572 }
31573
31574 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
31575         unsigned char pubkey_hash_arr[20];
31576         CHECK(pubkey_hash->arr_len == 20);
31577         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
31578         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
31579         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
31580         uintptr_t ret_ref = 0;
31581         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31582         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31584         ret_ref = (uintptr_t)ret_var.inner;
31585         if (ret_var.is_owned) {
31586                 ret_ref |= 1;
31587         }
31588         return ret_ref;
31589 }
31590
31591 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
31592         unsigned char script_hash_arr[32];
31593         CHECK(script_hash->arr_len == 32);
31594         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
31595         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
31596         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
31597         uintptr_t ret_ref = 0;
31598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31601         ret_ref = (uintptr_t)ret_var.inner;
31602         if (ret_var.is_owned) {
31603                 ret_ref |= 1;
31604         }
31605         return ret_ref;
31606 }
31607
31608 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
31609         LDKu8slice program_ref;
31610         program_ref.datalen = program->arr_len;
31611         program_ref.data = program->elems /* XXX program leaks */;
31612         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
31613         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
31614         return (uintptr_t)ret_conv;
31615 }
31616
31617 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
31618         LDKShutdownScript this_arg_conv;
31619         this_arg_conv.inner = (void*)(this_arg & (~1));
31620         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
31621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31622         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
31623         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
31624         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31625         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31626         CVec_u8Z_free(ret_var);
31627         return ret_arr;
31628 }
31629
31630 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
31631         LDKShutdownScript this_arg_conv;
31632         this_arg_conv.inner = (void*)(this_arg & (~1));
31633         this_arg_conv.is_owned = false;
31634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31635         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31636         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
31637         return ret_arr;
31638 }
31639
31640 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
31641         LDKShutdownScript this_arg_conv;
31642         this_arg_conv.inner = (void*)(this_arg & (~1));
31643         this_arg_conv.is_owned = false;
31644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31645         LDKInitFeatures features_conv;
31646         features_conv.inner = (void*)(features & (~1));
31647         features_conv.is_owned = false;
31648         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
31649         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
31650         return ret_val;
31651 }
31652
31653 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
31654         if ((this_ptr & 1) != 0) return;
31655         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31656         CHECK_ACCESS(this_ptr_ptr);
31657         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
31658         FREE((void*)this_ptr);
31659         CustomMessageReader_free(this_ptr_conv);
31660 }
31661
31662 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
31663         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
31664         *ret_ret = Type_clone(arg);
31665         return (uintptr_t)ret_ret;
31666 }
31667 intptr_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
31668         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
31669         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
31670         LDKType* arg_conv = (LDKType*)arg_ptr;
31671         intptr_t ret_val = Type_clone_ptr(arg_conv);
31672         return ret_val;
31673 }
31674
31675 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
31676         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
31677         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
31678         LDKType* orig_conv = (LDKType*)orig_ptr;
31679         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
31680         *ret_ret = Type_clone(orig_conv);
31681         return (uintptr_t)ret_ret;
31682 }
31683
31684 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
31685         if ((this_ptr & 1) != 0) return;
31686         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31687         CHECK_ACCESS(this_ptr_ptr);
31688         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
31689         FREE((void*)this_ptr);
31690         Type_free(this_ptr_conv);
31691 }
31692
31693 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
31694         LDKNodeId this_obj_conv;
31695         this_obj_conv.inner = (void*)(this_obj & (~1));
31696         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31698         NodeId_free(this_obj_conv);
31699 }
31700
31701 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
31702         LDKNodeId ret_var = NodeId_clone(arg);
31703 uintptr_t ret_ref = 0;
31704 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31705 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31706 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31707 ret_ref = (uintptr_t)ret_var.inner;
31708 if (ret_var.is_owned) {
31709         ret_ref |= 1;
31710 }
31711         return ret_ref;
31712 }
31713 intptr_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
31714         LDKNodeId arg_conv;
31715         arg_conv.inner = (void*)(arg & (~1));
31716         arg_conv.is_owned = false;
31717         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31718         intptr_t ret_val = NodeId_clone_ptr(&arg_conv);
31719         return ret_val;
31720 }
31721
31722 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
31723         LDKNodeId orig_conv;
31724         orig_conv.inner = (void*)(orig & (~1));
31725         orig_conv.is_owned = false;
31726         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31727         LDKNodeId ret_var = NodeId_clone(&orig_conv);
31728         uintptr_t ret_ref = 0;
31729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31732         ret_ref = (uintptr_t)ret_var.inner;
31733         if (ret_var.is_owned) {
31734                 ret_ref |= 1;
31735         }
31736         return ret_ref;
31737 }
31738
31739 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
31740         LDKPublicKey pubkey_ref;
31741         CHECK(pubkey->arr_len == 33);
31742         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
31743         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
31744         uintptr_t ret_ref = 0;
31745         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31746         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31748         ret_ref = (uintptr_t)ret_var.inner;
31749         if (ret_var.is_owned) {
31750                 ret_ref |= 1;
31751         }
31752         return ret_ref;
31753 }
31754
31755 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
31756         LDKNodeId this_arg_conv;
31757         this_arg_conv.inner = (void*)(this_arg & (~1));
31758         this_arg_conv.is_owned = false;
31759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31760         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
31761         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31762         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31763         return ret_arr;
31764 }
31765
31766 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
31767         LDKNodeId o_conv;
31768         o_conv.inner = (void*)(o & (~1));
31769         o_conv.is_owned = false;
31770         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
31771         int64_t ret_val = NodeId_hash(&o_conv);
31772         return ret_val;
31773 }
31774
31775 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
31776         LDKNodeId obj_conv;
31777         obj_conv.inner = (void*)(obj & (~1));
31778         obj_conv.is_owned = false;
31779         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31780         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
31781         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31782         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31783         CVec_u8Z_free(ret_var);
31784         return ret_arr;
31785 }
31786
31787 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
31788         LDKu8slice ser_ref;
31789         ser_ref.datalen = ser->arr_len;
31790         ser_ref.data = ser->elems /* XXX ser leaks */;
31791         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
31792         *ret_conv = NodeId_read(ser_ref);
31793         return (uintptr_t)ret_conv;
31794 }
31795
31796 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
31797         LDKNetworkGraph this_obj_conv;
31798         this_obj_conv.inner = (void*)(this_obj & (~1));
31799         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31801         NetworkGraph_free(this_obj_conv);
31802 }
31803
31804 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
31805         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
31806 uintptr_t ret_ref = 0;
31807 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31808 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31809 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31810 ret_ref = (uintptr_t)ret_var.inner;
31811 if (ret_var.is_owned) {
31812         ret_ref |= 1;
31813 }
31814         return ret_ref;
31815 }
31816 intptr_t  __attribute__((export_name("TS_NetworkGraph_clone_ptr"))) TS_NetworkGraph_clone_ptr(uint32_t arg) {
31817         LDKNetworkGraph arg_conv;
31818         arg_conv.inner = (void*)(arg & (~1));
31819         arg_conv.is_owned = false;
31820         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31821         intptr_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
31822         return ret_val;
31823 }
31824
31825 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone"))) TS_NetworkGraph_clone(uint32_t orig) {
31826         LDKNetworkGraph orig_conv;
31827         orig_conv.inner = (void*)(orig & (~1));
31828         orig_conv.is_owned = false;
31829         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31830         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
31831         uintptr_t ret_ref = 0;
31832         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31833         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31835         ret_ref = (uintptr_t)ret_var.inner;
31836         if (ret_var.is_owned) {
31837                 ret_ref |= 1;
31838         }
31839         return ret_ref;
31840 }
31841
31842 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
31843         LDKReadOnlyNetworkGraph this_obj_conv;
31844         this_obj_conv.inner = (void*)(this_obj & (~1));
31845         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31847         ReadOnlyNetworkGraph_free(this_obj_conv);
31848 }
31849
31850 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
31851         if ((this_ptr & 1) != 0) return;
31852         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31853         CHECK_ACCESS(this_ptr_ptr);
31854         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
31855         FREE((void*)this_ptr);
31856         NetworkUpdate_free(this_ptr_conv);
31857 }
31858
31859 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
31860         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31861         *ret_copy = NetworkUpdate_clone(arg);
31862 uintptr_t ret_ref = (uintptr_t)ret_copy;
31863         return ret_ref;
31864 }
31865 intptr_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
31866         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
31867         intptr_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
31868         return ret_val;
31869 }
31870
31871 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
31872         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
31873         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31874         *ret_copy = NetworkUpdate_clone(orig_conv);
31875         uintptr_t ret_ref = (uintptr_t)ret_copy;
31876         return ret_ref;
31877 }
31878
31879 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
31880         LDKChannelUpdate msg_conv;
31881         msg_conv.inner = (void*)(msg & (~1));
31882         msg_conv.is_owned = (msg & 1) || (msg == 0);
31883         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31884         msg_conv = ChannelUpdate_clone(&msg_conv);
31885         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31886         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
31887         uintptr_t ret_ref = (uintptr_t)ret_copy;
31888         return ret_ref;
31889 }
31890
31891 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_closed"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
31892         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31893         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
31894         uintptr_t ret_ref = (uintptr_t)ret_copy;
31895         return ret_ref;
31896 }
31897
31898 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
31899         LDKPublicKey node_id_ref;
31900         CHECK(node_id->arr_len == 33);
31901         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
31902         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31903         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
31904         uintptr_t ret_ref = (uintptr_t)ret_copy;
31905         return ret_ref;
31906 }
31907
31908 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
31909         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
31910         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
31911         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31912         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31913         CVec_u8Z_free(ret_var);
31914         return ret_arr;
31915 }
31916
31917 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
31918         LDKu8slice ser_ref;
31919         ser_ref.datalen = ser->arr_len;
31920         ser_ref.data = ser->elems /* XXX ser leaks */;
31921         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
31922         *ret_conv = NetworkUpdate_read(ser_ref);
31923         return (uintptr_t)ret_conv;
31924 }
31925
31926 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_EventHandler"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
31927         LDKNetGraphMsgHandler this_arg_conv;
31928         this_arg_conv.inner = (void*)(this_arg & (~1));
31929         this_arg_conv.is_owned = false;
31930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31931         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
31932         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
31933         return (uintptr_t)ret_ret;
31934 }
31935
31936 void  __attribute__((export_name("TS_NetGraphMsgHandler_free"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
31937         LDKNetGraphMsgHandler this_obj_conv;
31938         this_obj_conv.inner = (void*)(this_obj & (~1));
31939         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31941         NetGraphMsgHandler_free(this_obj_conv);
31942 }
31943
31944 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_new"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
31945         LDKNetworkGraph network_graph_conv;
31946         network_graph_conv.inner = (void*)(network_graph & (~1));
31947         network_graph_conv.is_owned = false;
31948         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
31949         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
31950         CHECK_ACCESS(chain_access_ptr);
31951         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
31952         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
31953         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
31954                 // Manually implement clone for Java trait instances
31955         }
31956         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
31957         CHECK_ACCESS(logger_ptr);
31958         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31959         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
31960         uintptr_t ret_ref = 0;
31961         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31962         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31964         ret_ref = (uintptr_t)ret_var.inner;
31965         if (ret_var.is_owned) {
31966                 ret_ref |= 1;
31967         }
31968         return ret_ref;
31969 }
31970
31971 void  __attribute__((export_name("TS_NetGraphMsgHandler_add_chain_access"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
31972         LDKNetGraphMsgHandler this_arg_conv;
31973         this_arg_conv.inner = (void*)(this_arg & (~1));
31974         this_arg_conv.is_owned = false;
31975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31976         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
31977         CHECK_ACCESS(chain_access_ptr);
31978         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
31979         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
31980         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
31981                 // Manually implement clone for Java trait instances
31982         }
31983         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
31984 }
31985
31986 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_RoutingMessageHandler"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
31987         LDKNetGraphMsgHandler this_arg_conv;
31988         this_arg_conv.inner = (void*)(this_arg & (~1));
31989         this_arg_conv.is_owned = false;
31990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31991         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
31992         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
31993         return (uintptr_t)ret_ret;
31994 }
31995
31996 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_MessageSendEventsProvider"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
31997         LDKNetGraphMsgHandler this_arg_conv;
31998         this_arg_conv.inner = (void*)(this_arg & (~1));
31999         this_arg_conv.is_owned = false;
32000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32001         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32002         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
32003         return (uintptr_t)ret_ret;
32004 }
32005
32006 void  __attribute__((export_name("TS_DirectionalChannelInfo_free"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
32007         LDKDirectionalChannelInfo this_obj_conv;
32008         this_obj_conv.inner = (void*)(this_obj & (~1));
32009         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32011         DirectionalChannelInfo_free(this_obj_conv);
32012 }
32013
32014 int32_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_last_update"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
32015         LDKDirectionalChannelInfo this_ptr_conv;
32016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32017         this_ptr_conv.is_owned = false;
32018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32019         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
32020         return ret_val;
32021 }
32022
32023 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_last_update"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
32024         LDKDirectionalChannelInfo this_ptr_conv;
32025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32026         this_ptr_conv.is_owned = false;
32027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32028         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
32029 }
32030
32031 jboolean  __attribute__((export_name("TS_DirectionalChannelInfo_get_enabled"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
32032         LDKDirectionalChannelInfo this_ptr_conv;
32033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32034         this_ptr_conv.is_owned = false;
32035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32036         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
32037         return ret_val;
32038 }
32039
32040 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_enabled"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
32041         LDKDirectionalChannelInfo this_ptr_conv;
32042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32043         this_ptr_conv.is_owned = false;
32044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32045         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
32046 }
32047
32048 int16_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_cltv_expiry_delta"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
32049         LDKDirectionalChannelInfo this_ptr_conv;
32050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32051         this_ptr_conv.is_owned = false;
32052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32053         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
32054         return ret_val;
32055 }
32056
32057 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_cltv_expiry_delta"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
32058         LDKDirectionalChannelInfo this_ptr_conv;
32059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32060         this_ptr_conv.is_owned = false;
32061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32062         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
32063 }
32064
32065 int64_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_htlc_minimum_msat"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
32066         LDKDirectionalChannelInfo this_ptr_conv;
32067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32068         this_ptr_conv.is_owned = false;
32069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32070         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
32071         return ret_val;
32072 }
32073
32074 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_htlc_minimum_msat"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
32075         LDKDirectionalChannelInfo this_ptr_conv;
32076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32077         this_ptr_conv.is_owned = false;
32078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32079         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
32080 }
32081
32082 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_htlc_maximum_msat"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
32083         LDKDirectionalChannelInfo this_ptr_conv;
32084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32085         this_ptr_conv.is_owned = false;
32086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32087         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32088         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
32089         uintptr_t ret_ref = (uintptr_t)ret_copy;
32090         return ret_ref;
32091 }
32092
32093 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_htlc_maximum_msat"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
32094         LDKDirectionalChannelInfo this_ptr_conv;
32095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32096         this_ptr_conv.is_owned = false;
32097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32098         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32099         CHECK_ACCESS(val_ptr);
32100         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32101         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
32102         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
32103 }
32104
32105 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_fees"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
32106         LDKDirectionalChannelInfo this_ptr_conv;
32107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32108         this_ptr_conv.is_owned = false;
32109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32110         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
32111         uintptr_t ret_ref = 0;
32112         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32113         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32115         ret_ref = (uintptr_t)ret_var.inner;
32116         if (ret_var.is_owned) {
32117                 ret_ref |= 1;
32118         }
32119         return ret_ref;
32120 }
32121
32122 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_fees"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
32123         LDKDirectionalChannelInfo this_ptr_conv;
32124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32125         this_ptr_conv.is_owned = false;
32126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32127         LDKRoutingFees val_conv;
32128         val_conv.inner = (void*)(val & (~1));
32129         val_conv.is_owned = (val & 1) || (val == 0);
32130         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32131         val_conv = RoutingFees_clone(&val_conv);
32132         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
32133 }
32134
32135 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_last_update_message"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
32136         LDKDirectionalChannelInfo this_ptr_conv;
32137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32138         this_ptr_conv.is_owned = false;
32139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32140         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
32141         uintptr_t ret_ref = 0;
32142         if ((uintptr_t)ret_var.inner > 4096) {
32143                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32144                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32146                 ret_ref = (uintptr_t)ret_var.inner;
32147                 if (ret_var.is_owned) {
32148                         ret_ref |= 1;
32149                 }
32150         }
32151         return ret_ref;
32152 }
32153
32154 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_last_update_message"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
32155         LDKDirectionalChannelInfo this_ptr_conv;
32156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32157         this_ptr_conv.is_owned = false;
32158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32159         LDKChannelUpdate val_conv;
32160         val_conv.inner = (void*)(val & (~1));
32161         val_conv.is_owned = (val & 1) || (val == 0);
32162         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32163         val_conv = ChannelUpdate_clone(&val_conv);
32164         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
32165 }
32166
32167 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_new"))) TS_DirectionalChannelInfo_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) {
32168         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
32169         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
32170         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
32171         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
32172         LDKRoutingFees fees_arg_conv;
32173         fees_arg_conv.inner = (void*)(fees_arg & (~1));
32174         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
32175         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
32176         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
32177         LDKChannelUpdate last_update_message_arg_conv;
32178         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
32179         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
32180         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
32181         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
32182         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_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);
32183         uintptr_t ret_ref = 0;
32184         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32185         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32187         ret_ref = (uintptr_t)ret_var.inner;
32188         if (ret_var.is_owned) {
32189                 ret_ref |= 1;
32190         }
32191         return ret_ref;
32192 }
32193
32194 static inline uintptr_t DirectionalChannelInfo_clone_ptr(LDKDirectionalChannelInfo *NONNULL_PTR arg) {
32195         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(arg);
32196 uintptr_t ret_ref = 0;
32197 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32198 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32199 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32200 ret_ref = (uintptr_t)ret_var.inner;
32201 if (ret_var.is_owned) {
32202         ret_ref |= 1;
32203 }
32204         return ret_ref;
32205 }
32206 intptr_t  __attribute__((export_name("TS_DirectionalChannelInfo_clone_ptr"))) TS_DirectionalChannelInfo_clone_ptr(uint32_t arg) {
32207         LDKDirectionalChannelInfo arg_conv;
32208         arg_conv.inner = (void*)(arg & (~1));
32209         arg_conv.is_owned = false;
32210         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32211         intptr_t ret_val = DirectionalChannelInfo_clone_ptr(&arg_conv);
32212         return ret_val;
32213 }
32214
32215 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_clone"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
32216         LDKDirectionalChannelInfo orig_conv;
32217         orig_conv.inner = (void*)(orig & (~1));
32218         orig_conv.is_owned = false;
32219         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32220         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
32221         uintptr_t ret_ref = 0;
32222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32225         ret_ref = (uintptr_t)ret_var.inner;
32226         if (ret_var.is_owned) {
32227                 ret_ref |= 1;
32228         }
32229         return ret_ref;
32230 }
32231
32232 int8_tArray  __attribute__((export_name("TS_DirectionalChannelInfo_write"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
32233         LDKDirectionalChannelInfo obj_conv;
32234         obj_conv.inner = (void*)(obj & (~1));
32235         obj_conv.is_owned = false;
32236         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32237         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
32238         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32239         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32240         CVec_u8Z_free(ret_var);
32241         return ret_arr;
32242 }
32243
32244 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_read"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
32245         LDKu8slice ser_ref;
32246         ser_ref.datalen = ser->arr_len;
32247         ser_ref.data = ser->elems /* XXX ser leaks */;
32248         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
32249         *ret_conv = DirectionalChannelInfo_read(ser_ref);
32250         return (uintptr_t)ret_conv;
32251 }
32252
32253 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
32254         LDKChannelInfo this_obj_conv;
32255         this_obj_conv.inner = (void*)(this_obj & (~1));
32256         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32258         ChannelInfo_free(this_obj_conv);
32259 }
32260
32261 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
32262         LDKChannelInfo this_ptr_conv;
32263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32264         this_ptr_conv.is_owned = false;
32265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32266         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
32267         uintptr_t ret_ref = 0;
32268         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32269         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32271         ret_ref = (uintptr_t)ret_var.inner;
32272         if (ret_var.is_owned) {
32273                 ret_ref |= 1;
32274         }
32275         return ret_ref;
32276 }
32277
32278 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
32279         LDKChannelInfo this_ptr_conv;
32280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32281         this_ptr_conv.is_owned = false;
32282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32283         LDKChannelFeatures val_conv;
32284         val_conv.inner = (void*)(val & (~1));
32285         val_conv.is_owned = (val & 1) || (val == 0);
32286         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32287         val_conv = ChannelFeatures_clone(&val_conv);
32288         ChannelInfo_set_features(&this_ptr_conv, val_conv);
32289 }
32290
32291 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
32292         LDKChannelInfo this_ptr_conv;
32293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32294         this_ptr_conv.is_owned = false;
32295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32296         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
32297         uintptr_t ret_ref = 0;
32298         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32299         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32301         ret_ref = (uintptr_t)ret_var.inner;
32302         if (ret_var.is_owned) {
32303                 ret_ref |= 1;
32304         }
32305         return ret_ref;
32306 }
32307
32308 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
32309         LDKChannelInfo this_ptr_conv;
32310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32311         this_ptr_conv.is_owned = false;
32312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32313         LDKNodeId val_conv;
32314         val_conv.inner = (void*)(val & (~1));
32315         val_conv.is_owned = (val & 1) || (val == 0);
32316         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32317         val_conv = NodeId_clone(&val_conv);
32318         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
32319 }
32320
32321 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
32322         LDKChannelInfo this_ptr_conv;
32323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32324         this_ptr_conv.is_owned = false;
32325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32326         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
32327         uintptr_t ret_ref = 0;
32328         if ((uintptr_t)ret_var.inner > 4096) {
32329                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32330                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32332                 ret_ref = (uintptr_t)ret_var.inner;
32333                 if (ret_var.is_owned) {
32334                         ret_ref |= 1;
32335                 }
32336         }
32337         return ret_ref;
32338 }
32339
32340 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
32341         LDKChannelInfo this_ptr_conv;
32342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32343         this_ptr_conv.is_owned = false;
32344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32345         LDKDirectionalChannelInfo val_conv;
32346         val_conv.inner = (void*)(val & (~1));
32347         val_conv.is_owned = (val & 1) || (val == 0);
32348         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32349         val_conv = DirectionalChannelInfo_clone(&val_conv);
32350         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
32351 }
32352
32353 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
32354         LDKChannelInfo this_ptr_conv;
32355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32356         this_ptr_conv.is_owned = false;
32357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32358         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
32359         uintptr_t ret_ref = 0;
32360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32363         ret_ref = (uintptr_t)ret_var.inner;
32364         if (ret_var.is_owned) {
32365                 ret_ref |= 1;
32366         }
32367         return ret_ref;
32368 }
32369
32370 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
32371         LDKChannelInfo this_ptr_conv;
32372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32373         this_ptr_conv.is_owned = false;
32374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32375         LDKNodeId val_conv;
32376         val_conv.inner = (void*)(val & (~1));
32377         val_conv.is_owned = (val & 1) || (val == 0);
32378         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32379         val_conv = NodeId_clone(&val_conv);
32380         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
32381 }
32382
32383 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
32384         LDKChannelInfo this_ptr_conv;
32385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32386         this_ptr_conv.is_owned = false;
32387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32388         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
32389         uintptr_t ret_ref = 0;
32390         if ((uintptr_t)ret_var.inner > 4096) {
32391                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32392                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32394                 ret_ref = (uintptr_t)ret_var.inner;
32395                 if (ret_var.is_owned) {
32396                         ret_ref |= 1;
32397                 }
32398         }
32399         return ret_ref;
32400 }
32401
32402 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
32403         LDKChannelInfo this_ptr_conv;
32404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32405         this_ptr_conv.is_owned = false;
32406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32407         LDKDirectionalChannelInfo val_conv;
32408         val_conv.inner = (void*)(val & (~1));
32409         val_conv.is_owned = (val & 1) || (val == 0);
32410         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32411         val_conv = DirectionalChannelInfo_clone(&val_conv);
32412         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
32413 }
32414
32415 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
32416         LDKChannelInfo this_ptr_conv;
32417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32418         this_ptr_conv.is_owned = false;
32419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32420         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32421         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
32422         uintptr_t ret_ref = (uintptr_t)ret_copy;
32423         return ret_ref;
32424 }
32425
32426 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
32427         LDKChannelInfo this_ptr_conv;
32428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32429         this_ptr_conv.is_owned = false;
32430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32431         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32432         CHECK_ACCESS(val_ptr);
32433         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32434         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
32435         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
32436 }
32437
32438 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
32439         LDKChannelInfo this_ptr_conv;
32440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32441         this_ptr_conv.is_owned = false;
32442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32443         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
32444         uintptr_t ret_ref = 0;
32445         if ((uintptr_t)ret_var.inner > 4096) {
32446                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32447                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32449                 ret_ref = (uintptr_t)ret_var.inner;
32450                 if (ret_var.is_owned) {
32451                         ret_ref |= 1;
32452                 }
32453         }
32454         return ret_ref;
32455 }
32456
32457 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
32458         LDKChannelInfo this_ptr_conv;
32459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32460         this_ptr_conv.is_owned = false;
32461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32462         LDKChannelAnnouncement val_conv;
32463         val_conv.inner = (void*)(val & (~1));
32464         val_conv.is_owned = (val & 1) || (val == 0);
32465         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32466         val_conv = ChannelAnnouncement_clone(&val_conv);
32467         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
32468 }
32469
32470 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
32471         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
32472 uintptr_t ret_ref = 0;
32473 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32474 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32475 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32476 ret_ref = (uintptr_t)ret_var.inner;
32477 if (ret_var.is_owned) {
32478         ret_ref |= 1;
32479 }
32480         return ret_ref;
32481 }
32482 intptr_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
32483         LDKChannelInfo arg_conv;
32484         arg_conv.inner = (void*)(arg & (~1));
32485         arg_conv.is_owned = false;
32486         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32487         intptr_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
32488         return ret_val;
32489 }
32490
32491 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
32492         LDKChannelInfo orig_conv;
32493         orig_conv.inner = (void*)(orig & (~1));
32494         orig_conv.is_owned = false;
32495         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32496         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
32497         uintptr_t ret_ref = 0;
32498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32501         ret_ref = (uintptr_t)ret_var.inner;
32502         if (ret_var.is_owned) {
32503                 ret_ref |= 1;
32504         }
32505         return ret_ref;
32506 }
32507
32508 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
32509         LDKChannelInfo obj_conv;
32510         obj_conv.inner = (void*)(obj & (~1));
32511         obj_conv.is_owned = false;
32512         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32513         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
32514         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32515         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32516         CVec_u8Z_free(ret_var);
32517         return ret_arr;
32518 }
32519
32520 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
32521         LDKu8slice ser_ref;
32522         ser_ref.datalen = ser->arr_len;
32523         ser_ref.data = ser->elems /* XXX ser leaks */;
32524         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
32525         *ret_conv = ChannelInfo_read(ser_ref);
32526         return (uintptr_t)ret_conv;
32527 }
32528
32529 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
32530         LDKRoutingFees this_obj_conv;
32531         this_obj_conv.inner = (void*)(this_obj & (~1));
32532         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32534         RoutingFees_free(this_obj_conv);
32535 }
32536
32537 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
32538         LDKRoutingFees this_ptr_conv;
32539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32540         this_ptr_conv.is_owned = false;
32541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32542         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
32543         return ret_val;
32544 }
32545
32546 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
32547         LDKRoutingFees this_ptr_conv;
32548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32549         this_ptr_conv.is_owned = false;
32550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32551         RoutingFees_set_base_msat(&this_ptr_conv, val);
32552 }
32553
32554 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
32555         LDKRoutingFees this_ptr_conv;
32556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32557         this_ptr_conv.is_owned = false;
32558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32559         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
32560         return ret_val;
32561 }
32562
32563 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
32564         LDKRoutingFees this_ptr_conv;
32565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32566         this_ptr_conv.is_owned = false;
32567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32568         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
32569 }
32570
32571 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
32572         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
32573         uintptr_t ret_ref = 0;
32574         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32575         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32577         ret_ref = (uintptr_t)ret_var.inner;
32578         if (ret_var.is_owned) {
32579                 ret_ref |= 1;
32580         }
32581         return ret_ref;
32582 }
32583
32584 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
32585         LDKRoutingFees a_conv;
32586         a_conv.inner = (void*)(a & (~1));
32587         a_conv.is_owned = false;
32588         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32589         LDKRoutingFees b_conv;
32590         b_conv.inner = (void*)(b & (~1));
32591         b_conv.is_owned = false;
32592         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32593         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
32594         return ret_val;
32595 }
32596
32597 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
32598         LDKRoutingFees ret_var = RoutingFees_clone(arg);
32599 uintptr_t ret_ref = 0;
32600 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32601 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32602 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32603 ret_ref = (uintptr_t)ret_var.inner;
32604 if (ret_var.is_owned) {
32605         ret_ref |= 1;
32606 }
32607         return ret_ref;
32608 }
32609 intptr_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
32610         LDKRoutingFees arg_conv;
32611         arg_conv.inner = (void*)(arg & (~1));
32612         arg_conv.is_owned = false;
32613         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32614         intptr_t ret_val = RoutingFees_clone_ptr(&arg_conv);
32615         return ret_val;
32616 }
32617
32618 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
32619         LDKRoutingFees orig_conv;
32620         orig_conv.inner = (void*)(orig & (~1));
32621         orig_conv.is_owned = false;
32622         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32623         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
32624         uintptr_t ret_ref = 0;
32625         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32626         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32628         ret_ref = (uintptr_t)ret_var.inner;
32629         if (ret_var.is_owned) {
32630                 ret_ref |= 1;
32631         }
32632         return ret_ref;
32633 }
32634
32635 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
32636         LDKRoutingFees o_conv;
32637         o_conv.inner = (void*)(o & (~1));
32638         o_conv.is_owned = false;
32639         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
32640         int64_t ret_val = RoutingFees_hash(&o_conv);
32641         return ret_val;
32642 }
32643
32644 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
32645         LDKRoutingFees obj_conv;
32646         obj_conv.inner = (void*)(obj & (~1));
32647         obj_conv.is_owned = false;
32648         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32649         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
32650         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32651         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32652         CVec_u8Z_free(ret_var);
32653         return ret_arr;
32654 }
32655
32656 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
32657         LDKu8slice ser_ref;
32658         ser_ref.datalen = ser->arr_len;
32659         ser_ref.data = ser->elems /* XXX ser leaks */;
32660         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
32661         *ret_conv = RoutingFees_read(ser_ref);
32662         return (uintptr_t)ret_conv;
32663 }
32664
32665 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
32666         LDKNodeAnnouncementInfo this_obj_conv;
32667         this_obj_conv.inner = (void*)(this_obj & (~1));
32668         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32670         NodeAnnouncementInfo_free(this_obj_conv);
32671 }
32672
32673 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
32674         LDKNodeAnnouncementInfo this_ptr_conv;
32675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32676         this_ptr_conv.is_owned = false;
32677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32678         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
32679         uintptr_t ret_ref = 0;
32680         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32681         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32683         ret_ref = (uintptr_t)ret_var.inner;
32684         if (ret_var.is_owned) {
32685                 ret_ref |= 1;
32686         }
32687         return ret_ref;
32688 }
32689
32690 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
32691         LDKNodeAnnouncementInfo this_ptr_conv;
32692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32693         this_ptr_conv.is_owned = false;
32694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32695         LDKNodeFeatures val_conv;
32696         val_conv.inner = (void*)(val & (~1));
32697         val_conv.is_owned = (val & 1) || (val == 0);
32698         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32699         val_conv = NodeFeatures_clone(&val_conv);
32700         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
32701 }
32702
32703 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
32704         LDKNodeAnnouncementInfo this_ptr_conv;
32705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32706         this_ptr_conv.is_owned = false;
32707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32708         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
32709         return ret_val;
32710 }
32711
32712 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
32713         LDKNodeAnnouncementInfo this_ptr_conv;
32714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32715         this_ptr_conv.is_owned = false;
32716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32717         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
32718 }
32719
32720 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
32721         LDKNodeAnnouncementInfo this_ptr_conv;
32722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32723         this_ptr_conv.is_owned = false;
32724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32725         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
32726         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
32727         return ret_arr;
32728 }
32729
32730 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
32731         LDKNodeAnnouncementInfo this_ptr_conv;
32732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32733         this_ptr_conv.is_owned = false;
32734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32735         LDKThreeBytes val_ref;
32736         CHECK(val->arr_len == 3);
32737         memcpy(val_ref.data, val->elems, 3); FREE(val);
32738         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
32739 }
32740
32741 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
32742         LDKNodeAnnouncementInfo this_ptr_conv;
32743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32744         this_ptr_conv.is_owned = false;
32745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32746         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32747         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
32748         return ret_arr;
32749 }
32750
32751 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
32752         LDKNodeAnnouncementInfo this_ptr_conv;
32753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32754         this_ptr_conv.is_owned = false;
32755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32756         LDKThirtyTwoBytes val_ref;
32757         CHECK(val->arr_len == 32);
32758         memcpy(val_ref.data, val->elems, 32); FREE(val);
32759         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
32760 }
32761
32762 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
32763         LDKNodeAnnouncementInfo this_ptr_conv;
32764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32765         this_ptr_conv.is_owned = false;
32766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32767         LDKCVec_NetAddressZ val_constr;
32768         val_constr.datalen = val->arr_len;
32769         if (val_constr.datalen > 0)
32770                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
32771         else
32772                 val_constr.data = NULL;
32773         uint32_t* val_vals = val->elems /* XXX val leaks */;
32774         for (size_t m = 0; m < val_constr.datalen; m++) {
32775                 uint32_t val_conv_12 = val_vals[m];
32776                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
32777                 CHECK_ACCESS(val_conv_12_ptr);
32778                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
32779                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
32780                 val_constr.data[m] = val_conv_12_conv;
32781         }
32782         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
32783 }
32784
32785 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
32786         LDKNodeAnnouncementInfo this_ptr_conv;
32787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32788         this_ptr_conv.is_owned = false;
32789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32790         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
32791         uintptr_t ret_ref = 0;
32792         if ((uintptr_t)ret_var.inner > 4096) {
32793                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32794                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32796                 ret_ref = (uintptr_t)ret_var.inner;
32797                 if (ret_var.is_owned) {
32798                         ret_ref |= 1;
32799                 }
32800         }
32801         return ret_ref;
32802 }
32803
32804 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
32805         LDKNodeAnnouncementInfo this_ptr_conv;
32806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32807         this_ptr_conv.is_owned = false;
32808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32809         LDKNodeAnnouncement val_conv;
32810         val_conv.inner = (void*)(val & (~1));
32811         val_conv.is_owned = (val & 1) || (val == 0);
32812         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32813         val_conv = NodeAnnouncement_clone(&val_conv);
32814         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
32815 }
32816
32817 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) {
32818         LDKNodeFeatures features_arg_conv;
32819         features_arg_conv.inner = (void*)(features_arg & (~1));
32820         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
32821         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
32822         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
32823         LDKThreeBytes rgb_arg_ref;
32824         CHECK(rgb_arg->arr_len == 3);
32825         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
32826         LDKThirtyTwoBytes alias_arg_ref;
32827         CHECK(alias_arg->arr_len == 32);
32828         memcpy(alias_arg_ref.data, alias_arg->elems, 32); FREE(alias_arg);
32829         LDKCVec_NetAddressZ addresses_arg_constr;
32830         addresses_arg_constr.datalen = addresses_arg->arr_len;
32831         if (addresses_arg_constr.datalen > 0)
32832                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
32833         else
32834                 addresses_arg_constr.data = NULL;
32835         uint32_t* addresses_arg_vals = addresses_arg->elems /* XXX addresses_arg leaks */;
32836         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
32837                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
32838                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
32839                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
32840                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
32841                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
32842         }
32843         LDKNodeAnnouncement announcement_message_arg_conv;
32844         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
32845         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
32846         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
32847         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
32848         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
32849         uintptr_t ret_ref = 0;
32850         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32851         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32853         ret_ref = (uintptr_t)ret_var.inner;
32854         if (ret_var.is_owned) {
32855                 ret_ref |= 1;
32856         }
32857         return ret_ref;
32858 }
32859
32860 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
32861         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
32862 uintptr_t ret_ref = 0;
32863 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32864 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32865 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32866 ret_ref = (uintptr_t)ret_var.inner;
32867 if (ret_var.is_owned) {
32868         ret_ref |= 1;
32869 }
32870         return ret_ref;
32871 }
32872 intptr_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
32873         LDKNodeAnnouncementInfo arg_conv;
32874         arg_conv.inner = (void*)(arg & (~1));
32875         arg_conv.is_owned = false;
32876         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32877         intptr_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
32878         return ret_val;
32879 }
32880
32881 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
32882         LDKNodeAnnouncementInfo orig_conv;
32883         orig_conv.inner = (void*)(orig & (~1));
32884         orig_conv.is_owned = false;
32885         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32886         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
32887         uintptr_t ret_ref = 0;
32888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32891         ret_ref = (uintptr_t)ret_var.inner;
32892         if (ret_var.is_owned) {
32893                 ret_ref |= 1;
32894         }
32895         return ret_ref;
32896 }
32897
32898 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
32899         LDKNodeAnnouncementInfo obj_conv;
32900         obj_conv.inner = (void*)(obj & (~1));
32901         obj_conv.is_owned = false;
32902         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32903         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
32904         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32905         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32906         CVec_u8Z_free(ret_var);
32907         return ret_arr;
32908 }
32909
32910 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
32911         LDKu8slice ser_ref;
32912         ser_ref.datalen = ser->arr_len;
32913         ser_ref.data = ser->elems /* XXX ser leaks */;
32914         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
32915         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
32916         return (uintptr_t)ret_conv;
32917 }
32918
32919 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
32920         LDKNodeInfo this_obj_conv;
32921         this_obj_conv.inner = (void*)(this_obj & (~1));
32922         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32924         NodeInfo_free(this_obj_conv);
32925 }
32926
32927 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
32928         LDKNodeInfo this_ptr_conv;
32929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32930         this_ptr_conv.is_owned = false;
32931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32932         LDKCVec_u64Z val_constr;
32933         val_constr.datalen = val->arr_len;
32934         if (val_constr.datalen > 0)
32935                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32936         else
32937                 val_constr.data = NULL;
32938         int64_t* val_vals = val->elems /* XXX val leaks */;
32939         for (size_t i = 0; i < val_constr.datalen; i++) {
32940                 int64_t val_conv_8 = val_vals[i];
32941                 val_constr.data[i] = val_conv_8;
32942         }
32943         NodeInfo_set_channels(&this_ptr_conv, val_constr);
32944 }
32945
32946 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
32947         LDKNodeInfo this_ptr_conv;
32948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32949         this_ptr_conv.is_owned = false;
32950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32951         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
32952         uintptr_t ret_ref = 0;
32953         if ((uintptr_t)ret_var.inner > 4096) {
32954                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32955                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32957                 ret_ref = (uintptr_t)ret_var.inner;
32958                 if (ret_var.is_owned) {
32959                         ret_ref |= 1;
32960                 }
32961         }
32962         return ret_ref;
32963 }
32964
32965 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) {
32966         LDKNodeInfo this_ptr_conv;
32967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32968         this_ptr_conv.is_owned = false;
32969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32970         LDKRoutingFees val_conv;
32971         val_conv.inner = (void*)(val & (~1));
32972         val_conv.is_owned = (val & 1) || (val == 0);
32973         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32974         val_conv = RoutingFees_clone(&val_conv);
32975         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
32976 }
32977
32978 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
32979         LDKNodeInfo this_ptr_conv;
32980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32981         this_ptr_conv.is_owned = false;
32982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32983         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
32984         uintptr_t ret_ref = 0;
32985         if ((uintptr_t)ret_var.inner > 4096) {
32986                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32987                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32988         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32989                 ret_ref = (uintptr_t)ret_var.inner;
32990                 if (ret_var.is_owned) {
32991                         ret_ref |= 1;
32992                 }
32993         }
32994         return ret_ref;
32995 }
32996
32997 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
32998         LDKNodeInfo this_ptr_conv;
32999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33000         this_ptr_conv.is_owned = false;
33001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33002         LDKNodeAnnouncementInfo val_conv;
33003         val_conv.inner = (void*)(val & (~1));
33004         val_conv.is_owned = (val & 1) || (val == 0);
33005         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33006         val_conv = NodeAnnouncementInfo_clone(&val_conv);
33007         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
33008 }
33009
33010 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) {
33011         LDKCVec_u64Z channels_arg_constr;
33012         channels_arg_constr.datalen = channels_arg->arr_len;
33013         if (channels_arg_constr.datalen > 0)
33014                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
33015         else
33016                 channels_arg_constr.data = NULL;
33017         int64_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
33018         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
33019                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
33020                 channels_arg_constr.data[i] = channels_arg_conv_8;
33021         }
33022         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
33023         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
33024         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
33025         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
33026         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
33027         LDKNodeAnnouncementInfo announcement_info_arg_conv;
33028         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
33029         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
33030         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
33031         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
33032         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
33033         uintptr_t ret_ref = 0;
33034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33037         ret_ref = (uintptr_t)ret_var.inner;
33038         if (ret_var.is_owned) {
33039                 ret_ref |= 1;
33040         }
33041         return ret_ref;
33042 }
33043
33044 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
33045         LDKNodeInfo ret_var = NodeInfo_clone(arg);
33046 uintptr_t ret_ref = 0;
33047 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33048 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33049 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33050 ret_ref = (uintptr_t)ret_var.inner;
33051 if (ret_var.is_owned) {
33052         ret_ref |= 1;
33053 }
33054         return ret_ref;
33055 }
33056 intptr_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
33057         LDKNodeInfo arg_conv;
33058         arg_conv.inner = (void*)(arg & (~1));
33059         arg_conv.is_owned = false;
33060         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33061         intptr_t ret_val = NodeInfo_clone_ptr(&arg_conv);
33062         return ret_val;
33063 }
33064
33065 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
33066         LDKNodeInfo orig_conv;
33067         orig_conv.inner = (void*)(orig & (~1));
33068         orig_conv.is_owned = false;
33069         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33070         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
33071         uintptr_t ret_ref = 0;
33072         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33073         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33075         ret_ref = (uintptr_t)ret_var.inner;
33076         if (ret_var.is_owned) {
33077                 ret_ref |= 1;
33078         }
33079         return ret_ref;
33080 }
33081
33082 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
33083         LDKNodeInfo obj_conv;
33084         obj_conv.inner = (void*)(obj & (~1));
33085         obj_conv.is_owned = false;
33086         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33087         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
33088         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33089         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33090         CVec_u8Z_free(ret_var);
33091         return ret_arr;
33092 }
33093
33094 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
33095         LDKu8slice ser_ref;
33096         ser_ref.datalen = ser->arr_len;
33097         ser_ref.data = ser->elems /* XXX ser leaks */;
33098         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
33099         *ret_conv = NodeInfo_read(ser_ref);
33100         return (uintptr_t)ret_conv;
33101 }
33102
33103 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
33104         LDKNetworkGraph obj_conv;
33105         obj_conv.inner = (void*)(obj & (~1));
33106         obj_conv.is_owned = false;
33107         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33108         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
33109         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33110         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33111         CVec_u8Z_free(ret_var);
33112         return ret_arr;
33113 }
33114
33115 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser) {
33116         LDKu8slice ser_ref;
33117         ser_ref.datalen = ser->arr_len;
33118         ser_ref.data = ser->elems /* XXX ser leaks */;
33119         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
33120         *ret_conv = NetworkGraph_read(ser_ref);
33121         return (uintptr_t)ret_conv;
33122 }
33123
33124 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
33125         LDKThirtyTwoBytes genesis_hash_ref;
33126         CHECK(genesis_hash->arr_len == 32);
33127         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
33128         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
33129         uintptr_t ret_ref = 0;
33130         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33131         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33133         ret_ref = (uintptr_t)ret_var.inner;
33134         if (ret_var.is_owned) {
33135                 ret_ref |= 1;
33136         }
33137         return ret_ref;
33138 }
33139
33140 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
33141         LDKNetworkGraph this_arg_conv;
33142         this_arg_conv.inner = (void*)(this_arg & (~1));
33143         this_arg_conv.is_owned = false;
33144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33145         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
33146         uintptr_t ret_ref = 0;
33147         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33148         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33150         ret_ref = (uintptr_t)ret_var.inner;
33151         if (ret_var.is_owned) {
33152                 ret_ref |= 1;
33153         }
33154         return ret_ref;
33155 }
33156
33157 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
33158         LDKNetworkGraph this_arg_conv;
33159         this_arg_conv.inner = (void*)(this_arg & (~1));
33160         this_arg_conv.is_owned = false;
33161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33162         LDKNodeAnnouncement msg_conv;
33163         msg_conv.inner = (void*)(msg & (~1));
33164         msg_conv.is_owned = false;
33165         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33166         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33167         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
33168         return (uintptr_t)ret_conv;
33169 }
33170
33171 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) {
33172         LDKNetworkGraph this_arg_conv;
33173         this_arg_conv.inner = (void*)(this_arg & (~1));
33174         this_arg_conv.is_owned = false;
33175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33176         LDKUnsignedNodeAnnouncement msg_conv;
33177         msg_conv.inner = (void*)(msg & (~1));
33178         msg_conv.is_owned = false;
33179         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33180         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33181         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
33182         return (uintptr_t)ret_conv;
33183 }
33184
33185 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) {
33186         LDKNetworkGraph this_arg_conv;
33187         this_arg_conv.inner = (void*)(this_arg & (~1));
33188         this_arg_conv.is_owned = false;
33189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33190         LDKChannelAnnouncement msg_conv;
33191         msg_conv.inner = (void*)(msg & (~1));
33192         msg_conv.is_owned = false;
33193         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33194         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
33195         CHECK_ACCESS(chain_access_ptr);
33196         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
33197         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
33198         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
33199                 // Manually implement clone for Java trait instances
33200         }
33201         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33202         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
33203         return (uintptr_t)ret_conv;
33204 }
33205
33206 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) {
33207         LDKNetworkGraph this_arg_conv;
33208         this_arg_conv.inner = (void*)(this_arg & (~1));
33209         this_arg_conv.is_owned = false;
33210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33211         LDKUnsignedChannelAnnouncement msg_conv;
33212         msg_conv.inner = (void*)(msg & (~1));
33213         msg_conv.is_owned = false;
33214         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33215         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
33216         CHECK_ACCESS(chain_access_ptr);
33217         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
33218         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
33219         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
33220                 // Manually implement clone for Java trait instances
33221         }
33222         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33223         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
33224         return (uintptr_t)ret_conv;
33225 }
33226
33227 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) {
33228         LDKNetworkGraph this_arg_conv;
33229         this_arg_conv.inner = (void*)(this_arg & (~1));
33230         this_arg_conv.is_owned = false;
33231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33232         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
33233 }
33234
33235 void  __attribute__((export_name("TS_NetworkGraph_fail_node"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
33236         LDKNetworkGraph this_arg_conv;
33237         this_arg_conv.inner = (void*)(this_arg & (~1));
33238         this_arg_conv.is_owned = false;
33239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33240         LDKPublicKey _node_id_ref;
33241         CHECK(_node_id->arr_len == 33);
33242         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
33243         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
33244 }
33245
33246 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) {
33247         LDKNetworkGraph this_arg_conv;
33248         this_arg_conv.inner = (void*)(this_arg & (~1));
33249         this_arg_conv.is_owned = false;
33250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33251         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
33252 }
33253
33254 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
33255         LDKNetworkGraph this_arg_conv;
33256         this_arg_conv.inner = (void*)(this_arg & (~1));
33257         this_arg_conv.is_owned = false;
33258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33259         LDKChannelUpdate msg_conv;
33260         msg_conv.inner = (void*)(msg & (~1));
33261         msg_conv.is_owned = false;
33262         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33263         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33264         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
33265         return (uintptr_t)ret_conv;
33266 }
33267
33268 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
33269         LDKNetworkGraph this_arg_conv;
33270         this_arg_conv.inner = (void*)(this_arg & (~1));
33271         this_arg_conv.is_owned = false;
33272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33273         LDKUnsignedChannelUpdate msg_conv;
33274         msg_conv.inner = (void*)(msg & (~1));
33275         msg_conv.is_owned = false;
33276         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33277         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33278         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
33279         return (uintptr_t)ret_conv;
33280 }
33281
33282 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
33283         LDKReadOnlyNetworkGraph this_arg_conv;
33284         this_arg_conv.inner = (void*)(this_arg & (~1));
33285         this_arg_conv.is_owned = false;
33286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33287         LDKPublicKey pubkey_ref;
33288         CHECK(pubkey->arr_len == 33);
33289         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
33290         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
33291         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
33292         uintptr_t ret_ref = (uintptr_t)ret_copy;
33293         return ret_ref;
33294 }
33295
33296 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
33297         LDKRouteHop this_obj_conv;
33298         this_obj_conv.inner = (void*)(this_obj & (~1));
33299         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33301         RouteHop_free(this_obj_conv);
33302 }
33303
33304 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
33305         LDKRouteHop this_ptr_conv;
33306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33307         this_ptr_conv.is_owned = false;
33308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33309         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33310         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
33311         return ret_arr;
33312 }
33313
33314 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
33315         LDKRouteHop this_ptr_conv;
33316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33317         this_ptr_conv.is_owned = false;
33318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33319         LDKPublicKey val_ref;
33320         CHECK(val->arr_len == 33);
33321         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33322         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
33323 }
33324
33325 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
33326         LDKRouteHop this_ptr_conv;
33327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33328         this_ptr_conv.is_owned = false;
33329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33330         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
33331         uintptr_t ret_ref = 0;
33332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33335         ret_ref = (uintptr_t)ret_var.inner;
33336         if (ret_var.is_owned) {
33337                 ret_ref |= 1;
33338         }
33339         return ret_ref;
33340 }
33341
33342 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
33343         LDKRouteHop this_ptr_conv;
33344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33345         this_ptr_conv.is_owned = false;
33346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33347         LDKNodeFeatures val_conv;
33348         val_conv.inner = (void*)(val & (~1));
33349         val_conv.is_owned = (val & 1) || (val == 0);
33350         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33351         val_conv = NodeFeatures_clone(&val_conv);
33352         RouteHop_set_node_features(&this_ptr_conv, val_conv);
33353 }
33354
33355 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
33356         LDKRouteHop this_ptr_conv;
33357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33358         this_ptr_conv.is_owned = false;
33359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33360         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
33361         return ret_val;
33362 }
33363
33364 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
33365         LDKRouteHop this_ptr_conv;
33366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33367         this_ptr_conv.is_owned = false;
33368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33369         RouteHop_set_short_channel_id(&this_ptr_conv, val);
33370 }
33371
33372 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
33373         LDKRouteHop this_ptr_conv;
33374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33375         this_ptr_conv.is_owned = false;
33376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33377         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
33378         uintptr_t ret_ref = 0;
33379         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33380         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33381         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33382         ret_ref = (uintptr_t)ret_var.inner;
33383         if (ret_var.is_owned) {
33384                 ret_ref |= 1;
33385         }
33386         return ret_ref;
33387 }
33388
33389 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
33390         LDKRouteHop this_ptr_conv;
33391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33392         this_ptr_conv.is_owned = false;
33393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33394         LDKChannelFeatures val_conv;
33395         val_conv.inner = (void*)(val & (~1));
33396         val_conv.is_owned = (val & 1) || (val == 0);
33397         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33398         val_conv = ChannelFeatures_clone(&val_conv);
33399         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
33400 }
33401
33402 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
33403         LDKRouteHop this_ptr_conv;
33404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33405         this_ptr_conv.is_owned = false;
33406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33407         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
33408         return ret_val;
33409 }
33410
33411 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
33412         LDKRouteHop this_ptr_conv;
33413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33414         this_ptr_conv.is_owned = false;
33415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33416         RouteHop_set_fee_msat(&this_ptr_conv, val);
33417 }
33418
33419 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
33420         LDKRouteHop this_ptr_conv;
33421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33422         this_ptr_conv.is_owned = false;
33423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33424         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
33425         return ret_val;
33426 }
33427
33428 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
33429         LDKRouteHop this_ptr_conv;
33430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33431         this_ptr_conv.is_owned = false;
33432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33433         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
33434 }
33435
33436 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) {
33437         LDKPublicKey pubkey_arg_ref;
33438         CHECK(pubkey_arg->arr_len == 33);
33439         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
33440         LDKNodeFeatures node_features_arg_conv;
33441         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
33442         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
33443         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
33444         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
33445         LDKChannelFeatures channel_features_arg_conv;
33446         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
33447         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
33448         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
33449         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
33450         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);
33451         uintptr_t ret_ref = 0;
33452         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33453         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33455         ret_ref = (uintptr_t)ret_var.inner;
33456         if (ret_var.is_owned) {
33457                 ret_ref |= 1;
33458         }
33459         return ret_ref;
33460 }
33461
33462 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
33463         LDKRouteHop ret_var = RouteHop_clone(arg);
33464 uintptr_t ret_ref = 0;
33465 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33466 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33467 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33468 ret_ref = (uintptr_t)ret_var.inner;
33469 if (ret_var.is_owned) {
33470         ret_ref |= 1;
33471 }
33472         return ret_ref;
33473 }
33474 intptr_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
33475         LDKRouteHop arg_conv;
33476         arg_conv.inner = (void*)(arg & (~1));
33477         arg_conv.is_owned = false;
33478         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33479         intptr_t ret_val = RouteHop_clone_ptr(&arg_conv);
33480         return ret_val;
33481 }
33482
33483 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
33484         LDKRouteHop orig_conv;
33485         orig_conv.inner = (void*)(orig & (~1));
33486         orig_conv.is_owned = false;
33487         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33488         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
33489         uintptr_t ret_ref = 0;
33490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33493         ret_ref = (uintptr_t)ret_var.inner;
33494         if (ret_var.is_owned) {
33495                 ret_ref |= 1;
33496         }
33497         return ret_ref;
33498 }
33499
33500 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
33501         LDKRouteHop o_conv;
33502         o_conv.inner = (void*)(o & (~1));
33503         o_conv.is_owned = false;
33504         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33505         int64_t ret_val = RouteHop_hash(&o_conv);
33506         return ret_val;
33507 }
33508
33509 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
33510         LDKRouteHop a_conv;
33511         a_conv.inner = (void*)(a & (~1));
33512         a_conv.is_owned = false;
33513         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33514         LDKRouteHop b_conv;
33515         b_conv.inner = (void*)(b & (~1));
33516         b_conv.is_owned = false;
33517         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33518         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
33519         return ret_val;
33520 }
33521
33522 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
33523         LDKRouteHop obj_conv;
33524         obj_conv.inner = (void*)(obj & (~1));
33525         obj_conv.is_owned = false;
33526         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33527         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
33528         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33529         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33530         CVec_u8Z_free(ret_var);
33531         return ret_arr;
33532 }
33533
33534 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
33535         LDKu8slice ser_ref;
33536         ser_ref.datalen = ser->arr_len;
33537         ser_ref.data = ser->elems /* XXX ser leaks */;
33538         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
33539         *ret_conv = RouteHop_read(ser_ref);
33540         return (uintptr_t)ret_conv;
33541 }
33542
33543 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
33544         LDKRoute this_obj_conv;
33545         this_obj_conv.inner = (void*)(this_obj & (~1));
33546         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33548         Route_free(this_obj_conv);
33549 }
33550
33551 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
33552         LDKRoute this_ptr_conv;
33553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33554         this_ptr_conv.is_owned = false;
33555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33556         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
33557         ptrArray ret_arr = NULL;
33558         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
33559         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
33560         for (size_t m = 0; m < ret_var.datalen; m++) {
33561                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
33562                 uint32_tArray ret_conv_12_arr = NULL;
33563                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
33564                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
33565                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
33566                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
33567                         uintptr_t ret_conv_12_conv_10_ref = 0;
33568                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33569                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33570                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
33571                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
33572                         if (ret_conv_12_conv_10_var.is_owned) {
33573                                 ret_conv_12_conv_10_ref |= 1;
33574                         }
33575                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
33576                 }
33577                 
33578                 FREE(ret_conv_12_var.data);
33579                 ret_arr_ptr[m] = ret_conv_12_arr;
33580         }
33581         
33582         FREE(ret_var.data);
33583         return ret_arr;
33584 }
33585
33586 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
33587         LDKRoute this_ptr_conv;
33588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33589         this_ptr_conv.is_owned = false;
33590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33591         LDKCVec_CVec_RouteHopZZ val_constr;
33592         val_constr.datalen = val->arr_len;
33593         if (val_constr.datalen > 0)
33594                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
33595         else
33596                 val_constr.data = NULL;
33597         uint32_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
33598         for (size_t m = 0; m < val_constr.datalen; m++) {
33599                 uint32_tArray val_conv_12 = val_vals[m];
33600                 LDKCVec_RouteHopZ val_conv_12_constr;
33601                 val_conv_12_constr.datalen = val_conv_12->arr_len;
33602                 if (val_conv_12_constr.datalen > 0)
33603                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
33604                 else
33605                         val_conv_12_constr.data = NULL;
33606                 uint32_t* val_conv_12_vals = val_conv_12->elems /* XXX val_conv_12 leaks */;
33607                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
33608                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
33609                         LDKRouteHop val_conv_12_conv_10_conv;
33610                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
33611                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
33612                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
33613                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
33614                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
33615                 }
33616                 val_constr.data[m] = val_conv_12_constr;
33617         }
33618         Route_set_paths(&this_ptr_conv, val_constr);
33619 }
33620
33621 uint32_t  __attribute__((export_name("TS_Route_get_payee"))) TS_Route_get_payee(uint32_t this_ptr) {
33622         LDKRoute this_ptr_conv;
33623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33624         this_ptr_conv.is_owned = false;
33625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33626         LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
33627         uintptr_t ret_ref = 0;
33628         if ((uintptr_t)ret_var.inner > 4096) {
33629                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33630                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33632                 ret_ref = (uintptr_t)ret_var.inner;
33633                 if (ret_var.is_owned) {
33634                         ret_ref |= 1;
33635                 }
33636         }
33637         return ret_ref;
33638 }
33639
33640 void  __attribute__((export_name("TS_Route_set_payee"))) TS_Route_set_payee(uint32_t this_ptr, uint32_t val) {
33641         LDKRoute this_ptr_conv;
33642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33643         this_ptr_conv.is_owned = false;
33644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33645         LDKPayee val_conv;
33646         val_conv.inner = (void*)(val & (~1));
33647         val_conv.is_owned = (val & 1) || (val == 0);
33648         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33649         val_conv = Payee_clone(&val_conv);
33650         Route_set_payee(&this_ptr_conv, val_conv);
33651 }
33652
33653 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payee_arg) {
33654         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
33655         paths_arg_constr.datalen = paths_arg->arr_len;
33656         if (paths_arg_constr.datalen > 0)
33657                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
33658         else
33659                 paths_arg_constr.data = NULL;
33660         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems /* XXX paths_arg leaks */;
33661         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
33662                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
33663                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
33664                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
33665                 if (paths_arg_conv_12_constr.datalen > 0)
33666                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
33667                 else
33668                         paths_arg_conv_12_constr.data = NULL;
33669                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems /* XXX paths_arg_conv_12 leaks */;
33670                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
33671                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
33672                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
33673                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
33674                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
33675                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
33676                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
33677                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
33678                 }
33679                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
33680         }
33681         LDKPayee payee_arg_conv;
33682         payee_arg_conv.inner = (void*)(payee_arg & (~1));
33683         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
33684         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
33685         payee_arg_conv = Payee_clone(&payee_arg_conv);
33686         LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
33687         uintptr_t ret_ref = 0;
33688         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33689         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33691         ret_ref = (uintptr_t)ret_var.inner;
33692         if (ret_var.is_owned) {
33693                 ret_ref |= 1;
33694         }
33695         return ret_ref;
33696 }
33697
33698 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
33699         LDKRoute ret_var = Route_clone(arg);
33700 uintptr_t ret_ref = 0;
33701 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33702 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33703 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33704 ret_ref = (uintptr_t)ret_var.inner;
33705 if (ret_var.is_owned) {
33706         ret_ref |= 1;
33707 }
33708         return ret_ref;
33709 }
33710 intptr_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
33711         LDKRoute arg_conv;
33712         arg_conv.inner = (void*)(arg & (~1));
33713         arg_conv.is_owned = false;
33714         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33715         intptr_t ret_val = Route_clone_ptr(&arg_conv);
33716         return ret_val;
33717 }
33718
33719 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
33720         LDKRoute orig_conv;
33721         orig_conv.inner = (void*)(orig & (~1));
33722         orig_conv.is_owned = false;
33723         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33724         LDKRoute ret_var = Route_clone(&orig_conv);
33725         uintptr_t ret_ref = 0;
33726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33729         ret_ref = (uintptr_t)ret_var.inner;
33730         if (ret_var.is_owned) {
33731                 ret_ref |= 1;
33732         }
33733         return ret_ref;
33734 }
33735
33736 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
33737         LDKRoute o_conv;
33738         o_conv.inner = (void*)(o & (~1));
33739         o_conv.is_owned = false;
33740         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33741         int64_t ret_val = Route_hash(&o_conv);
33742         return ret_val;
33743 }
33744
33745 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
33746         LDKRoute a_conv;
33747         a_conv.inner = (void*)(a & (~1));
33748         a_conv.is_owned = false;
33749         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33750         LDKRoute b_conv;
33751         b_conv.inner = (void*)(b & (~1));
33752         b_conv.is_owned = false;
33753         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33754         jboolean ret_val = Route_eq(&a_conv, &b_conv);
33755         return ret_val;
33756 }
33757
33758 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
33759         LDKRoute this_arg_conv;
33760         this_arg_conv.inner = (void*)(this_arg & (~1));
33761         this_arg_conv.is_owned = false;
33762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33763         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
33764         return ret_val;
33765 }
33766
33767 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
33768         LDKRoute this_arg_conv;
33769         this_arg_conv.inner = (void*)(this_arg & (~1));
33770         this_arg_conv.is_owned = false;
33771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33772         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
33773         return ret_val;
33774 }
33775
33776 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
33777         LDKRoute obj_conv;
33778         obj_conv.inner = (void*)(obj & (~1));
33779         obj_conv.is_owned = false;
33780         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33781         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
33782         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33783         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33784         CVec_u8Z_free(ret_var);
33785         return ret_arr;
33786 }
33787
33788 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
33789         LDKu8slice ser_ref;
33790         ser_ref.datalen = ser->arr_len;
33791         ser_ref.data = ser->elems /* XXX ser leaks */;
33792         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
33793         *ret_conv = Route_read(ser_ref);
33794         return (uintptr_t)ret_conv;
33795 }
33796
33797 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
33798         LDKRouteParameters this_obj_conv;
33799         this_obj_conv.inner = (void*)(this_obj & (~1));
33800         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33802         RouteParameters_free(this_obj_conv);
33803 }
33804
33805 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payee"))) TS_RouteParameters_get_payee(uint32_t this_ptr) {
33806         LDKRouteParameters 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         LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
33811         uintptr_t ret_ref = 0;
33812         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33813         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33815         ret_ref = (uintptr_t)ret_var.inner;
33816         if (ret_var.is_owned) {
33817                 ret_ref |= 1;
33818         }
33819         return ret_ref;
33820 }
33821
33822 void  __attribute__((export_name("TS_RouteParameters_set_payee"))) TS_RouteParameters_set_payee(uint32_t this_ptr, uint32_t val) {
33823         LDKRouteParameters this_ptr_conv;
33824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33825         this_ptr_conv.is_owned = false;
33826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33827         LDKPayee val_conv;
33828         val_conv.inner = (void*)(val & (~1));
33829         val_conv.is_owned = (val & 1) || (val == 0);
33830         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33831         val_conv = Payee_clone(&val_conv);
33832         RouteParameters_set_payee(&this_ptr_conv, val_conv);
33833 }
33834
33835 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
33836         LDKRouteParameters this_ptr_conv;
33837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33838         this_ptr_conv.is_owned = false;
33839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33840         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
33841         return ret_val;
33842 }
33843
33844 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
33845         LDKRouteParameters this_ptr_conv;
33846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33847         this_ptr_conv.is_owned = false;
33848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33849         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
33850 }
33851
33852 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
33853         LDKRouteParameters this_ptr_conv;
33854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33855         this_ptr_conv.is_owned = false;
33856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33857         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
33858         return ret_val;
33859 }
33860
33861 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) {
33862         LDKRouteParameters this_ptr_conv;
33863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33864         this_ptr_conv.is_owned = false;
33865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33866         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
33867 }
33868
33869 uint32_t  __attribute__((export_name("TS_RouteParameters_new"))) TS_RouteParameters_new(uint32_t payee_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
33870         LDKPayee payee_arg_conv;
33871         payee_arg_conv.inner = (void*)(payee_arg & (~1));
33872         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
33873         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
33874         payee_arg_conv = Payee_clone(&payee_arg_conv);
33875         LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
33876         uintptr_t ret_ref = 0;
33877         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33878         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33879         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33880         ret_ref = (uintptr_t)ret_var.inner;
33881         if (ret_var.is_owned) {
33882                 ret_ref |= 1;
33883         }
33884         return ret_ref;
33885 }
33886
33887 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
33888         LDKRouteParameters ret_var = RouteParameters_clone(arg);
33889 uintptr_t ret_ref = 0;
33890 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33891 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33892 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33893 ret_ref = (uintptr_t)ret_var.inner;
33894 if (ret_var.is_owned) {
33895         ret_ref |= 1;
33896 }
33897         return ret_ref;
33898 }
33899 intptr_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
33900         LDKRouteParameters arg_conv;
33901         arg_conv.inner = (void*)(arg & (~1));
33902         arg_conv.is_owned = false;
33903         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33904         intptr_t ret_val = RouteParameters_clone_ptr(&arg_conv);
33905         return ret_val;
33906 }
33907
33908 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
33909         LDKRouteParameters orig_conv;
33910         orig_conv.inner = (void*)(orig & (~1));
33911         orig_conv.is_owned = false;
33912         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33913         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
33914         uintptr_t ret_ref = 0;
33915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33918         ret_ref = (uintptr_t)ret_var.inner;
33919         if (ret_var.is_owned) {
33920                 ret_ref |= 1;
33921         }
33922         return ret_ref;
33923 }
33924
33925 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
33926         LDKRouteParameters obj_conv;
33927         obj_conv.inner = (void*)(obj & (~1));
33928         obj_conv.is_owned = false;
33929         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33930         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
33931         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33932         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33933         CVec_u8Z_free(ret_var);
33934         return ret_arr;
33935 }
33936
33937 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
33938         LDKu8slice ser_ref;
33939         ser_ref.datalen = ser->arr_len;
33940         ser_ref.data = ser->elems /* XXX ser leaks */;
33941         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
33942         *ret_conv = RouteParameters_read(ser_ref);
33943         return (uintptr_t)ret_conv;
33944 }
33945
33946 void  __attribute__((export_name("TS_Payee_free"))) TS_Payee_free(uint32_t this_obj) {
33947         LDKPayee this_obj_conv;
33948         this_obj_conv.inner = (void*)(this_obj & (~1));
33949         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33951         Payee_free(this_obj_conv);
33952 }
33953
33954 int8_tArray  __attribute__((export_name("TS_Payee_get_pubkey"))) TS_Payee_get_pubkey(uint32_t this_ptr) {
33955         LDKPayee this_ptr_conv;
33956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33957         this_ptr_conv.is_owned = false;
33958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33959         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33960         memcpy(ret_arr->elems, Payee_get_pubkey(&this_ptr_conv).compressed_form, 33);
33961         return ret_arr;
33962 }
33963
33964 void  __attribute__((export_name("TS_Payee_set_pubkey"))) TS_Payee_set_pubkey(uint32_t this_ptr, int8_tArray val) {
33965         LDKPayee this_ptr_conv;
33966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33967         this_ptr_conv.is_owned = false;
33968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33969         LDKPublicKey val_ref;
33970         CHECK(val->arr_len == 33);
33971         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33972         Payee_set_pubkey(&this_ptr_conv, val_ref);
33973 }
33974
33975 uint32_t  __attribute__((export_name("TS_Payee_get_features"))) TS_Payee_get_features(uint32_t this_ptr) {
33976         LDKPayee this_ptr_conv;
33977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33978         this_ptr_conv.is_owned = false;
33979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33980         LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
33981         uintptr_t ret_ref = 0;
33982         if ((uintptr_t)ret_var.inner > 4096) {
33983                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33984                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33986                 ret_ref = (uintptr_t)ret_var.inner;
33987                 if (ret_var.is_owned) {
33988                         ret_ref |= 1;
33989                 }
33990         }
33991         return ret_ref;
33992 }
33993
33994 void  __attribute__((export_name("TS_Payee_set_features"))) TS_Payee_set_features(uint32_t this_ptr, uint32_t val) {
33995         LDKPayee this_ptr_conv;
33996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33997         this_ptr_conv.is_owned = false;
33998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33999         LDKInvoiceFeatures val_conv;
34000         val_conv.inner = (void*)(val & (~1));
34001         val_conv.is_owned = (val & 1) || (val == 0);
34002         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34003         val_conv = InvoiceFeatures_clone(&val_conv);
34004         Payee_set_features(&this_ptr_conv, val_conv);
34005 }
34006
34007 uint32_tArray  __attribute__((export_name("TS_Payee_get_route_hints"))) TS_Payee_get_route_hints(uint32_t this_ptr) {
34008         LDKPayee this_ptr_conv;
34009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34010         this_ptr_conv.is_owned = false;
34011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34012         LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
34013         uint32_tArray ret_arr = NULL;
34014         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
34015         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
34016         for (size_t l = 0; l < ret_var.datalen; l++) {
34017                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
34018                 uintptr_t ret_conv_11_ref = 0;
34019                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34020                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34021                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
34022                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
34023                 if (ret_conv_11_var.is_owned) {
34024                         ret_conv_11_ref |= 1;
34025                 }
34026                 ret_arr_ptr[l] = ret_conv_11_ref;
34027         }
34028         
34029         FREE(ret_var.data);
34030         return ret_arr;
34031 }
34032
34033 void  __attribute__((export_name("TS_Payee_set_route_hints"))) TS_Payee_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
34034         LDKPayee this_ptr_conv;
34035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34036         this_ptr_conv.is_owned = false;
34037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34038         LDKCVec_RouteHintZ val_constr;
34039         val_constr.datalen = val->arr_len;
34040         if (val_constr.datalen > 0)
34041                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
34042         else
34043                 val_constr.data = NULL;
34044         uint32_t* val_vals = val->elems /* XXX val leaks */;
34045         for (size_t l = 0; l < val_constr.datalen; l++) {
34046                 uint32_t val_conv_11 = val_vals[l];
34047                 LDKRouteHint val_conv_11_conv;
34048                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
34049                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
34050                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
34051                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
34052                 val_constr.data[l] = val_conv_11_conv;
34053         }
34054         Payee_set_route_hints(&this_ptr_conv, val_constr);
34055 }
34056
34057 uint32_t  __attribute__((export_name("TS_Payee_get_expiry_time"))) TS_Payee_get_expiry_time(uint32_t this_ptr) {
34058         LDKPayee this_ptr_conv;
34059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34060         this_ptr_conv.is_owned = false;
34061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34062         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34063         *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
34064         uintptr_t ret_ref = (uintptr_t)ret_copy;
34065         return ret_ref;
34066 }
34067
34068 void  __attribute__((export_name("TS_Payee_set_expiry_time"))) TS_Payee_set_expiry_time(uint32_t this_ptr, uint32_t val) {
34069         LDKPayee this_ptr_conv;
34070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34071         this_ptr_conv.is_owned = false;
34072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34073         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34074         CHECK_ACCESS(val_ptr);
34075         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34076         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
34077         Payee_set_expiry_time(&this_ptr_conv, val_conv);
34078 }
34079
34080 uint32_t  __attribute__((export_name("TS_Payee_new"))) TS_Payee_new(int8_tArray pubkey_arg, uint32_t features_arg, uint32_tArray route_hints_arg, uint32_t expiry_time_arg) {
34081         LDKPublicKey pubkey_arg_ref;
34082         CHECK(pubkey_arg->arr_len == 33);
34083         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
34084         LDKInvoiceFeatures features_arg_conv;
34085         features_arg_conv.inner = (void*)(features_arg & (~1));
34086         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
34087         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
34088         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
34089         LDKCVec_RouteHintZ route_hints_arg_constr;
34090         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
34091         if (route_hints_arg_constr.datalen > 0)
34092                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
34093         else
34094                 route_hints_arg_constr.data = NULL;
34095         uint32_t* route_hints_arg_vals = route_hints_arg->elems /* XXX route_hints_arg leaks */;
34096         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
34097                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
34098                 LDKRouteHint route_hints_arg_conv_11_conv;
34099                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
34100                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
34101                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
34102                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
34103                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
34104         }
34105         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
34106         CHECK_ACCESS(expiry_time_arg_ptr);
34107         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
34108         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
34109         LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
34110         uintptr_t ret_ref = 0;
34111         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34112         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34114         ret_ref = (uintptr_t)ret_var.inner;
34115         if (ret_var.is_owned) {
34116                 ret_ref |= 1;
34117         }
34118         return ret_ref;
34119 }
34120
34121 static inline uintptr_t Payee_clone_ptr(LDKPayee *NONNULL_PTR arg) {
34122         LDKPayee ret_var = Payee_clone(arg);
34123 uintptr_t ret_ref = 0;
34124 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34125 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34126 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34127 ret_ref = (uintptr_t)ret_var.inner;
34128 if (ret_var.is_owned) {
34129         ret_ref |= 1;
34130 }
34131         return ret_ref;
34132 }
34133 intptr_t  __attribute__((export_name("TS_Payee_clone_ptr"))) TS_Payee_clone_ptr(uint32_t arg) {
34134         LDKPayee arg_conv;
34135         arg_conv.inner = (void*)(arg & (~1));
34136         arg_conv.is_owned = false;
34137         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34138         intptr_t ret_val = Payee_clone_ptr(&arg_conv);
34139         return ret_val;
34140 }
34141
34142 uint32_t  __attribute__((export_name("TS_Payee_clone"))) TS_Payee_clone(uint32_t orig) {
34143         LDKPayee orig_conv;
34144         orig_conv.inner = (void*)(orig & (~1));
34145         orig_conv.is_owned = false;
34146         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34147         LDKPayee ret_var = Payee_clone(&orig_conv);
34148         uintptr_t ret_ref = 0;
34149         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34150         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34152         ret_ref = (uintptr_t)ret_var.inner;
34153         if (ret_var.is_owned) {
34154                 ret_ref |= 1;
34155         }
34156         return ret_ref;
34157 }
34158
34159 int64_t  __attribute__((export_name("TS_Payee_hash"))) TS_Payee_hash(uint32_t o) {
34160         LDKPayee o_conv;
34161         o_conv.inner = (void*)(o & (~1));
34162         o_conv.is_owned = false;
34163         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34164         int64_t ret_val = Payee_hash(&o_conv);
34165         return ret_val;
34166 }
34167
34168 jboolean  __attribute__((export_name("TS_Payee_eq"))) TS_Payee_eq(uint32_t a, uint32_t b) {
34169         LDKPayee a_conv;
34170         a_conv.inner = (void*)(a & (~1));
34171         a_conv.is_owned = false;
34172         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34173         LDKPayee b_conv;
34174         b_conv.inner = (void*)(b & (~1));
34175         b_conv.is_owned = false;
34176         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34177         jboolean ret_val = Payee_eq(&a_conv, &b_conv);
34178         return ret_val;
34179 }
34180
34181 int8_tArray  __attribute__((export_name("TS_Payee_write"))) TS_Payee_write(uint32_t obj) {
34182         LDKPayee obj_conv;
34183         obj_conv.inner = (void*)(obj & (~1));
34184         obj_conv.is_owned = false;
34185         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34186         LDKCVec_u8Z ret_var = Payee_write(&obj_conv);
34187         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34188         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34189         CVec_u8Z_free(ret_var);
34190         return ret_arr;
34191 }
34192
34193 uint32_t  __attribute__((export_name("TS_Payee_read"))) TS_Payee_read(int8_tArray ser) {
34194         LDKu8slice ser_ref;
34195         ser_ref.datalen = ser->arr_len;
34196         ser_ref.data = ser->elems /* XXX ser leaks */;
34197         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
34198         *ret_conv = Payee_read(ser_ref);
34199         return (uintptr_t)ret_conv;
34200 }
34201
34202 uint32_t  __attribute__((export_name("TS_Payee_from_node_id"))) TS_Payee_from_node_id(int8_tArray pubkey) {
34203         LDKPublicKey pubkey_ref;
34204         CHECK(pubkey->arr_len == 33);
34205         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
34206         LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
34207         uintptr_t ret_ref = 0;
34208         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34209         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34211         ret_ref = (uintptr_t)ret_var.inner;
34212         if (ret_var.is_owned) {
34213                 ret_ref |= 1;
34214         }
34215         return ret_ref;
34216 }
34217
34218 uint32_t  __attribute__((export_name("TS_Payee_for_keysend"))) TS_Payee_for_keysend(int8_tArray pubkey) {
34219         LDKPublicKey pubkey_ref;
34220         CHECK(pubkey->arr_len == 33);
34221         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
34222         LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
34223         uintptr_t ret_ref = 0;
34224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34227         ret_ref = (uintptr_t)ret_var.inner;
34228         if (ret_var.is_owned) {
34229                 ret_ref |= 1;
34230         }
34231         return ret_ref;
34232 }
34233
34234 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
34235         LDKRouteHint this_obj_conv;
34236         this_obj_conv.inner = (void*)(this_obj & (~1));
34237         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34239         RouteHint_free(this_obj_conv);
34240 }
34241
34242 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
34243         LDKRouteHint this_ptr_conv;
34244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34245         this_ptr_conv.is_owned = false;
34246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34247         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
34248         uint32_tArray ret_arr = NULL;
34249         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
34250         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
34251         for (size_t o = 0; o < ret_var.datalen; o++) {
34252                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
34253                 uintptr_t ret_conv_14_ref = 0;
34254                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34255                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34256                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
34257                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
34258                 if (ret_conv_14_var.is_owned) {
34259                         ret_conv_14_ref |= 1;
34260                 }
34261                 ret_arr_ptr[o] = ret_conv_14_ref;
34262         }
34263         
34264         FREE(ret_var.data);
34265         return ret_arr;
34266 }
34267
34268 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
34269         LDKRouteHint this_ptr_conv;
34270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34271         this_ptr_conv.is_owned = false;
34272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34273         LDKCVec_RouteHintHopZ val_constr;
34274         val_constr.datalen = val->arr_len;
34275         if (val_constr.datalen > 0)
34276                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
34277         else
34278                 val_constr.data = NULL;
34279         uint32_t* val_vals = val->elems /* XXX val leaks */;
34280         for (size_t o = 0; o < val_constr.datalen; o++) {
34281                 uint32_t val_conv_14 = val_vals[o];
34282                 LDKRouteHintHop val_conv_14_conv;
34283                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
34284                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
34285                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
34286                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
34287                 val_constr.data[o] = val_conv_14_conv;
34288         }
34289         RouteHint_set_a(&this_ptr_conv, val_constr);
34290 }
34291
34292 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
34293         LDKCVec_RouteHintHopZ a_arg_constr;
34294         a_arg_constr.datalen = a_arg->arr_len;
34295         if (a_arg_constr.datalen > 0)
34296                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
34297         else
34298                 a_arg_constr.data = NULL;
34299         uint32_t* a_arg_vals = a_arg->elems /* XXX a_arg leaks */;
34300         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
34301                 uint32_t a_arg_conv_14 = a_arg_vals[o];
34302                 LDKRouteHintHop a_arg_conv_14_conv;
34303                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
34304                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
34305                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
34306                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
34307                 a_arg_constr.data[o] = a_arg_conv_14_conv;
34308         }
34309         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
34310         uintptr_t ret_ref = 0;
34311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34314         ret_ref = (uintptr_t)ret_var.inner;
34315         if (ret_var.is_owned) {
34316                 ret_ref |= 1;
34317         }
34318         return ret_ref;
34319 }
34320
34321 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
34322         LDKRouteHint ret_var = RouteHint_clone(arg);
34323 uintptr_t ret_ref = 0;
34324 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34325 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34326 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34327 ret_ref = (uintptr_t)ret_var.inner;
34328 if (ret_var.is_owned) {
34329         ret_ref |= 1;
34330 }
34331         return ret_ref;
34332 }
34333 intptr_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
34334         LDKRouteHint arg_conv;
34335         arg_conv.inner = (void*)(arg & (~1));
34336         arg_conv.is_owned = false;
34337         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34338         intptr_t ret_val = RouteHint_clone_ptr(&arg_conv);
34339         return ret_val;
34340 }
34341
34342 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
34343         LDKRouteHint orig_conv;
34344         orig_conv.inner = (void*)(orig & (~1));
34345         orig_conv.is_owned = false;
34346         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34347         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
34348         uintptr_t ret_ref = 0;
34349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34352         ret_ref = (uintptr_t)ret_var.inner;
34353         if (ret_var.is_owned) {
34354                 ret_ref |= 1;
34355         }
34356         return ret_ref;
34357 }
34358
34359 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
34360         LDKRouteHint o_conv;
34361         o_conv.inner = (void*)(o & (~1));
34362         o_conv.is_owned = false;
34363         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34364         int64_t ret_val = RouteHint_hash(&o_conv);
34365         return ret_val;
34366 }
34367
34368 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
34369         LDKRouteHint a_conv;
34370         a_conv.inner = (void*)(a & (~1));
34371         a_conv.is_owned = false;
34372         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34373         LDKRouteHint b_conv;
34374         b_conv.inner = (void*)(b & (~1));
34375         b_conv.is_owned = false;
34376         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34377         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
34378         return ret_val;
34379 }
34380
34381 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
34382         LDKRouteHint obj_conv;
34383         obj_conv.inner = (void*)(obj & (~1));
34384         obj_conv.is_owned = false;
34385         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34386         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
34387         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34388         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34389         CVec_u8Z_free(ret_var);
34390         return ret_arr;
34391 }
34392
34393 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
34394         LDKu8slice ser_ref;
34395         ser_ref.datalen = ser->arr_len;
34396         ser_ref.data = ser->elems /* XXX ser leaks */;
34397         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
34398         *ret_conv = RouteHint_read(ser_ref);
34399         return (uintptr_t)ret_conv;
34400 }
34401
34402 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
34403         LDKRouteHintHop this_obj_conv;
34404         this_obj_conv.inner = (void*)(this_obj & (~1));
34405         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34407         RouteHintHop_free(this_obj_conv);
34408 }
34409
34410 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
34411         LDKRouteHintHop this_ptr_conv;
34412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34413         this_ptr_conv.is_owned = false;
34414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34415         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34416         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
34417         return ret_arr;
34418 }
34419
34420 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
34421         LDKRouteHintHop this_ptr_conv;
34422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34423         this_ptr_conv.is_owned = false;
34424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34425         LDKPublicKey val_ref;
34426         CHECK(val->arr_len == 33);
34427         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34428         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
34429 }
34430
34431 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
34432         LDKRouteHintHop this_ptr_conv;
34433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34434         this_ptr_conv.is_owned = false;
34435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34436         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
34437         return ret_val;
34438 }
34439
34440 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
34441         LDKRouteHintHop this_ptr_conv;
34442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34443         this_ptr_conv.is_owned = false;
34444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34445         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
34446 }
34447
34448 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
34449         LDKRouteHintHop this_ptr_conv;
34450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34451         this_ptr_conv.is_owned = false;
34452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34453         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
34454         uintptr_t ret_ref = 0;
34455         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34456         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34457         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34458         ret_ref = (uintptr_t)ret_var.inner;
34459         if (ret_var.is_owned) {
34460                 ret_ref |= 1;
34461         }
34462         return ret_ref;
34463 }
34464
34465 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
34466         LDKRouteHintHop this_ptr_conv;
34467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34468         this_ptr_conv.is_owned = false;
34469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34470         LDKRoutingFees val_conv;
34471         val_conv.inner = (void*)(val & (~1));
34472         val_conv.is_owned = (val & 1) || (val == 0);
34473         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34474         val_conv = RoutingFees_clone(&val_conv);
34475         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
34476 }
34477
34478 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
34479         LDKRouteHintHop this_ptr_conv;
34480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34481         this_ptr_conv.is_owned = false;
34482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34483         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
34484         return ret_val;
34485 }
34486
34487 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
34488         LDKRouteHintHop this_ptr_conv;
34489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34490         this_ptr_conv.is_owned = false;
34491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34492         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
34493 }
34494
34495 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
34496         LDKRouteHintHop this_ptr_conv;
34497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34498         this_ptr_conv.is_owned = false;
34499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34500         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34501         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
34502         uintptr_t ret_ref = (uintptr_t)ret_copy;
34503         return ret_ref;
34504 }
34505
34506 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
34507         LDKRouteHintHop this_ptr_conv;
34508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34509         this_ptr_conv.is_owned = false;
34510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34511         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34512         CHECK_ACCESS(val_ptr);
34513         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34514         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
34515         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
34516 }
34517
34518 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
34519         LDKRouteHintHop this_ptr_conv;
34520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34521         this_ptr_conv.is_owned = false;
34522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34523         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34524         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
34525         uintptr_t ret_ref = (uintptr_t)ret_copy;
34526         return ret_ref;
34527 }
34528
34529 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
34530         LDKRouteHintHop this_ptr_conv;
34531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34532         this_ptr_conv.is_owned = false;
34533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34534         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34535         CHECK_ACCESS(val_ptr);
34536         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34537         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
34538         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
34539 }
34540
34541 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) {
34542         LDKPublicKey src_node_id_arg_ref;
34543         CHECK(src_node_id_arg->arr_len == 33);
34544         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
34545         LDKRoutingFees fees_arg_conv;
34546         fees_arg_conv.inner = (void*)(fees_arg & (~1));
34547         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
34548         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
34549         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
34550         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
34551         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
34552         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
34553         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
34554         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
34555         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
34556         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
34557         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
34558         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);
34559         uintptr_t ret_ref = 0;
34560         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34561         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34563         ret_ref = (uintptr_t)ret_var.inner;
34564         if (ret_var.is_owned) {
34565                 ret_ref |= 1;
34566         }
34567         return ret_ref;
34568 }
34569
34570 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
34571         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
34572 uintptr_t ret_ref = 0;
34573 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34574 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34575 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34576 ret_ref = (uintptr_t)ret_var.inner;
34577 if (ret_var.is_owned) {
34578         ret_ref |= 1;
34579 }
34580         return ret_ref;
34581 }
34582 intptr_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
34583         LDKRouteHintHop arg_conv;
34584         arg_conv.inner = (void*)(arg & (~1));
34585         arg_conv.is_owned = false;
34586         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34587         intptr_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
34588         return ret_val;
34589 }
34590
34591 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
34592         LDKRouteHintHop orig_conv;
34593         orig_conv.inner = (void*)(orig & (~1));
34594         orig_conv.is_owned = false;
34595         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34596         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
34597         uintptr_t ret_ref = 0;
34598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34601         ret_ref = (uintptr_t)ret_var.inner;
34602         if (ret_var.is_owned) {
34603                 ret_ref |= 1;
34604         }
34605         return ret_ref;
34606 }
34607
34608 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
34609         LDKRouteHintHop o_conv;
34610         o_conv.inner = (void*)(o & (~1));
34611         o_conv.is_owned = false;
34612         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34613         int64_t ret_val = RouteHintHop_hash(&o_conv);
34614         return ret_val;
34615 }
34616
34617 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
34618         LDKRouteHintHop a_conv;
34619         a_conv.inner = (void*)(a & (~1));
34620         a_conv.is_owned = false;
34621         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34622         LDKRouteHintHop b_conv;
34623         b_conv.inner = (void*)(b & (~1));
34624         b_conv.is_owned = false;
34625         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34626         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
34627         return ret_val;
34628 }
34629
34630 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
34631         LDKRouteHintHop obj_conv;
34632         obj_conv.inner = (void*)(obj & (~1));
34633         obj_conv.is_owned = false;
34634         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34635         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
34636         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34637         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34638         CVec_u8Z_free(ret_var);
34639         return ret_arr;
34640 }
34641
34642 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
34643         LDKu8slice ser_ref;
34644         ser_ref.datalen = ser->arr_len;
34645         ser_ref.data = ser->elems /* XXX ser leaks */;
34646         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
34647         *ret_conv = RouteHintHop_read(ser_ref);
34648         return (uintptr_t)ret_conv;
34649 }
34650
34651 uint32_t  __attribute__((export_name("TS_find_route"))) TS_find_route(int8_tArray our_node_pubkey, uint32_t params, uint32_t network, uint32_tArray first_hops, uint32_t logger, uint32_t scorer) {
34652         LDKPublicKey our_node_pubkey_ref;
34653         CHECK(our_node_pubkey->arr_len == 33);
34654         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
34655         LDKRouteParameters params_conv;
34656         params_conv.inner = (void*)(params & (~1));
34657         params_conv.is_owned = false;
34658         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
34659         LDKNetworkGraph network_conv;
34660         network_conv.inner = (void*)(network & (~1));
34661         network_conv.is_owned = false;
34662         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
34663         LDKCVec_ChannelDetailsZ first_hops_constr;
34664         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
34665         if (first_hops != 0) {
34666                 first_hops_constr.datalen = first_hops->arr_len;
34667                 if (first_hops_constr.datalen > 0)
34668                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
34669                 else
34670                         first_hops_constr.data = NULL;
34671                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
34672                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
34673                         uint32_t first_hops_conv_16 = first_hops_vals[q];
34674                         LDKChannelDetails first_hops_conv_16_conv;
34675                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
34676                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
34677                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
34678                         first_hops_constr.data[q] = first_hops_conv_16_conv;
34679                 }
34680                 first_hops_ptr = &first_hops_constr;
34681         }
34682         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
34683         CHECK_ACCESS(logger_ptr);
34684         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34685         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
34686         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
34687         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
34688         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
34689         *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
34690         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
34691         return (uintptr_t)ret_conv;
34692 }
34693
34694 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
34695         if ((this_ptr & 1) != 0) return;
34696         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34697         CHECK_ACCESS(this_ptr_ptr);
34698         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
34699         FREE((void*)this_ptr);
34700         Score_free(this_ptr_conv);
34701 }
34702
34703 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
34704         if ((this_ptr & 1) != 0) return;
34705         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34706         CHECK_ACCESS(this_ptr_ptr);
34707         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
34708         FREE((void*)this_ptr);
34709         LockableScore_free(this_ptr_conv);
34710 }
34711
34712 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
34713         LDKMultiThreadedLockableScore this_obj_conv;
34714         this_obj_conv.inner = (void*)(this_obj & (~1));
34715         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34717         MultiThreadedLockableScore_free(this_obj_conv);
34718 }
34719
34720 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
34721         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
34722         CHECK_ACCESS(score_ptr);
34723         LDKScore score_conv = *(LDKScore*)(score_ptr);
34724         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
34725         uintptr_t ret_ref = 0;
34726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34729         ret_ref = (uintptr_t)ret_var.inner;
34730         if (ret_var.is_owned) {
34731                 ret_ref |= 1;
34732         }
34733         return ret_ref;
34734 }
34735
34736 void  __attribute__((export_name("TS_ScoringParameters_free"))) TS_ScoringParameters_free(uint32_t this_obj) {
34737         LDKScoringParameters this_obj_conv;
34738         this_obj_conv.inner = (void*)(this_obj & (~1));
34739         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34741         ScoringParameters_free(this_obj_conv);
34742 }
34743
34744 int64_t  __attribute__((export_name("TS_ScoringParameters_get_base_penalty_msat"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
34745         LDKScoringParameters this_ptr_conv;
34746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34747         this_ptr_conv.is_owned = false;
34748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34749         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
34750         return ret_val;
34751 }
34752
34753 void  __attribute__((export_name("TS_ScoringParameters_set_base_penalty_msat"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
34754         LDKScoringParameters this_ptr_conv;
34755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34756         this_ptr_conv.is_owned = false;
34757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34758         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
34759 }
34760
34761 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_msat"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
34762         LDKScoringParameters this_ptr_conv;
34763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34764         this_ptr_conv.is_owned = false;
34765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34766         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
34767         return ret_val;
34768 }
34769
34770 void  __attribute__((export_name("TS_ScoringParameters_set_failure_penalty_msat"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
34771         LDKScoringParameters this_ptr_conv;
34772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34773         this_ptr_conv.is_owned = false;
34774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34775         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
34776 }
34777
34778 int16_t  __attribute__((export_name("TS_ScoringParameters_get_overuse_penalty_start_1024th"))) TS_ScoringParameters_get_overuse_penalty_start_1024th(uint32_t this_ptr) {
34779         LDKScoringParameters this_ptr_conv;
34780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34781         this_ptr_conv.is_owned = false;
34782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34783         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
34784         return ret_val;
34785 }
34786
34787 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) {
34788         LDKScoringParameters this_ptr_conv;
34789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34790         this_ptr_conv.is_owned = false;
34791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34792         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
34793 }
34794
34795 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) {
34796         LDKScoringParameters this_ptr_conv;
34797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34798         this_ptr_conv.is_owned = false;
34799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34800         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
34801         return ret_val;
34802 }
34803
34804 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) {
34805         LDKScoringParameters this_ptr_conv;
34806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34807         this_ptr_conv.is_owned = false;
34808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34809         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
34810 }
34811
34812 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_half_life"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
34813         LDKScoringParameters this_ptr_conv;
34814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34815         this_ptr_conv.is_owned = false;
34816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34817         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
34818         return ret_val;
34819 }
34820
34821 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) {
34822         LDKScoringParameters this_ptr_conv;
34823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34824         this_ptr_conv.is_owned = false;
34825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34826         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
34827 }
34828
34829 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) {
34830         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);
34831         uintptr_t ret_ref = 0;
34832         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34833         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34835         ret_ref = (uintptr_t)ret_var.inner;
34836         if (ret_var.is_owned) {
34837                 ret_ref |= 1;
34838         }
34839         return ret_ref;
34840 }
34841
34842 int8_tArray  __attribute__((export_name("TS_ScoringParameters_write"))) TS_ScoringParameters_write(uint32_t obj) {
34843         LDKScoringParameters obj_conv;
34844         obj_conv.inner = (void*)(obj & (~1));
34845         obj_conv.is_owned = false;
34846         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34847         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
34848         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34849         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34850         CVec_u8Z_free(ret_var);
34851         return ret_arr;
34852 }
34853
34854 uint32_t  __attribute__((export_name("TS_ScoringParameters_read"))) TS_ScoringParameters_read(int8_tArray ser) {
34855         LDKu8slice ser_ref;
34856         ser_ref.datalen = ser->arr_len;
34857         ser_ref.data = ser->elems /* XXX ser leaks */;
34858         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
34859         *ret_conv = ScoringParameters_read(ser_ref);
34860         return (uintptr_t)ret_conv;
34861 }
34862
34863 uint32_t  __attribute__((export_name("TS_ScoringParameters_default"))) TS_ScoringParameters_default() {
34864         LDKScoringParameters ret_var = ScoringParameters_default();
34865         uintptr_t ret_ref = 0;
34866         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34867         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34869         ret_ref = (uintptr_t)ret_var.inner;
34870         if (ret_var.is_owned) {
34871                 ret_ref |= 1;
34872         }
34873         return ret_ref;
34874 }
34875