Update CI references to 0.0.122
[ldk-java] / ts / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include "js-wasm.h"
4 #include <stdatomic.h>
5 #include <lightning.h>
6
7 // These should be provided...somehow...
8 void *memset(void *s, int c, size_t n);
9 void *memcpy(void *dest, const void *src, size_t n);
10 int memcmp(const void *s1, const void *s2, size_t n);
11
12 extern void __attribute__((noreturn)) abort(void);
13 static inline void assert(bool expression) {
14         if (!expression) { abort(); }
15 }
16
17 uint32_t __attribute__((export_name("test_bigint_pass_deadbeef0badf00d"))) test_bigint_pass_deadbeef0badf00d(uint64_t val) {
18         return val == 0xdeadbeef0badf00dULL;
19 }
20
21
22 void *malloc(size_t size);
23 void free(void *ptr);
24
25 #define MALLOC(a, _) malloc(a)
26 #define do_MALLOC(a, _b, _c) malloc(a)
27 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
28 #define DO_ASSERT(a) (void)(a)
29 #define CHECK(a)
30 #define CHECK_ACCESS(p)
31 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
32
33 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
34 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
35 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
36 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
37
38 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
39
40 #define DECL_ARR_TYPE(ty, name) \
41         struct name##array { \
42                 uint32_t arr_len; \
43                 ty elems[]; \
44         }; \
45         typedef struct name##array * name##Array; \
46         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
47                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint32_t), #name" array init", lineno); \
48                 arr->arr_len = arr_len; \
49                 return arr; \
50         }
51
52 DECL_ARR_TYPE(int64_t, int64_t);
53 DECL_ARR_TYPE(int8_t, int8_t);
54 DECL_ARR_TYPE(uint32_t, uint32_t);
55 DECL_ARR_TYPE(void*, ptr);
56 DECL_ARR_TYPE(char, char);
57 typedef charArray jstring;
58
59 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
60         charArray arr = init_charArray(len, __LINE__);
61         memcpy(arr->elems, chars, len);
62         return arr;
63 }
64 static inline LDKStr str_ref_to_owned_c(const jstring str) {
65         char* newchars = MALLOC(str->arr_len + 1, "String chars");
66         memcpy(newchars, str->elems, str->arr_len);
67         newchars[str->arr_len] = 0;
68         LDKStr res = {
69                 .chars = newchars,
70                 .len = str->arr_len,
71                 .chars_is_owned = true
72         };
73         return res;
74 }
75
76 typedef bool jboolean;
77
78 uint32_t __attribute__((export_name("TS_malloc"))) TS_malloc(uint32_t size) {
79         return (uint32_t)MALLOC(size, "JS-Called malloc");
80 }
81 void __attribute__((export_name("TS_free"))) TS_free(uint32_t ptr) {
82         FREE((void*)ptr);
83 }
84
85 jstring __attribute__((export_name("TS_get_ldk_c_bindings_version"))) TS_get_ldk_c_bindings_version() {
86         const char *res = check_get_ldk_bindings_version();
87         if (res == NULL) return NULL;
88         return str_ref_to_ts(res, strlen(res));
89 }
90 jstring __attribute__((export_name("TS_get_ldk_version"))) get_ldk_version() {
91         const char *res = check_get_ldk_version();
92         if (res == NULL) return NULL;
93         return str_ref_to_ts(res, strlen(res));
94 }
95 #include "version.c"
96 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
97 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
98         switch (ord) {
99                 case 0: return LDKAccessError_UnknownChain;
100                 case 1: return LDKAccessError_UnknownTx;
101         }
102         abort();
103 }
104 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
105         switch (val) {
106                 case LDKAccessError_UnknownChain: return 0;
107                 case LDKAccessError_UnknownTx: return 1;
108                 default: abort();
109         }
110 }
111 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
112         switch (ord) {
113                 case 0: return LDKCOption_NoneZ_Some;
114                 case 1: return LDKCOption_NoneZ_None;
115         }
116         abort();
117 }
118 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
119         switch (val) {
120                 case LDKCOption_NoneZ_Some: return 0;
121                 case LDKCOption_NoneZ_None: return 1;
122                 default: abort();
123         }
124 }
125 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
126         switch (ord) {
127                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
128                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
129         }
130         abort();
131 }
132 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
133         switch (val) {
134                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
135                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
136                 default: abort();
137         }
138 }
139 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
140         switch (ord) {
141                 case 0: return LDKConfirmationTarget_Background;
142                 case 1: return LDKConfirmationTarget_Normal;
143                 case 2: return LDKConfirmationTarget_HighPriority;
144         }
145         abort();
146 }
147 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
148         switch (val) {
149                 case LDKConfirmationTarget_Background: return 0;
150                 case LDKConfirmationTarget_Normal: return 1;
151                 case LDKConfirmationTarget_HighPriority: return 2;
152                 default: abort();
153         }
154 }
155 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
156         switch (ord) {
157                 case 0: return LDKLevel_Gossip;
158                 case 1: return LDKLevel_Trace;
159                 case 2: return LDKLevel_Debug;
160                 case 3: return LDKLevel_Info;
161                 case 4: return LDKLevel_Warn;
162                 case 5: return LDKLevel_Error;
163         }
164         abort();
165 }
166 static inline int32_t LDKLevel_to_js(LDKLevel val) {
167         switch (val) {
168                 case LDKLevel_Gossip: return 0;
169                 case LDKLevel_Trace: return 1;
170                 case LDKLevel_Debug: return 2;
171                 case LDKLevel_Info: return 3;
172                 case LDKLevel_Warn: return 4;
173                 case LDKLevel_Error: return 5;
174                 default: abort();
175         }
176 }
177 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
178         switch (ord) {
179                 case 0: return LDKNetwork_Bitcoin;
180                 case 1: return LDKNetwork_Testnet;
181                 case 2: return LDKNetwork_Regtest;
182                 case 3: return LDKNetwork_Signet;
183         }
184         abort();
185 }
186 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
187         switch (val) {
188                 case LDKNetwork_Bitcoin: return 0;
189                 case LDKNetwork_Testnet: return 1;
190                 case LDKNetwork_Regtest: return 2;
191                 case LDKNetwork_Signet: return 3;
192                 default: abort();
193         }
194 }
195 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
196         switch (ord) {
197                 case 0: return LDKSecp256k1Error_IncorrectSignature;
198                 case 1: return LDKSecp256k1Error_InvalidMessage;
199                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
200                 case 3: return LDKSecp256k1Error_InvalidSignature;
201                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
202                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
203                 case 6: return LDKSecp256k1Error_InvalidTweak;
204                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
205                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
206         }
207         abort();
208 }
209 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
210         switch (val) {
211                 case LDKSecp256k1Error_IncorrectSignature: return 0;
212                 case LDKSecp256k1Error_InvalidMessage: return 1;
213                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
214                 case LDKSecp256k1Error_InvalidSignature: return 3;
215                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
216                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
217                 case LDKSecp256k1Error_InvalidTweak: return 6;
218                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
219                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
220                 default: abort();
221         }
222 }
223 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
224         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
225         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
226         return ret;
227 }
228 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) {
229         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
230         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
231         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
232         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
233         CVec_u8Z_free(ret_var);
234         return ret_arr;
235 }
236
237 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) {
238         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
239         int64_t ret_val = TxOut_get_value(thing_conv);
240         return ret_val;
241 }
242
243 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
244 CHECK(owner->result_ok);
245         return ChannelConfig_clone(&*owner->contents.result);
246 }
247 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
248         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
249         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
250         uintptr_t ret_ref = 0;
251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
254         ret_ref = (uintptr_t)ret_var.inner;
255         if (ret_var.is_owned) {
256                 ret_ref |= 1;
257         }
258         return ret_ref;
259 }
260
261 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
262 CHECK(!owner->result_ok);
263         return DecodeError_clone(&*owner->contents.err);
264 }
265 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
266         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
267         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
268         uintptr_t ret_ref = 0;
269         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
270         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
272         ret_ref = (uintptr_t)ret_var.inner;
273         if (ret_var.is_owned) {
274                 ret_ref |= 1;
275         }
276         return ret_ref;
277 }
278
279 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
280 CHECK(owner->result_ok);
281         return OutPoint_clone(&*owner->contents.result);
282 }
283 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
284         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
285         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
286         uintptr_t ret_ref = 0;
287         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
288         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
290         ret_ref = (uintptr_t)ret_var.inner;
291         if (ret_var.is_owned) {
292                 ret_ref |= 1;
293         }
294         return ret_ref;
295 }
296
297 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
298 CHECK(!owner->result_ok);
299         return DecodeError_clone(&*owner->contents.err);
300 }
301 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
302         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
303         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
304         uintptr_t ret_ref = 0;
305         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
306         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
308         ret_ref = (uintptr_t)ret_var.inner;
309         if (ret_var.is_owned) {
310                 ret_ref |= 1;
311         }
312         return ret_ref;
313 }
314
315 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
316 CHECK(owner->result_ok);
317         return *owner->contents.result;
318 }
319 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
320         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
321         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
322         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
323         return ret_arr;
324 }
325
326 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
327 CHECK(!owner->result_ok);
328         return *owner->contents.err;
329 }
330 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
331         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
332         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
333         return ret_conv;
334 }
335
336 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
337 CHECK(owner->result_ok);
338         return *owner->contents.result;
339 }
340 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
341         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
342         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
343         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
344         return ret_arr;
345 }
346
347 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
348 CHECK(!owner->result_ok);
349         return *owner->contents.err;
350 }
351 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
352         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
353         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
354         return ret_conv;
355 }
356
357 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
358 CHECK(owner->result_ok);
359         return TxCreationKeys_clone(&*owner->contents.result);
360 }
361 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
362         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
363         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
364         uintptr_t ret_ref = 0;
365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
368         ret_ref = (uintptr_t)ret_var.inner;
369         if (ret_var.is_owned) {
370                 ret_ref |= 1;
371         }
372         return ret_ref;
373 }
374
375 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
376 CHECK(!owner->result_ok);
377         return DecodeError_clone(&*owner->contents.err);
378 }
379 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
380         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
381         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
382         uintptr_t ret_ref = 0;
383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
386         ret_ref = (uintptr_t)ret_var.inner;
387         if (ret_var.is_owned) {
388                 ret_ref |= 1;
389         }
390         return ret_ref;
391 }
392
393 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
394 CHECK(owner->result_ok);
395         return ChannelPublicKeys_clone(&*owner->contents.result);
396 }
397 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
398         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
399         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
400         uintptr_t ret_ref = 0;
401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
404         ret_ref = (uintptr_t)ret_var.inner;
405         if (ret_var.is_owned) {
406                 ret_ref |= 1;
407         }
408         return ret_ref;
409 }
410
411 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
412 CHECK(!owner->result_ok);
413         return DecodeError_clone(&*owner->contents.err);
414 }
415 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
416         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
417         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
418         uintptr_t ret_ref = 0;
419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
422         ret_ref = (uintptr_t)ret_var.inner;
423         if (ret_var.is_owned) {
424                 ret_ref |= 1;
425         }
426         return ret_ref;
427 }
428
429 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
430 CHECK(owner->result_ok);
431         return TxCreationKeys_clone(&*owner->contents.result);
432 }
433 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
434         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
435         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
436         uintptr_t ret_ref = 0;
437         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
438         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
440         ret_ref = (uintptr_t)ret_var.inner;
441         if (ret_var.is_owned) {
442                 ret_ref |= 1;
443         }
444         return ret_ref;
445 }
446
447 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
448 CHECK(!owner->result_ok);
449         return *owner->contents.err;
450 }
451 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
452         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
453         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
454         return ret_conv;
455 }
456
457 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
458         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
459         switch(obj->tag) {
460                 case LDKCOption_u32Z_Some: return 0;
461                 case LDKCOption_u32Z_None: return 1;
462                 default: abort();
463         }
464 }
465 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
466         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
467         assert(obj->tag == LDKCOption_u32Z_Some);
468         return obj->some;
469 }
470 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
471 CHECK(owner->result_ok);
472         return HTLCOutputInCommitment_clone(&*owner->contents.result);
473 }
474 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
475         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
476         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
477         uintptr_t ret_ref = 0;
478         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
479         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
481         ret_ref = (uintptr_t)ret_var.inner;
482         if (ret_var.is_owned) {
483                 ret_ref |= 1;
484         }
485         return ret_ref;
486 }
487
488 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
489 CHECK(!owner->result_ok);
490         return DecodeError_clone(&*owner->contents.err);
491 }
492 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
493         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
494         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
495         uintptr_t ret_ref = 0;
496         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
497         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
499         ret_ref = (uintptr_t)ret_var.inner;
500         if (ret_var.is_owned) {
501                 ret_ref |= 1;
502         }
503         return ret_ref;
504 }
505
506 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
507 CHECK(owner->result_ok);
508         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
509 }
510 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
511         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
512         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
513         uintptr_t ret_ref = 0;
514         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
515         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
517         ret_ref = (uintptr_t)ret_var.inner;
518         if (ret_var.is_owned) {
519                 ret_ref |= 1;
520         }
521         return ret_ref;
522 }
523
524 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
525 CHECK(!owner->result_ok);
526         return DecodeError_clone(&*owner->contents.err);
527 }
528 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
529         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
530         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
531         uintptr_t ret_ref = 0;
532         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
533         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
535         ret_ref = (uintptr_t)ret_var.inner;
536         if (ret_var.is_owned) {
537                 ret_ref |= 1;
538         }
539         return ret_ref;
540 }
541
542 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
543 CHECK(owner->result_ok);
544         return ChannelTransactionParameters_clone(&*owner->contents.result);
545 }
546 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
547         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
548         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
549         uintptr_t ret_ref = 0;
550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
553         ret_ref = (uintptr_t)ret_var.inner;
554         if (ret_var.is_owned) {
555                 ret_ref |= 1;
556         }
557         return ret_ref;
558 }
559
560 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
561 CHECK(!owner->result_ok);
562         return DecodeError_clone(&*owner->contents.err);
563 }
564 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
565         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
566         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
567         uintptr_t ret_ref = 0;
568         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
569         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
571         ret_ref = (uintptr_t)ret_var.inner;
572         if (ret_var.is_owned) {
573                 ret_ref |= 1;
574         }
575         return ret_ref;
576 }
577
578 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
579 CHECK(owner->result_ok);
580         return HolderCommitmentTransaction_clone(&*owner->contents.result);
581 }
582 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
583         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
584         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
585         uintptr_t ret_ref = 0;
586         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
587         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
589         ret_ref = (uintptr_t)ret_var.inner;
590         if (ret_var.is_owned) {
591                 ret_ref |= 1;
592         }
593         return ret_ref;
594 }
595
596 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
597 CHECK(!owner->result_ok);
598         return DecodeError_clone(&*owner->contents.err);
599 }
600 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
601         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
602         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
603         uintptr_t ret_ref = 0;
604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
607         ret_ref = (uintptr_t)ret_var.inner;
608         if (ret_var.is_owned) {
609                 ret_ref |= 1;
610         }
611         return ret_ref;
612 }
613
614 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
615 CHECK(owner->result_ok);
616         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
617 }
618 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
619         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
620         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
621         uintptr_t ret_ref = 0;
622         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
623         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
625         ret_ref = (uintptr_t)ret_var.inner;
626         if (ret_var.is_owned) {
627                 ret_ref |= 1;
628         }
629         return ret_ref;
630 }
631
632 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
633 CHECK(!owner->result_ok);
634         return DecodeError_clone(&*owner->contents.err);
635 }
636 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
637         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
638         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
639         uintptr_t ret_ref = 0;
640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
643         ret_ref = (uintptr_t)ret_var.inner;
644         if (ret_var.is_owned) {
645                 ret_ref |= 1;
646         }
647         return ret_ref;
648 }
649
650 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
651 CHECK(owner->result_ok);
652         return &*owner->contents.result;
653 }
654 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
655         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
656         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
657         uintptr_t ret_ref = 0;
658         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
659         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
661         ret_ref = (uintptr_t)ret_var.inner & ~1;
662         return ret_ref;
663 }
664
665 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
666 CHECK(!owner->result_ok);
667         return *owner->contents.err;
668 }
669 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
670         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
671         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
672 }
673
674 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
675 CHECK(owner->result_ok);
676         return CommitmentTransaction_clone(&*owner->contents.result);
677 }
678 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
679         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
680         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
681         uintptr_t ret_ref = 0;
682         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
683         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
685         ret_ref = (uintptr_t)ret_var.inner;
686         if (ret_var.is_owned) {
687                 ret_ref |= 1;
688         }
689         return ret_ref;
690 }
691
692 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
693 CHECK(!owner->result_ok);
694         return DecodeError_clone(&*owner->contents.err);
695 }
696 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
697         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
698         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
699         uintptr_t ret_ref = 0;
700         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
701         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
703         ret_ref = (uintptr_t)ret_var.inner;
704         if (ret_var.is_owned) {
705                 ret_ref |= 1;
706         }
707         return ret_ref;
708 }
709
710 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
711 CHECK(owner->result_ok);
712         return &*owner->contents.result;
713 }
714 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
715         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
716         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
717         uintptr_t ret_ref = 0;
718         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
719         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
721         ret_ref = (uintptr_t)ret_var.inner & ~1;
722         return ret_ref;
723 }
724
725 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
726 CHECK(!owner->result_ok);
727         return *owner->contents.err;
728 }
729 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
730         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
731         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
732 }
733
734 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
735 CHECK(owner->result_ok);
736         return *owner->contents.result;
737 }
738 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
739         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
740         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
741         ptrArray ret_arr = NULL;
742         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
743         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
744         for (size_t m = 0; m < ret_var.datalen; m++) {
745                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
746                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
747                 ret_arr_ptr[m] = ret_conv_12_arr;
748         }
749         
750         return ret_arr;
751 }
752
753 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
754 CHECK(!owner->result_ok);
755         return *owner->contents.err;
756 }
757 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
758         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
759         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
760 }
761
762 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
763 CHECK(owner->result_ok);
764         return ShutdownScript_clone(&*owner->contents.result);
765 }
766 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
767         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
768         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
769         uintptr_t ret_ref = 0;
770         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
771         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
773         ret_ref = (uintptr_t)ret_var.inner;
774         if (ret_var.is_owned) {
775                 ret_ref |= 1;
776         }
777         return ret_ref;
778 }
779
780 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
781 CHECK(!owner->result_ok);
782         return DecodeError_clone(&*owner->contents.err);
783 }
784 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
785         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
786         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
787         uintptr_t ret_ref = 0;
788         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
789         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
790         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
791         ret_ref = (uintptr_t)ret_var.inner;
792         if (ret_var.is_owned) {
793                 ret_ref |= 1;
794         }
795         return ret_ref;
796 }
797
798 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
799 CHECK(owner->result_ok);
800         return ShutdownScript_clone(&*owner->contents.result);
801 }
802 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
803         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
804         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
805         uintptr_t ret_ref = 0;
806         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
807         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
809         ret_ref = (uintptr_t)ret_var.inner;
810         if (ret_var.is_owned) {
811                 ret_ref |= 1;
812         }
813         return ret_ref;
814 }
815
816 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
817 CHECK(!owner->result_ok);
818         return InvalidShutdownScript_clone(&*owner->contents.err);
819 }
820 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
821         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
822         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
823         uintptr_t ret_ref = 0;
824         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
825         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
827         ret_ref = (uintptr_t)ret_var.inner;
828         if (ret_var.is_owned) {
829                 ret_ref |= 1;
830         }
831         return ret_ref;
832 }
833
834 typedef struct LDKType_JCalls {
835         atomic_size_t refcnt;
836         uint32_t instance_ptr;
837 } LDKType_JCalls;
838 static void LDKType_JCalls_free(void* this_arg) {
839         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
840         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
841                 FREE(j_calls);
842         }
843 }
844 uint16_t type_id_LDKType_jcall(const void* this_arg) {
845         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
846         return js_invoke_function_0(j_calls->instance_ptr, 0);
847 }
848 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
849         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
850         jstring ret = (jstring)js_invoke_function_0(j_calls->instance_ptr, 1);
851         LDKStr ret_conv = str_ref_to_owned_c(ret);
852         return ret_conv;
853 }
854 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
855         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
856         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 2);
857         LDKCVec_u8Z ret_ref;
858         ret_ref.datalen = ret->arr_len;
859         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
860         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
861         return ret_ref;
862 }
863 static void LDKType_JCalls_cloned(LDKType* new_obj) {
864         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
865         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
866 }
867 static inline LDKType LDKType_init (JSValue o) {
868         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
869         atomic_init(&calls->refcnt, 1);
870         calls->instance_ptr = o;
871
872         LDKType ret = {
873                 .this_arg = (void*) calls,
874                 .type_id = type_id_LDKType_jcall,
875                 .debug_str = debug_str_LDKType_jcall,
876                 .write = write_LDKType_jcall,
877                 .cloned = LDKType_JCalls_cloned,
878                 .free = LDKType_JCalls_free,
879         };
880         return ret;
881 }
882 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
883         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
884         *res_ptr = LDKType_init(o);
885         return (long)res_ptr;
886 }
887 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
888         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
889         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
890         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
891         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
892         return ret_val;
893 }
894
895 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
896         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
897         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
898         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
899         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
900         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
901         Str_free(ret_str);
902         return ret_conv;
903 }
904
905 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
906         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
907         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
908         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
909         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
910         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
911         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
912         CVec_u8Z_free(ret_var);
913         return ret_arr;
914 }
915
916 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
917         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
918         switch(obj->tag) {
919                 case LDKCOption_TypeZ_Some: return 0;
920                 case LDKCOption_TypeZ_None: return 1;
921                 default: abort();
922         }
923 }
924 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
925         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
926         assert(obj->tag == LDKCOption_TypeZ_Some);
927                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
928                         *some_ret = Type_clone(&obj->some);
929         return (uintptr_t)some_ret;
930 }
931 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
932 CHECK(owner->result_ok);
933         return COption_TypeZ_clone(&*owner->contents.result);
934 }
935 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
936         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
937         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
938         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
939         uintptr_t ret_ref = (uintptr_t)ret_copy;
940         return ret_ref;
941 }
942
943 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
944 CHECK(!owner->result_ok);
945         return DecodeError_clone(&*owner->contents.err);
946 }
947 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
948         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
949         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
950         uintptr_t ret_ref = 0;
951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
954         ret_ref = (uintptr_t)ret_var.inner;
955         if (ret_var.is_owned) {
956                 ret_ref |= 1;
957         }
958         return ret_ref;
959 }
960
961 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
962 CHECK(owner->result_ok);
963         return *owner->contents.result;
964 }
965 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
966         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
967         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
968         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
969         return ret_conv;
970 }
971
972 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
973 CHECK(!owner->result_ok);
974         return *owner->contents.err;
975 }
976 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
977         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
978         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
979         return ret_conv;
980 }
981
982 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
983 CHECK(owner->result_ok);
984         return ChannelMonitorUpdate_clone(&*owner->contents.result);
985 }
986 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
987         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
988         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
989         uintptr_t ret_ref = 0;
990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
993         ret_ref = (uintptr_t)ret_var.inner;
994         if (ret_var.is_owned) {
995                 ret_ref |= 1;
996         }
997         return ret_ref;
998 }
999
1000 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
1001 CHECK(!owner->result_ok);
1002         return DecodeError_clone(&*owner->contents.err);
1003 }
1004 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
1005         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
1006         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
1007         uintptr_t ret_ref = 0;
1008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1011         ret_ref = (uintptr_t)ret_var.inner;
1012         if (ret_var.is_owned) {
1013                 ret_ref |= 1;
1014         }
1015         return ret_ref;
1016 }
1017
1018 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
1019         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1020         switch(obj->tag) {
1021                 case LDKMonitorEvent_HTLCEvent: return 0;
1022                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
1023                 case LDKMonitorEvent_UpdateCompleted: return 2;
1024                 case LDKMonitorEvent_UpdateFailed: return 3;
1025                 default: abort();
1026         }
1027 }
1028 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
1029         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1030         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
1031                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1032                         uintptr_t htlc_event_ref = 0;
1033                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1034                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1035                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1036                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
1037         return htlc_event_ref;
1038 }
1039 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
1040         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1041         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
1042                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1043                         uintptr_t commitment_tx_confirmed_ref = 0;
1044                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1045                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1046                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1047                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
1048         return commitment_tx_confirmed_ref;
1049 }
1050 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
1051         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1052         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1053                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1054                         uintptr_t funding_txo_ref = 0;
1055                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1056                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1057                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1058                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
1059         return funding_txo_ref;
1060 }
1061 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
1062         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1063         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1064         return obj->update_completed.monitor_update_id;
1065 }
1066 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
1067         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1068         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
1069                         LDKOutPoint update_failed_var = obj->update_failed;
1070                         uintptr_t update_failed_ref = 0;
1071                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1072                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1073                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1074                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
1075         return update_failed_ref;
1076 }
1077 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
1078         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
1079         switch(obj->tag) {
1080                 case LDKCOption_MonitorEventZ_Some: return 0;
1081                 case LDKCOption_MonitorEventZ_None: return 1;
1082                 default: abort();
1083         }
1084 }
1085 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
1086         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
1087         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
1088                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
1089         return some_ref;
1090 }
1091 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
1092 CHECK(owner->result_ok);
1093         return COption_MonitorEventZ_clone(&*owner->contents.result);
1094 }
1095 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
1096         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
1097         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
1098         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
1099         uintptr_t ret_ref = (uintptr_t)ret_copy;
1100         return ret_ref;
1101 }
1102
1103 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
1104 CHECK(!owner->result_ok);
1105         return DecodeError_clone(&*owner->contents.err);
1106 }
1107 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
1108         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
1109         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
1110         uintptr_t ret_ref = 0;
1111         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1112         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1114         ret_ref = (uintptr_t)ret_var.inner;
1115         if (ret_var.is_owned) {
1116                 ret_ref |= 1;
1117         }
1118         return ret_ref;
1119 }
1120
1121 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
1122 CHECK(owner->result_ok);
1123         return HTLCUpdate_clone(&*owner->contents.result);
1124 }
1125 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
1126         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
1127         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
1128         uintptr_t ret_ref = 0;
1129         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1130         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1132         ret_ref = (uintptr_t)ret_var.inner;
1133         if (ret_var.is_owned) {
1134                 ret_ref |= 1;
1135         }
1136         return ret_ref;
1137 }
1138
1139 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
1140 CHECK(!owner->result_ok);
1141         return DecodeError_clone(&*owner->contents.err);
1142 }
1143 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
1144         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
1145         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
1146         uintptr_t ret_ref = 0;
1147         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1148         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1150         ret_ref = (uintptr_t)ret_var.inner;
1151         if (ret_var.is_owned) {
1152                 ret_ref |= 1;
1153         }
1154         return ret_ref;
1155 }
1156
1157 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1158 CHECK(owner->result_ok);
1159         return *owner->contents.result;
1160 }
1161 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
1162         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
1163         CResult_NoneNoneZ_get_ok(owner_conv);
1164 }
1165
1166 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1167 CHECK(!owner->result_ok);
1168         return *owner->contents.err;
1169 }
1170 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
1171         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
1172         CResult_NoneNoneZ_get_err(owner_conv);
1173 }
1174
1175 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
1176         return OutPoint_clone(&owner->a);
1177 }
1178 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
1179         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
1180         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
1181         uintptr_t ret_ref = 0;
1182         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1183         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1185         ret_ref = (uintptr_t)ret_var.inner;
1186         if (ret_var.is_owned) {
1187                 ret_ref |= 1;
1188         }
1189         return ret_ref;
1190 }
1191
1192 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
1193         return CVec_u8Z_clone(&owner->b);
1194 }
1195 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
1196         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
1197         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
1198         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1199         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1200         CVec_u8Z_free(ret_var);
1201         return ret_arr;
1202 }
1203
1204 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
1205         return owner->a;
1206 }
1207 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
1208         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
1209         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(owner_conv);
1210         return ret_val;
1211 }
1212
1213 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
1214         return CVec_u8Z_clone(&owner->b);
1215 }
1216 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
1217         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
1218         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
1219         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1220         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1221         CVec_u8Z_free(ret_var);
1222         return ret_arr;
1223 }
1224
1225 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
1226         return ThirtyTwoBytes_clone(&owner->a);
1227 }
1228 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
1229         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
1230         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
1231         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
1232         return ret_arr;
1233 }
1234
1235 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
1236         return owner->b;
1237 }
1238 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
1239         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
1240         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
1241         uint32_tArray ret_arr = NULL;
1242         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
1243         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
1244         for (size_t v = 0; v < ret_var.datalen; v++) {
1245                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = &ret_var.data[v];
1246                 // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_u32ScriptZ
1247                 ret_arr_ptr[v] = ((uintptr_t)ret_conv_21_conv) | 1;
1248         }
1249         
1250         return ret_arr;
1251 }
1252
1253 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1254         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1255         for (size_t i = 0; i < ret.datalen; i++) {
1256                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1257         }
1258         return ret;
1259 }
1260 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1261         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1262         switch(obj->tag) {
1263                 case LDKPaymentPurpose_InvoicePayment: return 0;
1264                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1265                 default: abort();
1266         }
1267 }
1268 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1269         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1270         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1271                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1272                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1273         return payment_preimage_arr;
1274 }
1275 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1276         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1277         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1278                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1279                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1280         return payment_secret_arr;
1281 }
1282 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1283         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1284         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1285                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1286                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1287         return spontaneous_payment_arr;
1288 }
1289 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1290         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1291         switch(obj->tag) {
1292                 case LDKCOption_u64Z_Some: return 0;
1293                 case LDKCOption_u64Z_None: return 1;
1294                 default: abort();
1295         }
1296 }
1297 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1298         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1299         assert(obj->tag == LDKCOption_u64Z_Some);
1300         return obj->some;
1301 }
1302 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1303         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1304         switch(obj->tag) {
1305                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1306                 case LDKNetworkUpdate_ChannelClosed: return 1;
1307                 case LDKNetworkUpdate_NodeFailure: return 2;
1308                 default: abort();
1309         }
1310 }
1311 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1312         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1313         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1314                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1315                         uintptr_t msg_ref = 0;
1316                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1317                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1318                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1319                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1320         return msg_ref;
1321 }
1322 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id(uint32_t ptr) {
1323         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1324         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1325         return obj->channel_closed.short_channel_id;
1326 }
1327 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent(uint32_t ptr) {
1328         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1329         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1330         return obj->channel_closed.is_permanent;
1331 }
1332 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1333         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1334         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1335                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1336                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1337         return node_id_arr;
1338 }
1339 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1340         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1341         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1342         return obj->node_failure.is_permanent;
1343 }
1344 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1345         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1346         switch(obj->tag) {
1347                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1348                 case LDKCOption_NetworkUpdateZ_None: return 1;
1349                 default: abort();
1350         }
1351 }
1352 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1353         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1354         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1355                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
1356         return some_ref;
1357 }
1358 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1359         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1360         for (size_t i = 0; i < ret.datalen; i++) {
1361                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1362         }
1363         return ret;
1364 }
1365 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1366         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1367         switch(obj->tag) {
1368                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1369                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1370                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1371                 default: abort();
1372         }
1373 }
1374 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1375         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1376         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1377                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1378                         uintptr_t outpoint_ref = 0;
1379                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1380                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1381                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1382                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1383         return outpoint_ref;
1384 }
1385 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1386         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1387         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1388                         uintptr_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1389         return (uintptr_t)output_ref;
1390 }
1391 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1392         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1393         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1394                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1395                         uintptr_t delayed_payment_output_ref = 0;
1396                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1397                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1398                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1399                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1400         return delayed_payment_output_ref;
1401 }
1402 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1403         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1404         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1405                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1406                         uintptr_t static_payment_output_ref = 0;
1407                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1408                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1409                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1410                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1411         return static_payment_output_ref;
1412 }
1413 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1414         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1415         for (size_t i = 0; i < ret.datalen; i++) {
1416                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1417         }
1418         return ret;
1419 }
1420 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1421         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1422         switch(obj->tag) {
1423                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1424                 case LDKClosureReason_HolderForceClosed: return 1;
1425                 case LDKClosureReason_CooperativeClosure: return 2;
1426                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1427                 case LDKClosureReason_FundingTimedOut: return 4;
1428                 case LDKClosureReason_ProcessingError: return 5;
1429                 case LDKClosureReason_DisconnectedPeer: return 6;
1430                 case LDKClosureReason_OutdatedChannelManager: return 7;
1431                 default: abort();
1432         }
1433 }
1434 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1435         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1436         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1437                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1438                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1439         return peer_msg_conv;
1440 }
1441 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1442         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1443         assert(obj->tag == LDKClosureReason_ProcessingError);
1444                         LDKStr err_str = obj->processing_error.err;
1445                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1446         return err_conv;
1447 }
1448 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1449         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1450         switch(obj->tag) {
1451                 case LDKEvent_FundingGenerationReady: return 0;
1452                 case LDKEvent_PaymentReceived: return 1;
1453                 case LDKEvent_PaymentSent: return 2;
1454                 case LDKEvent_PaymentPathFailed: return 3;
1455                 case LDKEvent_PaymentFailed: return 4;
1456                 case LDKEvent_PendingHTLCsForwardable: return 5;
1457                 case LDKEvent_SpendableOutputs: return 6;
1458                 case LDKEvent_PaymentForwarded: return 7;
1459                 case LDKEvent_ChannelClosed: return 8;
1460                 case LDKEvent_DiscardFunding: return 9;
1461                 case LDKEvent_PaymentPathSuccessful: return 10;
1462                 default: abort();
1463         }
1464 }
1465 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1466         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1467         assert(obj->tag == LDKEvent_FundingGenerationReady);
1468                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1469                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1470         return temporary_channel_id_arr;
1471 }
1472 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1473         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1474         assert(obj->tag == LDKEvent_FundingGenerationReady);
1475         return obj->funding_generation_ready.channel_value_satoshis;
1476 }
1477 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1478         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1479         assert(obj->tag == LDKEvent_FundingGenerationReady);
1480                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1481                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1482                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1483         return output_script_arr;
1484 }
1485 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1486         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1487         assert(obj->tag == LDKEvent_FundingGenerationReady);
1488         return obj->funding_generation_ready.user_channel_id;
1489 }
1490 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1491         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1492         assert(obj->tag == LDKEvent_PaymentReceived);
1493                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1494                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1495         return payment_hash_arr;
1496 }
1497 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amt"))) TS_LDKEvent_PaymentReceived_get_amt(uint32_t ptr) {
1498         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1499         assert(obj->tag == LDKEvent_PaymentReceived);
1500         return obj->payment_received.amt;
1501 }
1502 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1503         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1504         assert(obj->tag == LDKEvent_PaymentReceived);
1505                         uintptr_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1506         return purpose_ref;
1507 }
1508 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1509         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1510         assert(obj->tag == LDKEvent_PaymentSent);
1511                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1512                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1513         return payment_id_arr;
1514 }
1515 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1516         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1517         assert(obj->tag == LDKEvent_PaymentSent);
1518                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1519                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1520         return payment_preimage_arr;
1521 }
1522 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1523         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1524         assert(obj->tag == LDKEvent_PaymentSent);
1525                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1526                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1527         return payment_hash_arr;
1528 }
1529 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1530         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1531         assert(obj->tag == LDKEvent_PaymentSent);
1532                         uintptr_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1533         return fee_paid_msat_ref;
1534 }
1535 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1536         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1537         assert(obj->tag == LDKEvent_PaymentPathFailed);
1538                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1539                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1540         return payment_id_arr;
1541 }
1542 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1543         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1544         assert(obj->tag == LDKEvent_PaymentPathFailed);
1545                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1546                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1547         return payment_hash_arr;
1548 }
1549 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1550         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1551         assert(obj->tag == LDKEvent_PaymentPathFailed);
1552         return obj->payment_path_failed.rejected_by_dest;
1553 }
1554 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1555         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1556         assert(obj->tag == LDKEvent_PaymentPathFailed);
1557                         uintptr_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1558         return network_update_ref;
1559 }
1560 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1561         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1562         assert(obj->tag == LDKEvent_PaymentPathFailed);
1563         return obj->payment_path_failed.all_paths_failed;
1564 }
1565 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1566         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1567         assert(obj->tag == LDKEvent_PaymentPathFailed);
1568                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1569                         uint32_tArray path_arr = NULL;
1570                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1571                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1572                         for (size_t k = 0; k < path_var.datalen; k++) {
1573                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1574                                 uintptr_t path_conv_10_ref = 0;
1575                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1576                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1577                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1578                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1579                                 path_arr_ptr[k] = path_conv_10_ref;
1580                         }
1581                         
1582         return path_arr;
1583 }
1584 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1585         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1586         assert(obj->tag == LDKEvent_PaymentPathFailed);
1587                         uintptr_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1588         return short_channel_id_ref;
1589 }
1590 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1591         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1592         assert(obj->tag == LDKEvent_PaymentPathFailed);
1593                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1594                         uintptr_t retry_ref = 0;
1595                         if ((uintptr_t)retry_var.inner > 4096) {
1596                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1597                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1598                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1599                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1600                         }
1601         return retry_ref;
1602 }
1603 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1604         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1605         assert(obj->tag == LDKEvent_PaymentFailed);
1606                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1607                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1608         return payment_id_arr;
1609 }
1610 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1611         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1612         assert(obj->tag == LDKEvent_PaymentFailed);
1613                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1614                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1615         return payment_hash_arr;
1616 }
1617 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1618         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1619         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1620         return obj->pending_htl_cs_forwardable.time_forwardable;
1621 }
1622 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1623         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1624         assert(obj->tag == LDKEvent_SpendableOutputs);
1625                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1626                         uint32_tArray outputs_arr = NULL;
1627                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1628                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 4);
1629                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1630                                 uintptr_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1631                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1632                         }
1633                         
1634         return outputs_arr;
1635 }
1636 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1637         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1638         assert(obj->tag == LDKEvent_PaymentForwarded);
1639                         uintptr_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1640         return fee_earned_msat_ref;
1641 }
1642 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1643         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1644         assert(obj->tag == LDKEvent_PaymentForwarded);
1645         return obj->payment_forwarded.claim_from_onchain_tx;
1646 }
1647 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1648         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1649         assert(obj->tag == LDKEvent_ChannelClosed);
1650                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1651                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1652         return channel_id_arr;
1653 }
1654 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1655         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1656         assert(obj->tag == LDKEvent_ChannelClosed);
1657         return obj->channel_closed.user_channel_id;
1658 }
1659 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1660         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1661         assert(obj->tag == LDKEvent_ChannelClosed);
1662                         uintptr_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1663         return reason_ref;
1664 }
1665 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1666         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1667         assert(obj->tag == LDKEvent_DiscardFunding);
1668                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1669                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
1670         return channel_id_arr;
1671 }
1672 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
1673         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1674         assert(obj->tag == LDKEvent_DiscardFunding);
1675                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1676                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
1677                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
1678         return transaction_arr;
1679 }
1680 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1681         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1682         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1683                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1684                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1685         return payment_id_arr;
1686 }
1687 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1688         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1689         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1690                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1691                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1692         return payment_hash_arr;
1693 }
1694 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1695         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1696         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1697                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1698                         uint32_tArray path_arr = NULL;
1699                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1700                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1701                         for (size_t k = 0; k < path_var.datalen; k++) {
1702                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1703                                 uintptr_t path_conv_10_ref = 0;
1704                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1705                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1706                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1707                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1708                                 path_arr_ptr[k] = path_conv_10_ref;
1709                         }
1710                         
1711         return path_arr;
1712 }
1713 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
1714         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
1715         for (size_t i = 0; i < ret.datalen; i++) {
1716                 ret.data[i] = Event_clone(&orig->data[i]);
1717         }
1718         return ret;
1719 }
1720 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1721         return owner->a;
1722 }
1723 intptr_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
1724         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1725         intptr_t ret_val = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1726         return ret_val;
1727 }
1728
1729 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1730         return owner->b;
1731 }
1732 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
1733         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1734         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1735         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1736         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1737         return ret_arr;
1738 }
1739
1740 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1741         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1742         for (size_t i = 0; i < ret.datalen; i++) {
1743                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1744         }
1745         return ret;
1746 }
1747 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
1748         return owner->a;
1749 }
1750 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
1751         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
1752         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(owner_conv);
1753         return ret_val;
1754 }
1755
1756 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
1757         return TxOut_clone(&owner->b);
1758 }
1759 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
1760         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
1761         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1762         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
1763         return (uintptr_t)ret_ref;
1764 }
1765
1766 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
1767         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
1768         for (size_t i = 0; i < ret.datalen; i++) {
1769                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
1770         }
1771         return ret;
1772 }
1773 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
1774         return ThirtyTwoBytes_clone(&owner->a);
1775 }
1776 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
1777         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
1778         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
1779         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
1780         return ret_arr;
1781 }
1782
1783 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
1784         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
1785 }
1786 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
1787         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
1788         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
1789         uint32_tArray ret_arr = NULL;
1790         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
1791         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
1792         for (size_t u = 0; u < ret_var.datalen; u++) {
1793                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
1794                 *ret_conv_20_conv = ret_var.data[u];
1795                 ret_arr_ptr[u] = ((uintptr_t)ret_conv_20_conv);
1796         }
1797         
1798         FREE(ret_var.data);
1799         return ret_arr;
1800 }
1801
1802 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
1803         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 };
1804         for (size_t i = 0; i < ret.datalen; i++) {
1805                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
1806         }
1807         return ret;
1808 }
1809 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1810         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1811         for (size_t i = 0; i < ret.datalen; i++) {
1812                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1813         }
1814         return ret;
1815 }
1816 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
1817         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1818         switch(obj->tag) {
1819                 case LDKBalance_ClaimableOnChannelClose: return 0;
1820                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
1821                 case LDKBalance_ContentiousClaimable: return 2;
1822                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
1823                 default: abort();
1824         }
1825 }
1826 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
1827         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1828         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
1829         return obj->claimable_on_channel_close.claimable_amount_satoshis;
1830 }
1831 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
1832         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1833         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
1834         return obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
1835 }
1836 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
1837         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1838         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
1839         return obj->claimable_awaiting_confirmations.confirmation_height;
1840 }
1841 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
1842         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1843         assert(obj->tag == LDKBalance_ContentiousClaimable);
1844         return obj->contentious_claimable.claimable_amount_satoshis;
1845 }
1846 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
1847         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1848         assert(obj->tag == LDKBalance_ContentiousClaimable);
1849         return obj->contentious_claimable.timeout_height;
1850 }
1851 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
1852         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1853         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
1854         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
1855 }
1856 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
1857         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
1858         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
1859         return obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
1860 }
1861 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
1862         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
1863         for (size_t i = 0; i < ret.datalen; i++) {
1864                 ret.data[i] = Balance_clone(&orig->data[i]);
1865         }
1866         return ret;
1867 }
1868 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
1869         return owner->a;
1870 }
1871 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
1872         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
1873         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
1874         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
1875         return ret_arr;
1876 }
1877
1878 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
1879         return owner->b;
1880 }
1881 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
1882         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
1883         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
1884         ptrArray ret_arr = NULL;
1885         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
1886         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
1887         for (size_t m = 0; m < ret_var.datalen; m++) {
1888                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
1889                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
1890                 ret_arr_ptr[m] = ret_conv_12_arr;
1891         }
1892         
1893         return ret_arr;
1894 }
1895
1896 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
1897 CHECK(owner->result_ok);
1898         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
1899 }
1900 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
1901         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
1902         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
1903         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
1904         return ((uintptr_t)ret_conv);
1905 }
1906
1907 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
1908 CHECK(!owner->result_ok);
1909         return *owner->contents.err;
1910 }
1911 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
1912         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
1913         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
1914 }
1915
1916 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
1917 CHECK(owner->result_ok);
1918         return *owner->contents.result;
1919 }
1920 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
1921         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
1922         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
1923         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
1924         return ret_arr;
1925 }
1926
1927 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
1928 CHECK(!owner->result_ok);
1929         return *owner->contents.err;
1930 }
1931 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
1932         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
1933         CResult_SignatureNoneZ_get_err(owner_conv);
1934 }
1935
1936 typedef struct LDKBaseSign_JCalls {
1937         atomic_size_t refcnt;
1938         uint32_t instance_ptr;
1939 } LDKBaseSign_JCalls;
1940 static void LDKBaseSign_JCalls_free(void* this_arg) {
1941         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1942         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1943                 FREE(j_calls);
1944         }
1945 }
1946 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1947         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1948         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 3, (uint32_t)idx);
1949         LDKPublicKey ret_ref;
1950         CHECK(ret->arr_len == 33);
1951         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
1952         return ret_ref;
1953 }
1954 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
1955         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1956         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 4, (uint32_t)idx);
1957         LDKThirtyTwoBytes ret_ref;
1958         CHECK(ret->arr_len == 32);
1959         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
1960         return ret_ref;
1961 }
1962 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
1963         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1964         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
1965         uintptr_t holder_tx_ref = 0;
1966         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
1967         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1968         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1969         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
1970         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
1971         if (holder_tx_var.is_owned) {
1972                 holder_tx_ref |= 1;
1973         }
1974         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 5, (uint32_t)holder_tx_ref);
1975         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
1976         CHECK_ACCESS(ret_ptr);
1977         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
1978         FREE((void*)ret);
1979         return ret_conv;
1980 }
1981 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
1982         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1983         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 6);
1984         LDKThirtyTwoBytes ret_ref;
1985         CHECK(ret->arr_len == 32);
1986         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
1987         return ret_ref;
1988 }
1989 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1990         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
1991         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1992         uintptr_t commitment_tx_ref = 0;
1993         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1994         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1995         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1996         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
1997         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
1998         if (commitment_tx_var.is_owned) {
1999                 commitment_tx_ref |= 1;
2000         }
2001         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 7, (uint32_t)commitment_tx_ref);
2002         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2003         CHECK_ACCESS(ret_ptr);
2004         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2005         FREE((void*)ret);
2006         return ret_conv;
2007 }
2008 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
2009         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2010         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
2011         memcpy(secret_arr->elems, *secret, 32);
2012         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 8, (uint32_t)idx, (uint32_t)secret_arr);
2013         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2014         CHECK_ACCESS(ret_ptr);
2015         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2016         FREE((void*)ret);
2017         return ret_conv;
2018 }
2019 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2020         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2021         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2022         uintptr_t commitment_tx_ref = 0;
2023         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2024         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2025         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2026         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
2027         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
2028         if (commitment_tx_var.is_owned) {
2029                 commitment_tx_ref |= 1;
2030         }
2031         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 9, (uint32_t)commitment_tx_ref);
2032         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2033         CHECK_ACCESS(ret_ptr);
2034         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2035         FREE((void*)ret);
2036         return ret_conv;
2037 }
2038 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]) {
2039         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2040         LDKTransaction justice_tx_var = justice_tx;
2041         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
2042         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
2043         Transaction_free(justice_tx_var);
2044         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
2045         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
2046         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);
2047         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2048         CHECK_ACCESS(ret_ptr);
2049         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2050         FREE((void*)ret);
2051         return ret_conv;
2052 }
2053 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) {
2054         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2055         LDKTransaction justice_tx_var = justice_tx;
2056         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
2057         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
2058         Transaction_free(justice_tx_var);
2059         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
2060         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
2061         LDKHTLCOutputInCommitment htlc_var = *htlc;
2062         uintptr_t htlc_ref = 0;
2063         htlc_var = HTLCOutputInCommitment_clone(htlc);
2064         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2065         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2066         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
2067         htlc_ref = (uintptr_t)htlc_var.inner;
2068         if (htlc_var.is_owned) {
2069                 htlc_ref |= 1;
2070         }
2071         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);
2072         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2073         CHECK_ACCESS(ret_ptr);
2074         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2075         FREE((void*)ret);
2076         return ret_conv;
2077 }
2078 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) {
2079         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2080         LDKTransaction htlc_tx_var = htlc_tx;
2081         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
2082         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
2083         Transaction_free(htlc_tx_var);
2084         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
2085         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
2086         LDKHTLCOutputInCommitment htlc_var = *htlc;
2087         uintptr_t htlc_ref = 0;
2088         htlc_var = HTLCOutputInCommitment_clone(htlc);
2089         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2090         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2091         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
2092         htlc_ref = (uintptr_t)htlc_var.inner;
2093         if (htlc_var.is_owned) {
2094                 htlc_ref |= 1;
2095         }
2096         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);
2097         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2098         CHECK_ACCESS(ret_ptr);
2099         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2100         FREE((void*)ret);
2101         return ret_conv;
2102 }
2103 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
2104         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2105         LDKClosingTransaction closing_tx_var = *closing_tx;
2106         uintptr_t closing_tx_ref = 0;
2107         closing_tx_var = ClosingTransaction_clone(closing_tx);
2108         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2109         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2110         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
2111         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
2112         if (closing_tx_var.is_owned) {
2113                 closing_tx_ref |= 1;
2114         }
2115         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 13, (uint32_t)closing_tx_ref);
2116         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2117         CHECK_ACCESS(ret_ptr);
2118         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2119         FREE((void*)ret);
2120         return ret_conv;
2121 }
2122 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
2123         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2124         LDKUnsignedChannelAnnouncement msg_var = *msg;
2125         uintptr_t msg_ref = 0;
2126         msg_var = UnsignedChannelAnnouncement_clone(msg);
2127         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2128         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2129         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2130         msg_ref = (uintptr_t)msg_var.inner;
2131         if (msg_var.is_owned) {
2132                 msg_ref |= 1;
2133         }
2134         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 14, (uint32_t)msg_ref);
2135         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2136         CHECK_ACCESS(ret_ptr);
2137         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2138         FREE((void*)ret);
2139         return ret_conv;
2140 }
2141 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
2142         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2143         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
2144         uintptr_t channel_parameters_ref = 0;
2145         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
2146         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2147         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2148         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
2149         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
2150         if (channel_parameters_var.is_owned) {
2151                 channel_parameters_ref |= 1;
2152         }
2153         js_invoke_function_1(j_calls->instance_ptr, 15, (uint32_t)channel_parameters_ref);
2154 }
2155 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
2156         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
2157         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2158 }
2159 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
2160         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
2161         atomic_init(&calls->refcnt, 1);
2162         calls->instance_ptr = o;
2163
2164         LDKChannelPublicKeys pubkeys_conv;
2165         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2166         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2167         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2168
2169         LDKBaseSign ret = {
2170                 .this_arg = (void*) calls,
2171                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
2172                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
2173                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
2174                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
2175                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
2176                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
2177                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
2178                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
2179                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
2180                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
2181                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
2182                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
2183                 .ready_channel = ready_channel_LDKBaseSign_jcall,
2184                 .free = LDKBaseSign_JCalls_free,
2185                 .pubkeys = pubkeys_conv,
2186                 .set_pubkeys = NULL,
2187         };
2188         return ret;
2189 }
2190 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
2191         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
2192         *res_ptr = LDKBaseSign_init(o, pubkeys);
2193         return (long)res_ptr;
2194 }
2195 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
2196         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2197         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2198         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2199         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
2200         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
2201         return ret_arr;
2202 }
2203
2204 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
2205         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2206         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2207         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2208         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
2209         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
2210         return ret_arr;
2211 }
2212
2213 uint32_t  __attribute__((export_name("TS_BaseSign_validate_holder_commitment"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx) {
2214         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2215         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2216         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2217         LDKHolderCommitmentTransaction holder_tx_conv;
2218         holder_tx_conv.inner = (void*)(holder_tx & (~1));
2219         holder_tx_conv.is_owned = false;
2220         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
2221         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2222         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
2223         return (uintptr_t)ret_conv;
2224 }
2225
2226 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
2227         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2228         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2229         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2230         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
2231         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
2232         return ret_arr;
2233 }
2234
2235 uint32_t  __attribute__((export_name("TS_BaseSign_sign_counterparty_commitment"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
2236         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2237         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2238         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2239         LDKCommitmentTransaction commitment_tx_conv;
2240         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2241         commitment_tx_conv.is_owned = false;
2242         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2243         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2244         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
2245         return (uintptr_t)ret_conv;
2246 }
2247
2248 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) {
2249         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2250         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2251         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2252         unsigned char secret_arr[32];
2253         CHECK(secret->arr_len == 32);
2254         memcpy(secret_arr, secret->elems, 32); FREE(secret);
2255         unsigned char (*secret_ref)[32] = &secret_arr;
2256         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
2257         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
2258         return (uintptr_t)ret_conv;
2259 }
2260
2261 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) {
2262         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2263         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2264         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2265         LDKHolderCommitmentTransaction commitment_tx_conv;
2266         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
2267         commitment_tx_conv.is_owned = false;
2268         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
2269         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
2270         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
2271         return (uintptr_t)ret_conv;
2272 }
2273
2274 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) {
2275         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2276         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2277         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2278         LDKTransaction justice_tx_ref;
2279         justice_tx_ref.datalen = justice_tx->arr_len;
2280         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2281         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
2282         justice_tx_ref.data_is_owned = true;
2283         unsigned char per_commitment_key_arr[32];
2284         CHECK(per_commitment_key->arr_len == 32);
2285         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
2286         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2287         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2288         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
2289         return (uintptr_t)ret_conv;
2290 }
2291
2292 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) {
2293         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2294         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2295         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2296         LDKTransaction justice_tx_ref;
2297         justice_tx_ref.datalen = justice_tx->arr_len;
2298         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
2299         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
2300         justice_tx_ref.data_is_owned = true;
2301         unsigned char per_commitment_key_arr[32];
2302         CHECK(per_commitment_key->arr_len == 32);
2303         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
2304         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
2305         LDKHTLCOutputInCommitment htlc_conv;
2306         htlc_conv.inner = (void*)(htlc & (~1));
2307         htlc_conv.is_owned = false;
2308         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2309         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2310         *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);
2311         return (uintptr_t)ret_conv;
2312 }
2313
2314 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) {
2315         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2316         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2317         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2318         LDKTransaction htlc_tx_ref;
2319         htlc_tx_ref.datalen = htlc_tx->arr_len;
2320         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
2321         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
2322         htlc_tx_ref.data_is_owned = true;
2323         LDKPublicKey per_commitment_point_ref;
2324         CHECK(per_commitment_point->arr_len == 33);
2325         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
2326         LDKHTLCOutputInCommitment htlc_conv;
2327         htlc_conv.inner = (void*)(htlc & (~1));
2328         htlc_conv.is_owned = false;
2329         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
2330         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2331         *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);
2332         return (uintptr_t)ret_conv;
2333 }
2334
2335 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
2336         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2337         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2338         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2339         LDKClosingTransaction closing_tx_conv;
2340         closing_tx_conv.inner = (void*)(closing_tx & (~1));
2341         closing_tx_conv.is_owned = false;
2342         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
2343         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2344         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
2345         return (uintptr_t)ret_conv;
2346 }
2347
2348 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
2349         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2350         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2351         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2352         LDKUnsignedChannelAnnouncement msg_conv;
2353         msg_conv.inner = (void*)(msg & (~1));
2354         msg_conv.is_owned = false;
2355         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
2356         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
2357         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2358         return (uintptr_t)ret_conv;
2359 }
2360
2361 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
2362         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2363         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2364         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2365         LDKChannelTransactionParameters channel_parameters_conv;
2366         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
2367         channel_parameters_conv.is_owned = false;
2368         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
2369         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
2370 }
2371
2372 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
2373         if (this_arg->set_pubkeys != NULL)
2374                 this_arg->set_pubkeys(this_arg);
2375         return this_arg->pubkeys;
2376 }
2377 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
2378         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2379         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2380         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
2381         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
2382         uintptr_t ret_ref = 0;
2383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2386         ret_ref = (uintptr_t)ret_var.inner;
2387         if (ret_var.is_owned) {
2388                 ret_ref |= 1;
2389         }
2390         return ret_ref;
2391 }
2392
2393 typedef struct LDKSign_JCalls {
2394         atomic_size_t refcnt;
2395         uint32_t instance_ptr;
2396         LDKBaseSign_JCalls* BaseSign;
2397 } LDKSign_JCalls;
2398 static void LDKSign_JCalls_free(void* this_arg) {
2399         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2400         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2401                 FREE(j_calls);
2402         }
2403 }
2404 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
2405         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
2406         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 16);
2407         LDKCVec_u8Z ret_ref;
2408         ret_ref.datalen = ret->arr_len;
2409         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2410         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
2411         return ret_ref;
2412 }
2413 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
2414         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
2415         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2416         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
2417 }
2418 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
2419         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
2420         atomic_init(&calls->refcnt, 1);
2421         calls->instance_ptr = o;
2422
2423         LDKChannelPublicKeys pubkeys_conv;
2424         pubkeys_conv.inner = (void*)(pubkeys & (~1));
2425         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
2426         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
2427
2428         LDKSign ret = {
2429                 .this_arg = (void*) calls,
2430                 .write = write_LDKSign_jcall,
2431                 .cloned = LDKSign_JCalls_cloned,
2432                 .free = LDKSign_JCalls_free,
2433                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
2434         };
2435         calls->BaseSign = ret.BaseSign.this_arg;
2436         return ret;
2437 }
2438 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
2439         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
2440         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
2441         return (long)res_ptr;
2442 }
2443 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
2444         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2445         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2446         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
2447         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2448         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2449         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2450         CVec_u8Z_free(ret_var);
2451         return ret_arr;
2452 }
2453
2454 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
2455         return ThirtyTwoBytes_clone(&owner->a);
2456 }
2457 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
2458         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
2459         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
2460         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
2461         return ret_arr;
2462 }
2463
2464 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
2465         return ChannelMonitor_clone(&owner->b);
2466 }
2467 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
2468         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
2469         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
2470         uintptr_t ret_ref = 0;
2471         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2472         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2474         ret_ref = (uintptr_t)ret_var.inner;
2475         if (ret_var.is_owned) {
2476                 ret_ref |= 1;
2477         }
2478         return ret_ref;
2479 }
2480
2481 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
2482 CHECK(owner->result_ok);
2483         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
2484 }
2485 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
2486         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
2487         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
2488         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
2489         return ((uintptr_t)ret_conv);
2490 }
2491
2492 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
2493 CHECK(!owner->result_ok);
2494         return DecodeError_clone(&*owner->contents.err);
2495 }
2496 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
2497         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
2498         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
2499         uintptr_t ret_ref = 0;
2500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2503         ret_ref = (uintptr_t)ret_var.inner;
2504         if (ret_var.is_owned) {
2505                 ret_ref |= 1;
2506         }
2507         return ret_ref;
2508 }
2509
2510 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2511 CHECK(owner->result_ok);
2512         return RouteHop_clone(&*owner->contents.result);
2513 }
2514 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
2515         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
2516         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
2517         uintptr_t ret_ref = 0;
2518         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2519         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2521         ret_ref = (uintptr_t)ret_var.inner;
2522         if (ret_var.is_owned) {
2523                 ret_ref |= 1;
2524         }
2525         return ret_ref;
2526 }
2527
2528 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2529 CHECK(!owner->result_ok);
2530         return DecodeError_clone(&*owner->contents.err);
2531 }
2532 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
2533         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
2534         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
2535         uintptr_t ret_ref = 0;
2536         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2537         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2539         ret_ref = (uintptr_t)ret_var.inner;
2540         if (ret_var.is_owned) {
2541                 ret_ref |= 1;
2542         }
2543         return ret_ref;
2544 }
2545
2546 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2547         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2548         for (size_t i = 0; i < ret.datalen; i++) {
2549                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2550         }
2551         return ret;
2552 }
2553 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2554 CHECK(owner->result_ok);
2555         return Route_clone(&*owner->contents.result);
2556 }
2557 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
2558         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
2559         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
2560         uintptr_t ret_ref = 0;
2561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2564         ret_ref = (uintptr_t)ret_var.inner;
2565         if (ret_var.is_owned) {
2566                 ret_ref |= 1;
2567         }
2568         return ret_ref;
2569 }
2570
2571 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2572 CHECK(!owner->result_ok);
2573         return DecodeError_clone(&*owner->contents.err);
2574 }
2575 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
2576         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
2577         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
2578         uintptr_t ret_ref = 0;
2579         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2580         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2582         ret_ref = (uintptr_t)ret_var.inner;
2583         if (ret_var.is_owned) {
2584                 ret_ref |= 1;
2585         }
2586         return ret_ref;
2587 }
2588
2589 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2590 CHECK(owner->result_ok);
2591         return RouteParameters_clone(&*owner->contents.result);
2592 }
2593 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
2594         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
2595         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
2596         uintptr_t ret_ref = 0;
2597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2600         ret_ref = (uintptr_t)ret_var.inner;
2601         if (ret_var.is_owned) {
2602                 ret_ref |= 1;
2603         }
2604         return ret_ref;
2605 }
2606
2607 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2608 CHECK(!owner->result_ok);
2609         return DecodeError_clone(&*owner->contents.err);
2610 }
2611 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
2612         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
2613         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
2614         uintptr_t ret_ref = 0;
2615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2618         ret_ref = (uintptr_t)ret_var.inner;
2619         if (ret_var.is_owned) {
2620                 ret_ref |= 1;
2621         }
2622         return ret_ref;
2623 }
2624
2625 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2626         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2627         for (size_t i = 0; i < ret.datalen; i++) {
2628                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2629         }
2630         return ret;
2631 }
2632 static inline struct LDKPayee CResult_PayeeDecodeErrorZ_get_ok(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR owner){
2633 CHECK(owner->result_ok);
2634         return Payee_clone(&*owner->contents.result);
2635 }
2636 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_get_ok"))) TS_CResult_PayeeDecodeErrorZ_get_ok(uint32_t owner) {
2637         LDKCResult_PayeeDecodeErrorZ* owner_conv = (LDKCResult_PayeeDecodeErrorZ*)(owner & ~1);
2638         LDKPayee ret_var = CResult_PayeeDecodeErrorZ_get_ok(owner_conv);
2639         uintptr_t ret_ref = 0;
2640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2643         ret_ref = (uintptr_t)ret_var.inner;
2644         if (ret_var.is_owned) {
2645                 ret_ref |= 1;
2646         }
2647         return ret_ref;
2648 }
2649
2650 static inline struct LDKDecodeError CResult_PayeeDecodeErrorZ_get_err(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR owner){
2651 CHECK(!owner->result_ok);
2652         return DecodeError_clone(&*owner->contents.err);
2653 }
2654 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_get_err"))) TS_CResult_PayeeDecodeErrorZ_get_err(uint32_t owner) {
2655         LDKCResult_PayeeDecodeErrorZ* owner_conv = (LDKCResult_PayeeDecodeErrorZ*)(owner & ~1);
2656         LDKDecodeError ret_var = CResult_PayeeDecodeErrorZ_get_err(owner_conv);
2657         uintptr_t ret_ref = 0;
2658         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2659         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2661         ret_ref = (uintptr_t)ret_var.inner;
2662         if (ret_var.is_owned) {
2663                 ret_ref |= 1;
2664         }
2665         return ret_ref;
2666 }
2667
2668 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
2669         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
2670         for (size_t i = 0; i < ret.datalen; i++) {
2671                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
2672         }
2673         return ret;
2674 }
2675 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2676 CHECK(owner->result_ok);
2677         return RouteHint_clone(&*owner->contents.result);
2678 }
2679 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
2680         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
2681         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
2682         uintptr_t ret_ref = 0;
2683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2686         ret_ref = (uintptr_t)ret_var.inner;
2687         if (ret_var.is_owned) {
2688                 ret_ref |= 1;
2689         }
2690         return ret_ref;
2691 }
2692
2693 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2694 CHECK(!owner->result_ok);
2695         return DecodeError_clone(&*owner->contents.err);
2696 }
2697 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
2698         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
2699         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
2700         uintptr_t ret_ref = 0;
2701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2704         ret_ref = (uintptr_t)ret_var.inner;
2705         if (ret_var.is_owned) {
2706                 ret_ref |= 1;
2707         }
2708         return ret_ref;
2709 }
2710
2711 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2712 CHECK(owner->result_ok);
2713         return RouteHintHop_clone(&*owner->contents.result);
2714 }
2715 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
2716         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
2717         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
2718         uintptr_t ret_ref = 0;
2719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2722         ret_ref = (uintptr_t)ret_var.inner;
2723         if (ret_var.is_owned) {
2724                 ret_ref |= 1;
2725         }
2726         return ret_ref;
2727 }
2728
2729 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2730 CHECK(!owner->result_ok);
2731         return DecodeError_clone(&*owner->contents.err);
2732 }
2733 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
2734         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
2735         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
2736         uintptr_t ret_ref = 0;
2737         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2738         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2740         ret_ref = (uintptr_t)ret_var.inner;
2741         if (ret_var.is_owned) {
2742                 ret_ref |= 1;
2743         }
2744         return ret_ref;
2745 }
2746
2747 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2748         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2749         for (size_t i = 0; i < ret.datalen; i++) {
2750                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2751         }
2752         return ret;
2753 }
2754 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2755 CHECK(owner->result_ok);
2756         return Route_clone(&*owner->contents.result);
2757 }
2758 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
2759         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
2760         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
2761         uintptr_t ret_ref = 0;
2762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2765         ret_ref = (uintptr_t)ret_var.inner;
2766         if (ret_var.is_owned) {
2767                 ret_ref |= 1;
2768         }
2769         return ret_ref;
2770 }
2771
2772 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2773 CHECK(!owner->result_ok);
2774         return LightningError_clone(&*owner->contents.err);
2775 }
2776 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
2777         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
2778         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
2779         uintptr_t ret_ref = 0;
2780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2783         ret_ref = (uintptr_t)ret_var.inner;
2784         if (ret_var.is_owned) {
2785                 ret_ref |= 1;
2786         }
2787         return ret_ref;
2788 }
2789
2790 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
2791 CHECK(owner->result_ok);
2792         return *owner->contents.result;
2793 }
2794 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
2795         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
2796         CResult_NoneLightningErrorZ_get_ok(owner_conv);
2797 }
2798
2799 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
2800 CHECK(!owner->result_ok);
2801         return LightningError_clone(&*owner->contents.err);
2802 }
2803 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
2804         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
2805         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
2806         uintptr_t ret_ref = 0;
2807         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2808         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2810         ret_ref = (uintptr_t)ret_var.inner;
2811         if (ret_var.is_owned) {
2812                 ret_ref |= 1;
2813         }
2814         return ret_ref;
2815 }
2816
2817 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
2818         return owner->a;
2819 }
2820 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
2821         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
2822         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
2823         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
2824         return ret_arr;
2825 }
2826
2827 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
2828         return Type_clone(&owner->b);
2829 }
2830 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
2831         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
2832         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
2833         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
2834         return (uintptr_t)ret_ret;
2835 }
2836
2837 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
2838         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
2839         for (size_t i = 0; i < ret.datalen; i++) {
2840                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
2841         }
2842         return ret;
2843 }
2844 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
2845         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2846         switch(obj->tag) {
2847                 case LDKErrorAction_DisconnectPeer: return 0;
2848                 case LDKErrorAction_IgnoreError: return 1;
2849                 case LDKErrorAction_IgnoreAndLog: return 2;
2850                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
2851                 case LDKErrorAction_SendErrorMessage: return 4;
2852                 default: abort();
2853         }
2854 }
2855 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
2856         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2857         assert(obj->tag == LDKErrorAction_DisconnectPeer);
2858                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2859                         uintptr_t msg_ref = 0;
2860                         if ((uintptr_t)msg_var.inner > 4096) {
2861                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2862                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2863                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2864                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
2865                         }
2866         return msg_ref;
2867 }
2868 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
2869         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2870         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
2871                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
2872         return ignore_and_log_conv;
2873 }
2874 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
2875         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2876         assert(obj->tag == LDKErrorAction_SendErrorMessage);
2877                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2878                         uintptr_t msg_ref = 0;
2879                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2880                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2881                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2882                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2883         return msg_ref;
2884 }
2885 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
2886         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2887         switch(obj->tag) {
2888                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
2889                 case LDKMessageSendEvent_SendOpenChannel: return 1;
2890                 case LDKMessageSendEvent_SendFundingCreated: return 2;
2891                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2892                 case LDKMessageSendEvent_SendFundingLocked: return 4;
2893                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2894                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2895                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2896                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2897                 case LDKMessageSendEvent_SendShutdown: return 9;
2898                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2899                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
2900                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
2901                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2902                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2903                 case LDKMessageSendEvent_HandleError: return 15;
2904                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2905                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2906                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2907                 default: abort();
2908         }
2909 }
2910 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2911         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2912         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2913                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2914                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2915         return node_id_arr;
2916 }
2917 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2918         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2919         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2920                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2921                         uintptr_t msg_ref = 0;
2922                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2923                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2924                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2925                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2926         return msg_ref;
2927 }
2928 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2929         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2930         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2931                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2932                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2933         return node_id_arr;
2934 }
2935 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2936         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2937         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2938                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2939                         uintptr_t msg_ref = 0;
2940                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2941                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2942                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2943                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2944         return msg_ref;
2945 }
2946 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2947         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2948         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2949                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2950                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2951         return node_id_arr;
2952 }
2953 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2954         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2955         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2956                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2957                         uintptr_t msg_ref = 0;
2958                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2959                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2960                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2961                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2962         return msg_ref;
2963 }
2964 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2965         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2966         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2967                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2968                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2969         return node_id_arr;
2970 }
2971 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2972         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2973         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2974                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2975                         uintptr_t msg_ref = 0;
2976                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2977                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2978                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2979                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2980         return msg_ref;
2981 }
2982 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_node_id"))) TS_LDKMessageSendEvent_SendFundingLocked_get_node_id(uint32_t ptr) {
2983         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2984         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2985                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2986                         memcpy(node_id_arr->elems, obj->send_funding_locked.node_id.compressed_form, 33);
2987         return node_id_arr;
2988 }
2989 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_msg"))) TS_LDKMessageSendEvent_SendFundingLocked_get_msg(uint32_t ptr) {
2990         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2991         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2992                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2993                         uintptr_t msg_ref = 0;
2994                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2995                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2996                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2997                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2998         return msg_ref;
2999 }
3000 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
3001         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3002         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
3003                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3004                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
3005         return node_id_arr;
3006 }
3007 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
3008         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3009         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
3010                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
3011                         uintptr_t msg_ref = 0;
3012                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3013                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3014                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3015                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3016         return msg_ref;
3017 }
3018 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
3019         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3020         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
3021                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3022                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
3023         return node_id_arr;
3024 }
3025 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
3026         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3027         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
3028                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
3029                         uintptr_t updates_ref = 0;
3030                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3031                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3032                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
3033                         updates_ref = (uintptr_t)updates_var.inner & ~1;
3034         return updates_ref;
3035 }
3036 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
3037         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3038         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
3039                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3040                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
3041         return node_id_arr;
3042 }
3043 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
3044         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3045         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
3046                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
3047                         uintptr_t msg_ref = 0;
3048                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3049                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3050                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3051                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3052         return msg_ref;
3053 }
3054 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
3055         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3056         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
3057                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3058                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
3059         return node_id_arr;
3060 }
3061 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
3062         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3063         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
3064                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
3065                         uintptr_t msg_ref = 0;
3066                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3067                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3068                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3069                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3070         return msg_ref;
3071 }
3072 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
3073         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3074         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
3075                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3076                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
3077         return node_id_arr;
3078 }
3079 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
3080         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3081         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
3082                         LDKShutdown msg_var = obj->send_shutdown.msg;
3083                         uintptr_t msg_ref = 0;
3084                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3085                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3086                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3087                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3088         return msg_ref;
3089 }
3090 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
3091         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3092         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
3093                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3094                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
3095         return node_id_arr;
3096 }
3097 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
3098         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3099         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
3100                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3101                         uintptr_t msg_ref = 0;
3102                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3103                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3104                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3105                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3106         return msg_ref;
3107 }
3108 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
3109         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3110         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
3111                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
3112                         uintptr_t msg_ref = 0;
3113                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3114                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3115                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3116                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3117         return msg_ref;
3118 }
3119 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
3120         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3121         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
3122                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3123                         uintptr_t update_msg_ref = 0;
3124                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3125                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3126                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3127                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
3128         return update_msg_ref;
3129 }
3130 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
3131         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3132         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
3133                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
3134                         uintptr_t msg_ref = 0;
3135                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3136                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3137                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3138                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3139         return msg_ref;
3140 }
3141 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
3142         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3143         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
3144                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3145                         uintptr_t msg_ref = 0;
3146                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3147                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3148                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3149                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3150         return msg_ref;
3151 }
3152 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
3153         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3154         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
3155                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3156                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
3157         return node_id_arr;
3158 }
3159 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
3160         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3161         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
3162                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3163                         uintptr_t msg_ref = 0;
3164                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3165                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3166                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3167                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3168         return msg_ref;
3169 }
3170 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
3171         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3172         assert(obj->tag == LDKMessageSendEvent_HandleError);
3173                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3174                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
3175         return node_id_arr;
3176 }
3177 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
3178         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3179         assert(obj->tag == LDKMessageSendEvent_HandleError);
3180                         uintptr_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
3181         return action_ref;
3182 }
3183 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
3184         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3185         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
3186                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3187                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
3188         return node_id_arr;
3189 }
3190 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
3191         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3192         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
3193                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3194                         uintptr_t msg_ref = 0;
3195                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3196                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3197                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3198                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3199         return msg_ref;
3200 }
3201 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
3202         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3203         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
3204                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3205                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
3206         return node_id_arr;
3207 }
3208 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
3209         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3210         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
3211                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3212                         uintptr_t msg_ref = 0;
3213                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3214                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3215                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3216                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3217         return msg_ref;
3218 }
3219 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
3220         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3221         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
3222                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
3223                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
3224         return node_id_arr;
3225 }
3226 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
3227         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
3228         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
3229                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3230                         uintptr_t msg_ref = 0;
3231                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3232                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3233                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3234                         msg_ref = (uintptr_t)msg_var.inner & ~1;
3235         return msg_ref;
3236 }
3237 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3238         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3239         for (size_t i = 0; i < ret.datalen; i++) {
3240                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3241         }
3242         return ret;
3243 }
3244 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3245 CHECK(owner->result_ok);
3246         return *owner->contents.result;
3247 }
3248 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
3249         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3250         jboolean ret_val = CResult_boolLightningErrorZ_get_ok(owner_conv);
3251         return ret_val;
3252 }
3253
3254 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3255 CHECK(!owner->result_ok);
3256         return LightningError_clone(&*owner->contents.err);
3257 }
3258 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
3259         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3260         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3261         uintptr_t ret_ref = 0;
3262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3265         ret_ref = (uintptr_t)ret_var.inner;
3266         if (ret_var.is_owned) {
3267                 ret_ref |= 1;
3268         }
3269         return ret_ref;
3270 }
3271
3272 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3273         return ChannelAnnouncement_clone(&owner->a);
3274 }
3275 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
3276         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3277         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3278         uintptr_t ret_ref = 0;
3279         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3280         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3282         ret_ref = (uintptr_t)ret_var.inner;
3283         if (ret_var.is_owned) {
3284                 ret_ref |= 1;
3285         }
3286         return ret_ref;
3287 }
3288
3289 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3290         return ChannelUpdate_clone(&owner->b);
3291 }
3292 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
3293         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3294         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3295         uintptr_t ret_ref = 0;
3296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3299         ret_ref = (uintptr_t)ret_var.inner;
3300         if (ret_var.is_owned) {
3301                 ret_ref |= 1;
3302         }
3303         return ret_ref;
3304 }
3305
3306 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3307         return ChannelUpdate_clone(&owner->c);
3308 }
3309 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
3310         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3311         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3312         uintptr_t ret_ref = 0;
3313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3316         ret_ref = (uintptr_t)ret_var.inner;
3317         if (ret_var.is_owned) {
3318                 ret_ref |= 1;
3319         }
3320         return ret_ref;
3321 }
3322
3323 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3324         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3325         for (size_t i = 0; i < ret.datalen; i++) {
3326                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3327         }
3328         return ret;
3329 }
3330 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3331         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3332         for (size_t i = 0; i < ret.datalen; i++) {
3333                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3334         }
3335         return ret;
3336 }
3337 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
3338 CHECK(owner->result_ok);
3339         return CVec_u8Z_clone(&*owner->contents.result);
3340 }
3341 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
3342         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
3343         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
3344         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3345         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3346         CVec_u8Z_free(ret_var);
3347         return ret_arr;
3348 }
3349
3350 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
3351 CHECK(!owner->result_ok);
3352         return PeerHandleError_clone(&*owner->contents.err);
3353 }
3354 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
3355         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
3356         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
3357         uintptr_t ret_ref = 0;
3358         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3359         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3361         ret_ref = (uintptr_t)ret_var.inner;
3362         if (ret_var.is_owned) {
3363                 ret_ref |= 1;
3364         }
3365         return ret_ref;
3366 }
3367
3368 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
3369 CHECK(owner->result_ok);
3370         return *owner->contents.result;
3371 }
3372 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
3373         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
3374         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
3375 }
3376
3377 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
3378 CHECK(!owner->result_ok);
3379         return PeerHandleError_clone(&*owner->contents.err);
3380 }
3381 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
3382         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
3383         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
3384         uintptr_t ret_ref = 0;
3385         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3386         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3388         ret_ref = (uintptr_t)ret_var.inner;
3389         if (ret_var.is_owned) {
3390                 ret_ref |= 1;
3391         }
3392         return ret_ref;
3393 }
3394
3395 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
3396 CHECK(owner->result_ok);
3397         return *owner->contents.result;
3398 }
3399 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
3400         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
3401         jboolean ret_val = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
3402         return ret_val;
3403 }
3404
3405 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
3406 CHECK(!owner->result_ok);
3407         return PeerHandleError_clone(&*owner->contents.err);
3408 }
3409 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
3410         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
3411         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
3412         uintptr_t ret_ref = 0;
3413         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3414         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3416         ret_ref = (uintptr_t)ret_var.inner;
3417         if (ret_var.is_owned) {
3418                 ret_ref |= 1;
3419         }
3420         return ret_ref;
3421 }
3422
3423 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3424 CHECK(owner->result_ok);
3425         return TxOut_clone(&*owner->contents.result);
3426 }
3427 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
3428         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3429         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3430         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3431         return (uintptr_t)ret_ref;
3432 }
3433
3434 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3435 CHECK(!owner->result_ok);
3436         return AccessError_clone(&*owner->contents.err);
3437 }
3438 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
3439         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
3440         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
3441         return ret_conv;
3442 }
3443
3444 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3445 CHECK(owner->result_ok);
3446         return *owner->contents.result;
3447 }
3448 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
3449         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3450         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
3451 }
3452
3453 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3454 CHECK(!owner->result_ok);
3455         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
3456 }
3457 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
3458         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
3459         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
3460         return ret_conv;
3461 }
3462
3463 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
3464         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
3465         switch(obj->tag) {
3466                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
3467                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
3468                 default: abort();
3469         }
3470 }
3471 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
3472         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
3473         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
3474                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
3475                         *some_conv = obj->some;
3476                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
3477         return ((uintptr_t)some_conv);
3478 }
3479 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
3480         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
3481         switch(obj->tag) {
3482                 case LDKCOption_ClosureReasonZ_Some: return 0;
3483                 case LDKCOption_ClosureReasonZ_None: return 1;
3484                 default: abort();
3485         }
3486 }
3487 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
3488         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
3489         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
3490                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
3491         return some_ref;
3492 }
3493 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
3494 CHECK(owner->result_ok);
3495         return COption_ClosureReasonZ_clone(&*owner->contents.result);
3496 }
3497 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
3498         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
3499         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
3500         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
3501         uintptr_t ret_ref = (uintptr_t)ret_copy;
3502         return ret_ref;
3503 }
3504
3505 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
3506 CHECK(!owner->result_ok);
3507         return DecodeError_clone(&*owner->contents.err);
3508 }
3509 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
3510         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
3511         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
3512         uintptr_t ret_ref = 0;
3513         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3514         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3516         ret_ref = (uintptr_t)ret_var.inner;
3517         if (ret_var.is_owned) {
3518                 ret_ref |= 1;
3519         }
3520         return ret_ref;
3521 }
3522
3523 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
3524         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
3525         switch(obj->tag) {
3526                 case LDKCOption_EventZ_Some: return 0;
3527                 case LDKCOption_EventZ_None: return 1;
3528                 default: abort();
3529         }
3530 }
3531 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
3532         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
3533         assert(obj->tag == LDKCOption_EventZ_Some);
3534                         uintptr_t some_ref = ((uintptr_t)&obj->some) | 1;
3535         return some_ref;
3536 }
3537 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3538 CHECK(owner->result_ok);
3539         return COption_EventZ_clone(&*owner->contents.result);
3540 }
3541 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
3542         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
3543         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
3544         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
3545         uintptr_t ret_ref = (uintptr_t)ret_copy;
3546         return ret_ref;
3547 }
3548
3549 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3550 CHECK(!owner->result_ok);
3551         return DecodeError_clone(&*owner->contents.err);
3552 }
3553 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
3554         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
3555         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
3556         uintptr_t ret_ref = 0;
3557         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3558         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3560         ret_ref = (uintptr_t)ret_var.inner;
3561         if (ret_var.is_owned) {
3562                 ret_ref |= 1;
3563         }
3564         return ret_ref;
3565 }
3566
3567 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3568 CHECK(owner->result_ok);
3569         return NodeId_clone(&*owner->contents.result);
3570 }
3571 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
3572         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3573         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
3574         uintptr_t ret_ref = 0;
3575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3578         ret_ref = (uintptr_t)ret_var.inner;
3579         if (ret_var.is_owned) {
3580                 ret_ref |= 1;
3581         }
3582         return ret_ref;
3583 }
3584
3585 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
3586 CHECK(!owner->result_ok);
3587         return DecodeError_clone(&*owner->contents.err);
3588 }
3589 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
3590         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
3591         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
3592         uintptr_t ret_ref = 0;
3593         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3594         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3596         ret_ref = (uintptr_t)ret_var.inner;
3597         if (ret_var.is_owned) {
3598                 ret_ref |= 1;
3599         }
3600         return ret_ref;
3601 }
3602
3603 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3604 CHECK(owner->result_ok);
3605         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
3606 }
3607 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
3608         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3609         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
3610         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
3611         uintptr_t ret_ref = (uintptr_t)ret_copy;
3612         return ret_ref;
3613 }
3614
3615 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
3616 CHECK(!owner->result_ok);
3617         return DecodeError_clone(&*owner->contents.err);
3618 }
3619 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
3620         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
3621         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
3622         uintptr_t ret_ref = 0;
3623         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3624         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3626         ret_ref = (uintptr_t)ret_var.inner;
3627         if (ret_var.is_owned) {
3628                 ret_ref |= 1;
3629         }
3630         return ret_ref;
3631 }
3632
3633 typedef struct LDKAccess_JCalls {
3634         atomic_size_t refcnt;
3635         uint32_t instance_ptr;
3636 } LDKAccess_JCalls;
3637 static void LDKAccess_JCalls_free(void* this_arg) {
3638         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3639         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3640                 FREE(j_calls);
3641         }
3642 }
3643 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3644         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3645         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
3646         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
3647         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 17, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id);
3648         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3649         CHECK_ACCESS(ret_ptr);
3650         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
3651         FREE((void*)ret);
3652         return ret_conv;
3653 }
3654 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
3655         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
3656         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3657 }
3658 static inline LDKAccess LDKAccess_init (JSValue o) {
3659         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3660         atomic_init(&calls->refcnt, 1);
3661         calls->instance_ptr = o;
3662
3663         LDKAccess ret = {
3664                 .this_arg = (void*) calls,
3665                 .get_utxo = get_utxo_LDKAccess_jcall,
3666                 .free = LDKAccess_JCalls_free,
3667         };
3668         return ret;
3669 }
3670 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
3671         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3672         *res_ptr = LDKAccess_init(o);
3673         return (long)res_ptr;
3674 }
3675 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) {
3676         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3677         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3678         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
3679         unsigned char genesis_hash_arr[32];
3680         CHECK(genesis_hash->arr_len == 32);
3681         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
3682         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3683         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3684         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3685         return (uintptr_t)ret_conv;
3686 }
3687
3688 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
3689         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3690         switch(obj->tag) {
3691                 case LDKCOption_AccessZ_Some: return 0;
3692                 case LDKCOption_AccessZ_None: return 1;
3693                 default: abort();
3694         }
3695 }
3696 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
3697         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
3698         assert(obj->tag == LDKCOption_AccessZ_Some);
3699                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3700                         *some_ret = obj->some;
3701                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
3702         return (uintptr_t)some_ret;
3703 }
3704 static inline struct LDKDirectionalChannelInfo CResult_DirectionalChannelInfoDecodeErrorZ_get_ok(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3705 CHECK(owner->result_ok);
3706         return DirectionalChannelInfo_clone(&*owner->contents.result);
3707 }
3708 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
3709         LDKCResult_DirectionalChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(owner & ~1);
3710         LDKDirectionalChannelInfo ret_var = CResult_DirectionalChannelInfoDecodeErrorZ_get_ok(owner_conv);
3711         uintptr_t ret_ref = 0;
3712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3715         ret_ref = (uintptr_t)ret_var.inner;
3716         if (ret_var.is_owned) {
3717                 ret_ref |= 1;
3718         }
3719         return ret_ref;
3720 }
3721
3722 static inline struct LDKDecodeError CResult_DirectionalChannelInfoDecodeErrorZ_get_err(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3723 CHECK(!owner->result_ok);
3724         return DecodeError_clone(&*owner->contents.err);
3725 }
3726 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_get_err"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
3727         LDKCResult_DirectionalChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(owner & ~1);
3728         LDKDecodeError ret_var = CResult_DirectionalChannelInfoDecodeErrorZ_get_err(owner_conv);
3729         uintptr_t ret_ref = 0;
3730         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3731         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3733         ret_ref = (uintptr_t)ret_var.inner;
3734         if (ret_var.is_owned) {
3735                 ret_ref |= 1;
3736         }
3737         return ret_ref;
3738 }
3739
3740 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3741 CHECK(owner->result_ok);
3742         return ChannelInfo_clone(&*owner->contents.result);
3743 }
3744 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
3745         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3746         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
3747         uintptr_t ret_ref = 0;
3748         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3749         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3751         ret_ref = (uintptr_t)ret_var.inner;
3752         if (ret_var.is_owned) {
3753                 ret_ref |= 1;
3754         }
3755         return ret_ref;
3756 }
3757
3758 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3759 CHECK(!owner->result_ok);
3760         return DecodeError_clone(&*owner->contents.err);
3761 }
3762 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
3763         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3764         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
3765         uintptr_t ret_ref = 0;
3766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3769         ret_ref = (uintptr_t)ret_var.inner;
3770         if (ret_var.is_owned) {
3771                 ret_ref |= 1;
3772         }
3773         return ret_ref;
3774 }
3775
3776 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3777 CHECK(owner->result_ok);
3778         return RoutingFees_clone(&*owner->contents.result);
3779 }
3780 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
3781         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3782         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
3783         uintptr_t ret_ref = 0;
3784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3787         ret_ref = (uintptr_t)ret_var.inner;
3788         if (ret_var.is_owned) {
3789                 ret_ref |= 1;
3790         }
3791         return ret_ref;
3792 }
3793
3794 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3795 CHECK(!owner->result_ok);
3796         return DecodeError_clone(&*owner->contents.err);
3797 }
3798 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
3799         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3800         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
3801         uintptr_t ret_ref = 0;
3802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3805         ret_ref = (uintptr_t)ret_var.inner;
3806         if (ret_var.is_owned) {
3807                 ret_ref |= 1;
3808         }
3809         return ret_ref;
3810 }
3811
3812 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3813         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3814         switch(obj->tag) {
3815                 case LDKNetAddress_IPv4: return 0;
3816                 case LDKNetAddress_IPv6: return 1;
3817                 case LDKNetAddress_OnionV2: return 2;
3818                 case LDKNetAddress_OnionV3: return 3;
3819                 default: abort();
3820         }
3821 }
3822 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3823         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3824         assert(obj->tag == LDKNetAddress_IPv4);
3825                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3826                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3827         return addr_arr;
3828 }
3829 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3830         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3831         assert(obj->tag == LDKNetAddress_IPv4);
3832         return obj->i_pv4.port;
3833 }
3834 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3835         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3836         assert(obj->tag == LDKNetAddress_IPv6);
3837                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
3838                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3839         return addr_arr;
3840 }
3841 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
3842         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3843         assert(obj->tag == LDKNetAddress_IPv6);
3844         return obj->i_pv6.port;
3845 }
3846 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
3847         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3848         assert(obj->tag == LDKNetAddress_OnionV2);
3849                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
3850                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
3851         return onion_v2_arr;
3852 }
3853 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
3854         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3855         assert(obj->tag == LDKNetAddress_OnionV3);
3856                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
3857                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
3858         return ed25519_pubkey_arr;
3859 }
3860 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
3861         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3862         assert(obj->tag == LDKNetAddress_OnionV3);
3863         return obj->onion_v3.checksum;
3864 }
3865 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
3866         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3867         assert(obj->tag == LDKNetAddress_OnionV3);
3868         return obj->onion_v3.version;
3869 }
3870 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
3871         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3872         assert(obj->tag == LDKNetAddress_OnionV3);
3873         return obj->onion_v3.port;
3874 }
3875 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3876         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3877         for (size_t i = 0; i < ret.datalen; i++) {
3878                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3879         }
3880         return ret;
3881 }
3882 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3883 CHECK(owner->result_ok);
3884         return NodeAnnouncementInfo_clone(&*owner->contents.result);
3885 }
3886 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
3887         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3888         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
3889         uintptr_t ret_ref = 0;
3890         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3891         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3893         ret_ref = (uintptr_t)ret_var.inner;
3894         if (ret_var.is_owned) {
3895                 ret_ref |= 1;
3896         }
3897         return ret_ref;
3898 }
3899
3900 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3901 CHECK(!owner->result_ok);
3902         return DecodeError_clone(&*owner->contents.err);
3903 }
3904 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
3905         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3906         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
3907         uintptr_t ret_ref = 0;
3908         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3909         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3911         ret_ref = (uintptr_t)ret_var.inner;
3912         if (ret_var.is_owned) {
3913                 ret_ref |= 1;
3914         }
3915         return ret_ref;
3916 }
3917
3918 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3919         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3920         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3921         return ret;
3922 }
3923 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3924 CHECK(owner->result_ok);
3925         return NodeInfo_clone(&*owner->contents.result);
3926 }
3927 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
3928         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3929         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
3930         uintptr_t ret_ref = 0;
3931         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3932         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3934         ret_ref = (uintptr_t)ret_var.inner;
3935         if (ret_var.is_owned) {
3936                 ret_ref |= 1;
3937         }
3938         return ret_ref;
3939 }
3940
3941 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3942 CHECK(!owner->result_ok);
3943         return DecodeError_clone(&*owner->contents.err);
3944 }
3945 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
3946         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3947         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
3948         uintptr_t ret_ref = 0;
3949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3952         ret_ref = (uintptr_t)ret_var.inner;
3953         if (ret_var.is_owned) {
3954                 ret_ref |= 1;
3955         }
3956         return ret_ref;
3957 }
3958
3959 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3960 CHECK(owner->result_ok);
3961         return NetworkGraph_clone(&*owner->contents.result);
3962 }
3963 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
3964         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3965         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
3966         uintptr_t ret_ref = 0;
3967         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3968         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3970         ret_ref = (uintptr_t)ret_var.inner;
3971         if (ret_var.is_owned) {
3972                 ret_ref |= 1;
3973         }
3974         return ret_ref;
3975 }
3976
3977 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3978 CHECK(!owner->result_ok);
3979         return DecodeError_clone(&*owner->contents.err);
3980 }
3981 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
3982         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3983         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
3984         uintptr_t ret_ref = 0;
3985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3988         ret_ref = (uintptr_t)ret_var.inner;
3989         if (ret_var.is_owned) {
3990                 ret_ref |= 1;
3991         }
3992         return ret_ref;
3993 }
3994
3995 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
3996         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3997         switch(obj->tag) {
3998                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
3999                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
4000                 default: abort();
4001         }
4002 }
4003 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
4004         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
4005         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
4006                         LDKCVec_NetAddressZ some_var = obj->some;
4007                         uint32_tArray some_arr = NULL;
4008                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
4009                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
4010                         for (size_t m = 0; m < some_var.datalen; m++) {
4011                                 uintptr_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
4012                                 some_arr_ptr[m] = some_conv_12_ref;
4013                         }
4014                         
4015         return some_arr;
4016 }
4017 static inline struct LDKScoringParameters *CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
4018 CHECK(owner->result_ok);
4019         return &*owner->contents.result;
4020 }
4021 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t owner) {
4022         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
4023         LDKScoringParameters ret_var = *CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
4024         uintptr_t ret_ref = 0;
4025         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4026         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4028         ret_ref = (uintptr_t)ret_var.inner & ~1;
4029         return ret_ref;
4030 }
4031
4032 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
4033 CHECK(!owner->result_ok);
4034         return DecodeError_clone(&*owner->contents.err);
4035 }
4036 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_err"))) TS_CResult_ScoringParametersDecodeErrorZ_get_err(uint32_t owner) {
4037         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
4038         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
4039         uintptr_t ret_ref = 0;
4040         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4041         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4042         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4043         ret_ref = (uintptr_t)ret_var.inner;
4044         if (ret_var.is_owned) {
4045                 ret_ref |= 1;
4046         }
4047         return ret_ref;
4048 }
4049
4050 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4051 CHECK(owner->result_ok);
4052         return InitFeatures_clone(&*owner->contents.result);
4053 }
4054 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4055         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
4056         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
4057         uintptr_t ret_ref = 0;
4058         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4059         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4061         ret_ref = (uintptr_t)ret_var.inner;
4062         if (ret_var.is_owned) {
4063                 ret_ref |= 1;
4064         }
4065         return ret_ref;
4066 }
4067
4068 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4069 CHECK(!owner->result_ok);
4070         return DecodeError_clone(&*owner->contents.err);
4071 }
4072 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4073         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
4074         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
4075         uintptr_t ret_ref = 0;
4076         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4077         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4079         ret_ref = (uintptr_t)ret_var.inner;
4080         if (ret_var.is_owned) {
4081                 ret_ref |= 1;
4082         }
4083         return ret_ref;
4084 }
4085
4086 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4087 CHECK(owner->result_ok);
4088         return ChannelFeatures_clone(&*owner->contents.result);
4089 }
4090 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4091         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
4092         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
4093         uintptr_t ret_ref = 0;
4094         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4095         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4097         ret_ref = (uintptr_t)ret_var.inner;
4098         if (ret_var.is_owned) {
4099                 ret_ref |= 1;
4100         }
4101         return ret_ref;
4102 }
4103
4104 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4105 CHECK(!owner->result_ok);
4106         return DecodeError_clone(&*owner->contents.err);
4107 }
4108 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4109         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
4110         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
4111         uintptr_t ret_ref = 0;
4112         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4113         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4115         ret_ref = (uintptr_t)ret_var.inner;
4116         if (ret_var.is_owned) {
4117                 ret_ref |= 1;
4118         }
4119         return ret_ref;
4120 }
4121
4122 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4123 CHECK(owner->result_ok);
4124         return NodeFeatures_clone(&*owner->contents.result);
4125 }
4126 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4127         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
4128         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
4129         uintptr_t ret_ref = 0;
4130         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4131         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4133         ret_ref = (uintptr_t)ret_var.inner;
4134         if (ret_var.is_owned) {
4135                 ret_ref |= 1;
4136         }
4137         return ret_ref;
4138 }
4139
4140 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4141 CHECK(!owner->result_ok);
4142         return DecodeError_clone(&*owner->contents.err);
4143 }
4144 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4145         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
4146         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
4147         uintptr_t ret_ref = 0;
4148         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4149         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4150         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4151         ret_ref = (uintptr_t)ret_var.inner;
4152         if (ret_var.is_owned) {
4153                 ret_ref |= 1;
4154         }
4155         return ret_ref;
4156 }
4157
4158 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4159 CHECK(owner->result_ok);
4160         return InvoiceFeatures_clone(&*owner->contents.result);
4161 }
4162 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4163         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
4164         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
4165         uintptr_t ret_ref = 0;
4166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4169         ret_ref = (uintptr_t)ret_var.inner;
4170         if (ret_var.is_owned) {
4171                 ret_ref |= 1;
4172         }
4173         return ret_ref;
4174 }
4175
4176 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4177 CHECK(!owner->result_ok);
4178         return DecodeError_clone(&*owner->contents.err);
4179 }
4180 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4181         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
4182         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
4183         uintptr_t ret_ref = 0;
4184         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4185         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4187         ret_ref = (uintptr_t)ret_var.inner;
4188         if (ret_var.is_owned) {
4189                 ret_ref |= 1;
4190         }
4191         return ret_ref;
4192 }
4193
4194 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4195 CHECK(owner->result_ok);
4196         return ChannelTypeFeatures_clone(&*owner->contents.result);
4197 }
4198 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
4199         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
4200         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
4201         uintptr_t ret_ref = 0;
4202         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4203         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4205         ret_ref = (uintptr_t)ret_var.inner;
4206         if (ret_var.is_owned) {
4207                 ret_ref |= 1;
4208         }
4209         return ret_ref;
4210 }
4211
4212 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4213 CHECK(!owner->result_ok);
4214         return DecodeError_clone(&*owner->contents.err);
4215 }
4216 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
4217         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
4218         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
4219         uintptr_t ret_ref = 0;
4220         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4221         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4223         ret_ref = (uintptr_t)ret_var.inner;
4224         if (ret_var.is_owned) {
4225                 ret_ref |= 1;
4226         }
4227         return ret_ref;
4228 }
4229
4230 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
4231 CHECK(owner->result_ok);
4232         return NetAddress_clone(&*owner->contents.result);
4233 }
4234 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
4235         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
4236         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
4237         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
4238         uintptr_t ret_ref = (uintptr_t)ret_copy;
4239         return ret_ref;
4240 }
4241
4242 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
4243 CHECK(!owner->result_ok);
4244         return DecodeError_clone(&*owner->contents.err);
4245 }
4246 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
4247         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
4248         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
4249         uintptr_t ret_ref = 0;
4250         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4251         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4253         ret_ref = (uintptr_t)ret_var.inner;
4254         if (ret_var.is_owned) {
4255                 ret_ref |= 1;
4256         }
4257         return ret_ref;
4258 }
4259
4260 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
4261         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
4262         for (size_t i = 0; i < ret.datalen; i++) {
4263                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
4264         }
4265         return ret;
4266 }
4267 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
4268         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
4269         for (size_t i = 0; i < ret.datalen; i++) {
4270                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
4271         }
4272         return ret;
4273 }
4274 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
4275         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
4276         for (size_t i = 0; i < ret.datalen; i++) {
4277                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
4278         }
4279         return ret;
4280 }
4281 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
4282         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
4283         for (size_t i = 0; i < ret.datalen; i++) {
4284                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
4285         }
4286         return ret;
4287 }
4288 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
4289 CHECK(owner->result_ok);
4290         return AcceptChannel_clone(&*owner->contents.result);
4291 }
4292 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
4293         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
4294         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
4295         uintptr_t ret_ref = 0;
4296         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4297         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4299         ret_ref = (uintptr_t)ret_var.inner;
4300         if (ret_var.is_owned) {
4301                 ret_ref |= 1;
4302         }
4303         return ret_ref;
4304 }
4305
4306 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
4307 CHECK(!owner->result_ok);
4308         return DecodeError_clone(&*owner->contents.err);
4309 }
4310 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
4311         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
4312         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
4313         uintptr_t ret_ref = 0;
4314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4317         ret_ref = (uintptr_t)ret_var.inner;
4318         if (ret_var.is_owned) {
4319                 ret_ref |= 1;
4320         }
4321         return ret_ref;
4322 }
4323
4324 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
4325 CHECK(owner->result_ok);
4326         return AnnouncementSignatures_clone(&*owner->contents.result);
4327 }
4328 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
4329         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
4330         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
4331         uintptr_t ret_ref = 0;
4332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4335         ret_ref = (uintptr_t)ret_var.inner;
4336         if (ret_var.is_owned) {
4337                 ret_ref |= 1;
4338         }
4339         return ret_ref;
4340 }
4341
4342 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
4343 CHECK(!owner->result_ok);
4344         return DecodeError_clone(&*owner->contents.err);
4345 }
4346 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
4347         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
4348         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
4349         uintptr_t ret_ref = 0;
4350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4353         ret_ref = (uintptr_t)ret_var.inner;
4354         if (ret_var.is_owned) {
4355                 ret_ref |= 1;
4356         }
4357         return ret_ref;
4358 }
4359
4360 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
4361 CHECK(owner->result_ok);
4362         return ChannelReestablish_clone(&*owner->contents.result);
4363 }
4364 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
4365         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
4366         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
4367         uintptr_t ret_ref = 0;
4368         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4369         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4371         ret_ref = (uintptr_t)ret_var.inner;
4372         if (ret_var.is_owned) {
4373                 ret_ref |= 1;
4374         }
4375         return ret_ref;
4376 }
4377
4378 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
4379 CHECK(!owner->result_ok);
4380         return DecodeError_clone(&*owner->contents.err);
4381 }
4382 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
4383         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
4384         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
4385         uintptr_t ret_ref = 0;
4386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4389         ret_ref = (uintptr_t)ret_var.inner;
4390         if (ret_var.is_owned) {
4391                 ret_ref |= 1;
4392         }
4393         return ret_ref;
4394 }
4395
4396 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
4397 CHECK(owner->result_ok);
4398         return ClosingSigned_clone(&*owner->contents.result);
4399 }
4400 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
4401         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
4402         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
4403         uintptr_t ret_ref = 0;
4404         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4405         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4407         ret_ref = (uintptr_t)ret_var.inner;
4408         if (ret_var.is_owned) {
4409                 ret_ref |= 1;
4410         }
4411         return ret_ref;
4412 }
4413
4414 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
4415 CHECK(!owner->result_ok);
4416         return DecodeError_clone(&*owner->contents.err);
4417 }
4418 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
4419         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
4420         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
4421         uintptr_t ret_ref = 0;
4422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4425         ret_ref = (uintptr_t)ret_var.inner;
4426         if (ret_var.is_owned) {
4427                 ret_ref |= 1;
4428         }
4429         return ret_ref;
4430 }
4431
4432 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
4433 CHECK(owner->result_ok);
4434         return ClosingSignedFeeRange_clone(&*owner->contents.result);
4435 }
4436 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
4437         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
4438         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
4439         uintptr_t ret_ref = 0;
4440         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4441         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4443         ret_ref = (uintptr_t)ret_var.inner;
4444         if (ret_var.is_owned) {
4445                 ret_ref |= 1;
4446         }
4447         return ret_ref;
4448 }
4449
4450 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
4451 CHECK(!owner->result_ok);
4452         return DecodeError_clone(&*owner->contents.err);
4453 }
4454 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
4455         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
4456         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
4457         uintptr_t ret_ref = 0;
4458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4461         ret_ref = (uintptr_t)ret_var.inner;
4462         if (ret_var.is_owned) {
4463                 ret_ref |= 1;
4464         }
4465         return ret_ref;
4466 }
4467
4468 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
4469 CHECK(owner->result_ok);
4470         return CommitmentSigned_clone(&*owner->contents.result);
4471 }
4472 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
4473         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
4474         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
4475         uintptr_t ret_ref = 0;
4476         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4477         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4479         ret_ref = (uintptr_t)ret_var.inner;
4480         if (ret_var.is_owned) {
4481                 ret_ref |= 1;
4482         }
4483         return ret_ref;
4484 }
4485
4486 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
4487 CHECK(!owner->result_ok);
4488         return DecodeError_clone(&*owner->contents.err);
4489 }
4490 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
4491         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
4492         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
4493         uintptr_t ret_ref = 0;
4494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4497         ret_ref = (uintptr_t)ret_var.inner;
4498         if (ret_var.is_owned) {
4499                 ret_ref |= 1;
4500         }
4501         return ret_ref;
4502 }
4503
4504 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
4505 CHECK(owner->result_ok);
4506         return FundingCreated_clone(&*owner->contents.result);
4507 }
4508 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
4509         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
4510         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
4511         uintptr_t ret_ref = 0;
4512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4515         ret_ref = (uintptr_t)ret_var.inner;
4516         if (ret_var.is_owned) {
4517                 ret_ref |= 1;
4518         }
4519         return ret_ref;
4520 }
4521
4522 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
4523 CHECK(!owner->result_ok);
4524         return DecodeError_clone(&*owner->contents.err);
4525 }
4526 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
4527         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
4528         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
4529         uintptr_t ret_ref = 0;
4530         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4531         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4533         ret_ref = (uintptr_t)ret_var.inner;
4534         if (ret_var.is_owned) {
4535                 ret_ref |= 1;
4536         }
4537         return ret_ref;
4538 }
4539
4540 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
4541 CHECK(owner->result_ok);
4542         return FundingSigned_clone(&*owner->contents.result);
4543 }
4544 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
4545         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
4546         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
4547         uintptr_t ret_ref = 0;
4548         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4549         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4551         ret_ref = (uintptr_t)ret_var.inner;
4552         if (ret_var.is_owned) {
4553                 ret_ref |= 1;
4554         }
4555         return ret_ref;
4556 }
4557
4558 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
4559 CHECK(!owner->result_ok);
4560         return DecodeError_clone(&*owner->contents.err);
4561 }
4562 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
4563         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
4564         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
4565         uintptr_t ret_ref = 0;
4566         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4567         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4569         ret_ref = (uintptr_t)ret_var.inner;
4570         if (ret_var.is_owned) {
4571                 ret_ref |= 1;
4572         }
4573         return ret_ref;
4574 }
4575
4576 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
4577 CHECK(owner->result_ok);
4578         return FundingLocked_clone(&*owner->contents.result);
4579 }
4580 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_ok"))) TS_CResult_FundingLockedDecodeErrorZ_get_ok(uint32_t owner) {
4581         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
4582         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
4583         uintptr_t ret_ref = 0;
4584         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4585         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4587         ret_ref = (uintptr_t)ret_var.inner;
4588         if (ret_var.is_owned) {
4589                 ret_ref |= 1;
4590         }
4591         return ret_ref;
4592 }
4593
4594 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
4595 CHECK(!owner->result_ok);
4596         return DecodeError_clone(&*owner->contents.err);
4597 }
4598 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_err"))) TS_CResult_FundingLockedDecodeErrorZ_get_err(uint32_t owner) {
4599         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
4600         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
4601         uintptr_t ret_ref = 0;
4602         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4603         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4605         ret_ref = (uintptr_t)ret_var.inner;
4606         if (ret_var.is_owned) {
4607                 ret_ref |= 1;
4608         }
4609         return ret_ref;
4610 }
4611
4612 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
4613 CHECK(owner->result_ok);
4614         return Init_clone(&*owner->contents.result);
4615 }
4616 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
4617         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
4618         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
4619         uintptr_t ret_ref = 0;
4620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4623         ret_ref = (uintptr_t)ret_var.inner;
4624         if (ret_var.is_owned) {
4625                 ret_ref |= 1;
4626         }
4627         return ret_ref;
4628 }
4629
4630 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
4631 CHECK(!owner->result_ok);
4632         return DecodeError_clone(&*owner->contents.err);
4633 }
4634 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
4635         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
4636         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
4637         uintptr_t ret_ref = 0;
4638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4641         ret_ref = (uintptr_t)ret_var.inner;
4642         if (ret_var.is_owned) {
4643                 ret_ref |= 1;
4644         }
4645         return ret_ref;
4646 }
4647
4648 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
4649 CHECK(owner->result_ok);
4650         return OpenChannel_clone(&*owner->contents.result);
4651 }
4652 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
4653         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
4654         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
4655         uintptr_t ret_ref = 0;
4656         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4657         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4659         ret_ref = (uintptr_t)ret_var.inner;
4660         if (ret_var.is_owned) {
4661                 ret_ref |= 1;
4662         }
4663         return ret_ref;
4664 }
4665
4666 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
4667 CHECK(!owner->result_ok);
4668         return DecodeError_clone(&*owner->contents.err);
4669 }
4670 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
4671         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
4672         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
4673         uintptr_t ret_ref = 0;
4674         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4675         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4677         ret_ref = (uintptr_t)ret_var.inner;
4678         if (ret_var.is_owned) {
4679                 ret_ref |= 1;
4680         }
4681         return ret_ref;
4682 }
4683
4684 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
4685 CHECK(owner->result_ok);
4686         return RevokeAndACK_clone(&*owner->contents.result);
4687 }
4688 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
4689         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
4690         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
4691         uintptr_t ret_ref = 0;
4692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4695         ret_ref = (uintptr_t)ret_var.inner;
4696         if (ret_var.is_owned) {
4697                 ret_ref |= 1;
4698         }
4699         return ret_ref;
4700 }
4701
4702 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
4703 CHECK(!owner->result_ok);
4704         return DecodeError_clone(&*owner->contents.err);
4705 }
4706 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
4707         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
4708         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
4709         uintptr_t ret_ref = 0;
4710         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4711         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4713         ret_ref = (uintptr_t)ret_var.inner;
4714         if (ret_var.is_owned) {
4715                 ret_ref |= 1;
4716         }
4717         return ret_ref;
4718 }
4719
4720 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
4721 CHECK(owner->result_ok);
4722         return Shutdown_clone(&*owner->contents.result);
4723 }
4724 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
4725         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
4726         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
4727         uintptr_t ret_ref = 0;
4728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4731         ret_ref = (uintptr_t)ret_var.inner;
4732         if (ret_var.is_owned) {
4733                 ret_ref |= 1;
4734         }
4735         return ret_ref;
4736 }
4737
4738 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
4739 CHECK(!owner->result_ok);
4740         return DecodeError_clone(&*owner->contents.err);
4741 }
4742 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
4743         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
4744         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
4745         uintptr_t ret_ref = 0;
4746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4749         ret_ref = (uintptr_t)ret_var.inner;
4750         if (ret_var.is_owned) {
4751                 ret_ref |= 1;
4752         }
4753         return ret_ref;
4754 }
4755
4756 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
4757 CHECK(owner->result_ok);
4758         return UpdateFailHTLC_clone(&*owner->contents.result);
4759 }
4760 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
4761         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
4762         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
4763         uintptr_t ret_ref = 0;
4764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4767         ret_ref = (uintptr_t)ret_var.inner;
4768         if (ret_var.is_owned) {
4769                 ret_ref |= 1;
4770         }
4771         return ret_ref;
4772 }
4773
4774 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
4775 CHECK(!owner->result_ok);
4776         return DecodeError_clone(&*owner->contents.err);
4777 }
4778 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
4779         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
4780         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
4781         uintptr_t ret_ref = 0;
4782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4785         ret_ref = (uintptr_t)ret_var.inner;
4786         if (ret_var.is_owned) {
4787                 ret_ref |= 1;
4788         }
4789         return ret_ref;
4790 }
4791
4792 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
4793 CHECK(owner->result_ok);
4794         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
4795 }
4796 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
4797         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
4798         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
4799         uintptr_t ret_ref = 0;
4800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4803         ret_ref = (uintptr_t)ret_var.inner;
4804         if (ret_var.is_owned) {
4805                 ret_ref |= 1;
4806         }
4807         return ret_ref;
4808 }
4809
4810 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
4811 CHECK(!owner->result_ok);
4812         return DecodeError_clone(&*owner->contents.err);
4813 }
4814 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
4815         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
4816         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
4817         uintptr_t ret_ref = 0;
4818         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4819         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4821         ret_ref = (uintptr_t)ret_var.inner;
4822         if (ret_var.is_owned) {
4823                 ret_ref |= 1;
4824         }
4825         return ret_ref;
4826 }
4827
4828 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
4829 CHECK(owner->result_ok);
4830         return UpdateFee_clone(&*owner->contents.result);
4831 }
4832 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
4833         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
4834         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
4835         uintptr_t ret_ref = 0;
4836         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4837         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4839         ret_ref = (uintptr_t)ret_var.inner;
4840         if (ret_var.is_owned) {
4841                 ret_ref |= 1;
4842         }
4843         return ret_ref;
4844 }
4845
4846 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
4847 CHECK(!owner->result_ok);
4848         return DecodeError_clone(&*owner->contents.err);
4849 }
4850 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
4851         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
4852         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
4853         uintptr_t ret_ref = 0;
4854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4857         ret_ref = (uintptr_t)ret_var.inner;
4858         if (ret_var.is_owned) {
4859                 ret_ref |= 1;
4860         }
4861         return ret_ref;
4862 }
4863
4864 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
4865 CHECK(owner->result_ok);
4866         return UpdateFulfillHTLC_clone(&*owner->contents.result);
4867 }
4868 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
4869         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
4870         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
4871         uintptr_t ret_ref = 0;
4872         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4873         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4875         ret_ref = (uintptr_t)ret_var.inner;
4876         if (ret_var.is_owned) {
4877                 ret_ref |= 1;
4878         }
4879         return ret_ref;
4880 }
4881
4882 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
4883 CHECK(!owner->result_ok);
4884         return DecodeError_clone(&*owner->contents.err);
4885 }
4886 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
4887         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
4888         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
4889         uintptr_t ret_ref = 0;
4890         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4891         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4893         ret_ref = (uintptr_t)ret_var.inner;
4894         if (ret_var.is_owned) {
4895                 ret_ref |= 1;
4896         }
4897         return ret_ref;
4898 }
4899
4900 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
4901 CHECK(owner->result_ok);
4902         return UpdateAddHTLC_clone(&*owner->contents.result);
4903 }
4904 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
4905         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
4906         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
4907         uintptr_t ret_ref = 0;
4908         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4909         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4911         ret_ref = (uintptr_t)ret_var.inner;
4912         if (ret_var.is_owned) {
4913                 ret_ref |= 1;
4914         }
4915         return ret_ref;
4916 }
4917
4918 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
4919 CHECK(!owner->result_ok);
4920         return DecodeError_clone(&*owner->contents.err);
4921 }
4922 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
4923         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
4924         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
4925         uintptr_t ret_ref = 0;
4926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4929         ret_ref = (uintptr_t)ret_var.inner;
4930         if (ret_var.is_owned) {
4931                 ret_ref |= 1;
4932         }
4933         return ret_ref;
4934 }
4935
4936 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
4937 CHECK(owner->result_ok);
4938         return Ping_clone(&*owner->contents.result);
4939 }
4940 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
4941         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
4942         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
4943         uintptr_t ret_ref = 0;
4944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4947         ret_ref = (uintptr_t)ret_var.inner;
4948         if (ret_var.is_owned) {
4949                 ret_ref |= 1;
4950         }
4951         return ret_ref;
4952 }
4953
4954 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
4955 CHECK(!owner->result_ok);
4956         return DecodeError_clone(&*owner->contents.err);
4957 }
4958 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
4959         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
4960         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
4961         uintptr_t ret_ref = 0;
4962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4965         ret_ref = (uintptr_t)ret_var.inner;
4966         if (ret_var.is_owned) {
4967                 ret_ref |= 1;
4968         }
4969         return ret_ref;
4970 }
4971
4972 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
4973 CHECK(owner->result_ok);
4974         return Pong_clone(&*owner->contents.result);
4975 }
4976 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
4977         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
4978         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
4979         uintptr_t ret_ref = 0;
4980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4983         ret_ref = (uintptr_t)ret_var.inner;
4984         if (ret_var.is_owned) {
4985                 ret_ref |= 1;
4986         }
4987         return ret_ref;
4988 }
4989
4990 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
4991 CHECK(!owner->result_ok);
4992         return DecodeError_clone(&*owner->contents.err);
4993 }
4994 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
4995         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
4996         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
4997         uintptr_t ret_ref = 0;
4998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5001         ret_ref = (uintptr_t)ret_var.inner;
5002         if (ret_var.is_owned) {
5003                 ret_ref |= 1;
5004         }
5005         return ret_ref;
5006 }
5007
5008 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5009 CHECK(owner->result_ok);
5010         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
5011 }
5012 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
5013         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
5014         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
5015         uintptr_t ret_ref = 0;
5016         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5017         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5019         ret_ref = (uintptr_t)ret_var.inner;
5020         if (ret_var.is_owned) {
5021                 ret_ref |= 1;
5022         }
5023         return ret_ref;
5024 }
5025
5026 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5027 CHECK(!owner->result_ok);
5028         return DecodeError_clone(&*owner->contents.err);
5029 }
5030 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
5031         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
5032         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
5033         uintptr_t ret_ref = 0;
5034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5037         ret_ref = (uintptr_t)ret_var.inner;
5038         if (ret_var.is_owned) {
5039                 ret_ref |= 1;
5040         }
5041         return ret_ref;
5042 }
5043
5044 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5045 CHECK(owner->result_ok);
5046         return ChannelAnnouncement_clone(&*owner->contents.result);
5047 }
5048 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
5049         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
5050         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
5051         uintptr_t ret_ref = 0;
5052         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5053         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5055         ret_ref = (uintptr_t)ret_var.inner;
5056         if (ret_var.is_owned) {
5057                 ret_ref |= 1;
5058         }
5059         return ret_ref;
5060 }
5061
5062 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5063 CHECK(!owner->result_ok);
5064         return DecodeError_clone(&*owner->contents.err);
5065 }
5066 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
5067         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
5068         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
5069         uintptr_t ret_ref = 0;
5070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5073         ret_ref = (uintptr_t)ret_var.inner;
5074         if (ret_var.is_owned) {
5075                 ret_ref |= 1;
5076         }
5077         return ret_ref;
5078 }
5079
5080 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
5081 CHECK(owner->result_ok);
5082         return UnsignedChannelUpdate_clone(&*owner->contents.result);
5083 }
5084 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5085         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
5086         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
5087         uintptr_t ret_ref = 0;
5088         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5089         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5091         ret_ref = (uintptr_t)ret_var.inner;
5092         if (ret_var.is_owned) {
5093                 ret_ref |= 1;
5094         }
5095         return ret_ref;
5096 }
5097
5098 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
5099 CHECK(!owner->result_ok);
5100         return DecodeError_clone(&*owner->contents.err);
5101 }
5102 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
5103         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
5104         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
5105         uintptr_t ret_ref = 0;
5106         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5107         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5109         ret_ref = (uintptr_t)ret_var.inner;
5110         if (ret_var.is_owned) {
5111                 ret_ref |= 1;
5112         }
5113         return ret_ref;
5114 }
5115
5116 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
5117 CHECK(owner->result_ok);
5118         return ChannelUpdate_clone(&*owner->contents.result);
5119 }
5120 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5121         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
5122         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
5123         uintptr_t ret_ref = 0;
5124         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5125         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5127         ret_ref = (uintptr_t)ret_var.inner;
5128         if (ret_var.is_owned) {
5129                 ret_ref |= 1;
5130         }
5131         return ret_ref;
5132 }
5133
5134 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
5135 CHECK(!owner->result_ok);
5136         return DecodeError_clone(&*owner->contents.err);
5137 }
5138 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
5139         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
5140         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
5141         uintptr_t ret_ref = 0;
5142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5145         ret_ref = (uintptr_t)ret_var.inner;
5146         if (ret_var.is_owned) {
5147                 ret_ref |= 1;
5148         }
5149         return ret_ref;
5150 }
5151
5152 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
5153 CHECK(owner->result_ok);
5154         return ErrorMessage_clone(&*owner->contents.result);
5155 }
5156 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
5157         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
5158         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
5159         uintptr_t ret_ref = 0;
5160         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5161         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5163         ret_ref = (uintptr_t)ret_var.inner;
5164         if (ret_var.is_owned) {
5165                 ret_ref |= 1;
5166         }
5167         return ret_ref;
5168 }
5169
5170 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
5171 CHECK(!owner->result_ok);
5172         return DecodeError_clone(&*owner->contents.err);
5173 }
5174 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
5175         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
5176         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
5177         uintptr_t ret_ref = 0;
5178         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5179         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5181         ret_ref = (uintptr_t)ret_var.inner;
5182         if (ret_var.is_owned) {
5183                 ret_ref |= 1;
5184         }
5185         return ret_ref;
5186 }
5187
5188 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5189 CHECK(owner->result_ok);
5190         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
5191 }
5192 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
5193         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
5194         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
5195         uintptr_t ret_ref = 0;
5196         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5197         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5199         ret_ref = (uintptr_t)ret_var.inner;
5200         if (ret_var.is_owned) {
5201                 ret_ref |= 1;
5202         }
5203         return ret_ref;
5204 }
5205
5206 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5207 CHECK(!owner->result_ok);
5208         return DecodeError_clone(&*owner->contents.err);
5209 }
5210 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
5211         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
5212         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
5213         uintptr_t ret_ref = 0;
5214         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5215         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5217         ret_ref = (uintptr_t)ret_var.inner;
5218         if (ret_var.is_owned) {
5219                 ret_ref |= 1;
5220         }
5221         return ret_ref;
5222 }
5223
5224 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5225 CHECK(owner->result_ok);
5226         return NodeAnnouncement_clone(&*owner->contents.result);
5227 }
5228 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
5229         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
5230         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
5231         uintptr_t ret_ref = 0;
5232         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5233         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5235         ret_ref = (uintptr_t)ret_var.inner;
5236         if (ret_var.is_owned) {
5237                 ret_ref |= 1;
5238         }
5239         return ret_ref;
5240 }
5241
5242 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
5243 CHECK(!owner->result_ok);
5244         return DecodeError_clone(&*owner->contents.err);
5245 }
5246 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
5247         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
5248         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
5249         uintptr_t ret_ref = 0;
5250         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5251         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5253         ret_ref = (uintptr_t)ret_var.inner;
5254         if (ret_var.is_owned) {
5255                 ret_ref |= 1;
5256         }
5257         return ret_ref;
5258 }
5259
5260 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
5261 CHECK(owner->result_ok);
5262         return QueryShortChannelIds_clone(&*owner->contents.result);
5263 }
5264 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
5265         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
5266         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
5267         uintptr_t ret_ref = 0;
5268         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5269         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5271         ret_ref = (uintptr_t)ret_var.inner;
5272         if (ret_var.is_owned) {
5273                 ret_ref |= 1;
5274         }
5275         return ret_ref;
5276 }
5277
5278 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
5279 CHECK(!owner->result_ok);
5280         return DecodeError_clone(&*owner->contents.err);
5281 }
5282 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
5283         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
5284         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
5285         uintptr_t ret_ref = 0;
5286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5289         ret_ref = (uintptr_t)ret_var.inner;
5290         if (ret_var.is_owned) {
5291                 ret_ref |= 1;
5292         }
5293         return ret_ref;
5294 }
5295
5296 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
5297 CHECK(owner->result_ok);
5298         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
5299 }
5300 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
5301         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
5302         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
5303         uintptr_t ret_ref = 0;
5304         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5305         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5307         ret_ref = (uintptr_t)ret_var.inner;
5308         if (ret_var.is_owned) {
5309                 ret_ref |= 1;
5310         }
5311         return ret_ref;
5312 }
5313
5314 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
5315 CHECK(!owner->result_ok);
5316         return DecodeError_clone(&*owner->contents.err);
5317 }
5318 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
5319         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
5320         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
5321         uintptr_t ret_ref = 0;
5322         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5323         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5324         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5325         ret_ref = (uintptr_t)ret_var.inner;
5326         if (ret_var.is_owned) {
5327                 ret_ref |= 1;
5328         }
5329         return ret_ref;
5330 }
5331
5332 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
5333 CHECK(owner->result_ok);
5334         return QueryChannelRange_clone(&*owner->contents.result);
5335 }
5336 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
5337         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
5338         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
5339         uintptr_t ret_ref = 0;
5340         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5341         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5343         ret_ref = (uintptr_t)ret_var.inner;
5344         if (ret_var.is_owned) {
5345                 ret_ref |= 1;
5346         }
5347         return ret_ref;
5348 }
5349
5350 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
5351 CHECK(!owner->result_ok);
5352         return DecodeError_clone(&*owner->contents.err);
5353 }
5354 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
5355         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
5356         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
5357         uintptr_t ret_ref = 0;
5358         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5359         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5361         ret_ref = (uintptr_t)ret_var.inner;
5362         if (ret_var.is_owned) {
5363                 ret_ref |= 1;
5364         }
5365         return ret_ref;
5366 }
5367
5368 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
5369 CHECK(owner->result_ok);
5370         return ReplyChannelRange_clone(&*owner->contents.result);
5371 }
5372 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
5373         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
5374         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
5375         uintptr_t ret_ref = 0;
5376         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5377         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5379         ret_ref = (uintptr_t)ret_var.inner;
5380         if (ret_var.is_owned) {
5381                 ret_ref |= 1;
5382         }
5383         return ret_ref;
5384 }
5385
5386 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
5387 CHECK(!owner->result_ok);
5388         return DecodeError_clone(&*owner->contents.err);
5389 }
5390 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
5391         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
5392         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
5393         uintptr_t ret_ref = 0;
5394         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5395         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5396         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5397         ret_ref = (uintptr_t)ret_var.inner;
5398         if (ret_var.is_owned) {
5399                 ret_ref |= 1;
5400         }
5401         return ret_ref;
5402 }
5403
5404 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
5405 CHECK(owner->result_ok);
5406         return GossipTimestampFilter_clone(&*owner->contents.result);
5407 }
5408 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
5409         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
5410         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
5411         uintptr_t ret_ref = 0;
5412         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5413         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5415         ret_ref = (uintptr_t)ret_var.inner;
5416         if (ret_var.is_owned) {
5417                 ret_ref |= 1;
5418         }
5419         return ret_ref;
5420 }
5421
5422 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
5423 CHECK(!owner->result_ok);
5424         return DecodeError_clone(&*owner->contents.err);
5425 }
5426 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
5427         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
5428         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
5429         uintptr_t ret_ref = 0;
5430         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5431         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5433         ret_ref = (uintptr_t)ret_var.inner;
5434         if (ret_var.is_owned) {
5435                 ret_ref |= 1;
5436         }
5437         return ret_ref;
5438 }
5439
5440 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5441 CHECK(owner->result_ok);
5442         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
5443 }
5444 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
5445         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
5446         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5447         uintptr_t ret_ref = 0;
5448         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5449         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5451         ret_ref = (uintptr_t)ret_var.inner;
5452         if (ret_var.is_owned) {
5453                 ret_ref |= 1;
5454         }
5455         return ret_ref;
5456 }
5457
5458 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5459 CHECK(!owner->result_ok);
5460         return DecodeError_clone(&*owner->contents.err);
5461 }
5462 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
5463         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
5464         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5465         uintptr_t ret_ref = 0;
5466         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5467         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5469         ret_ref = (uintptr_t)ret_var.inner;
5470         if (ret_var.is_owned) {
5471                 ret_ref |= 1;
5472         }
5473         return ret_ref;
5474 }
5475
5476 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5477 CHECK(owner->result_ok);
5478         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
5479 }
5480 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
5481         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
5482         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5483         uintptr_t ret_ref = 0;
5484         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5485         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5487         ret_ref = (uintptr_t)ret_var.inner;
5488         if (ret_var.is_owned) {
5489                 ret_ref |= 1;
5490         }
5491         return ret_ref;
5492 }
5493
5494 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5495 CHECK(!owner->result_ok);
5496         return DecodeError_clone(&*owner->contents.err);
5497 }
5498 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
5499         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
5500         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5501         uintptr_t ret_ref = 0;
5502         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5503         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5505         ret_ref = (uintptr_t)ret_var.inner;
5506         if (ret_var.is_owned) {
5507                 ret_ref |= 1;
5508         }
5509         return ret_ref;
5510 }
5511
5512 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5513 CHECK(owner->result_ok);
5514         return SpendableOutputDescriptor_clone(&*owner->contents.result);
5515 }
5516 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
5517         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
5518         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
5519         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5520         uintptr_t ret_ref = (uintptr_t)ret_copy;
5521         return ret_ref;
5522 }
5523
5524 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5525 CHECK(!owner->result_ok);
5526         return DecodeError_clone(&*owner->contents.err);
5527 }
5528 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
5529         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
5530         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5531         uintptr_t ret_ref = 0;
5532         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5533         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5535         ret_ref = (uintptr_t)ret_var.inner;
5536         if (ret_var.is_owned) {
5537                 ret_ref |= 1;
5538         }
5539         return ret_ref;
5540 }
5541
5542 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5543 CHECK(owner->result_ok);
5544         return Sign_clone(&*owner->contents.result);
5545 }
5546 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
5547         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5548         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5549         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
5550         return (uintptr_t)ret_ret;
5551 }
5552
5553 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5554 CHECK(!owner->result_ok);
5555         return DecodeError_clone(&*owner->contents.err);
5556 }
5557 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
5558         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
5559         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
5560         uintptr_t ret_ref = 0;
5561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5564         ret_ref = (uintptr_t)ret_var.inner;
5565         if (ret_var.is_owned) {
5566                 ret_ref |= 1;
5567         }
5568         return ret_ref;
5569 }
5570
5571 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5572 CHECK(owner->result_ok);
5573         return *owner->contents.result;
5574 }
5575 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
5576         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5577         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
5578         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
5579         return ret_arr;
5580 }
5581
5582 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
5583 CHECK(!owner->result_ok);
5584         return *owner->contents.err;
5585 }
5586 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
5587         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
5588         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
5589 }
5590
5591 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
5592         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
5593         for (size_t i = 0; i < ret.datalen; i++) {
5594                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
5595         }
5596         return ret;
5597 }
5598 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5599 CHECK(owner->result_ok);
5600         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
5601 }
5602 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
5603         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5604         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
5605         ptrArray ret_arr = NULL;
5606         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
5607         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
5608         for (size_t m = 0; m < ret_var.datalen; m++) {
5609                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
5610                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
5611                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
5612                 CVec_u8Z_free(ret_conv_12_var);
5613                 ret_arr_ptr[m] = ret_conv_12_arr;
5614         }
5615         
5616         FREE(ret_var.data);
5617         return ret_arr;
5618 }
5619
5620 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
5621 CHECK(!owner->result_ok);
5622         return *owner->contents.err;
5623 }
5624 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
5625         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
5626         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
5627 }
5628
5629 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5630 CHECK(owner->result_ok);
5631         return InMemorySigner_clone(&*owner->contents.result);
5632 }
5633 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
5634         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5635         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
5636         uintptr_t ret_ref = 0;
5637         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5638         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5640         ret_ref = (uintptr_t)ret_var.inner;
5641         if (ret_var.is_owned) {
5642                 ret_ref |= 1;
5643         }
5644         return ret_ref;
5645 }
5646
5647 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
5648 CHECK(!owner->result_ok);
5649         return DecodeError_clone(&*owner->contents.err);
5650 }
5651 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
5652         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
5653         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
5654         uintptr_t ret_ref = 0;
5655         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5656         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5658         ret_ref = (uintptr_t)ret_var.inner;
5659         if (ret_var.is_owned) {
5660                 ret_ref |= 1;
5661         }
5662         return ret_ref;
5663 }
5664
5665 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
5666         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
5667         for (size_t i = 0; i < ret.datalen; i++) {
5668                 ret.data[i] = TxOut_clone(&orig->data[i]);
5669         }
5670         return ret;
5671 }
5672 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5673 CHECK(owner->result_ok);
5674         return *owner->contents.result;
5675 }
5676 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
5677         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5678         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
5679         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5680         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5681         return ret_arr;
5682 }
5683
5684 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
5685 CHECK(!owner->result_ok);
5686         return *owner->contents.err;
5687 }
5688 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
5689         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
5690         CResult_TransactionNoneZ_get_err(owner_conv);
5691 }
5692
5693 typedef struct LDKFilter_JCalls {
5694         atomic_size_t refcnt;
5695         uint32_t instance_ptr;
5696 } LDKFilter_JCalls;
5697 static void LDKFilter_JCalls_free(void* this_arg) {
5698         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5699         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5700                 FREE(j_calls);
5701         }
5702 }
5703 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
5704         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5705         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
5706         memcpy(txid_arr->elems, *txid, 32);
5707         LDKu8slice script_pubkey_var = script_pubkey;
5708         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
5709         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
5710         js_invoke_function_2(j_calls->instance_ptr, 18, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
5711 }
5712 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
5713         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
5714         LDKWatchedOutput output_var = output;
5715         uintptr_t output_ref = 0;
5716         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5717         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5718         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
5719         output_ref = (uintptr_t)output_var.inner;
5720         if (output_var.is_owned) {
5721                 output_ref |= 1;
5722         }
5723         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 19, (uint32_t)output_ref);
5724         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5725         CHECK_ACCESS(ret_ptr);
5726         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
5727         FREE((void*)ret);
5728         return ret_conv;
5729 }
5730 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
5731         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
5732         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5733 }
5734 static inline LDKFilter LDKFilter_init (JSValue o) {
5735         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
5736         atomic_init(&calls->refcnt, 1);
5737         calls->instance_ptr = o;
5738
5739         LDKFilter ret = {
5740                 .this_arg = (void*) calls,
5741                 .register_tx = register_tx_LDKFilter_jcall,
5742                 .register_output = register_output_LDKFilter_jcall,
5743                 .free = LDKFilter_JCalls_free,
5744         };
5745         return ret;
5746 }
5747 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
5748         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
5749         *res_ptr = LDKFilter_init(o);
5750         return (long)res_ptr;
5751 }
5752 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
5753         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5754         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5755         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
5756         unsigned char txid_arr[32];
5757         CHECK(txid->arr_len == 32);
5758         memcpy(txid_arr, txid->elems, 32); FREE(txid);
5759         unsigned char (*txid_ref)[32] = &txid_arr;
5760         LDKu8slice script_pubkey_ref;
5761         script_pubkey_ref.datalen = script_pubkey->arr_len;
5762         script_pubkey_ref.data = script_pubkey->elems /* XXX script_pubkey leaks */;
5763         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
5764 }
5765
5766 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
5767         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5768         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5769         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
5770         LDKWatchedOutput output_conv;
5771         output_conv.inner = (void*)(output & (~1));
5772         output_conv.is_owned = (output & 1) || (output == 0);
5773         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
5774         output_conv = WatchedOutput_clone(&output_conv);
5775         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
5776         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
5777         uintptr_t ret_ref = (uintptr_t)ret_copy;
5778         return ret_ref;
5779 }
5780
5781 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
5782         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
5783         switch(obj->tag) {
5784                 case LDKCOption_FilterZ_Some: return 0;
5785                 case LDKCOption_FilterZ_None: return 1;
5786                 default: abort();
5787         }
5788 }
5789 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
5790         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
5791         assert(obj->tag == LDKCOption_FilterZ_Some);
5792                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
5793                         *some_ret = obj->some;
5794                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
5795         return (uintptr_t)some_ret;
5796 }
5797 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
5798 CHECK(owner->result_ok);
5799         return &*owner->contents.result;
5800 }
5801 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
5802         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
5803         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
5804         uintptr_t ret_ref = 0;
5805         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5806         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5808         ret_ref = (uintptr_t)ret_var.inner & ~1;
5809         return ret_ref;
5810 }
5811
5812 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
5813 CHECK(!owner->result_ok);
5814         return *owner->contents.err;
5815 }
5816 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
5817         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
5818         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
5819 }
5820
5821 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
5822         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
5823         for (size_t i = 0; i < ret.datalen; i++) {
5824                 ret.data[i] = OutPoint_clone(&orig->data[i]);
5825         }
5826         return ret;
5827 }
5828 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
5829         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5830         switch(obj->tag) {
5831                 case LDKAPIError_APIMisuseError: return 0;
5832                 case LDKAPIError_FeeRateTooHigh: return 1;
5833                 case LDKAPIError_RouteError: return 2;
5834                 case LDKAPIError_ChannelUnavailable: return 3;
5835                 case LDKAPIError_MonitorUpdateFailed: return 4;
5836                 case LDKAPIError_IncompatibleShutdownScript: return 5;
5837                 default: abort();
5838         }
5839 }
5840 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
5841         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5842         assert(obj->tag == LDKAPIError_APIMisuseError);
5843                         LDKStr err_str = obj->api_misuse_error.err;
5844                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
5845         return err_conv;
5846 }
5847 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
5848         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5849         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
5850                         LDKStr err_str = obj->fee_rate_too_high.err;
5851                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
5852         return err_conv;
5853 }
5854 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
5855         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5856         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
5857         return obj->fee_rate_too_high.feerate;
5858 }
5859 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
5860         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5861         assert(obj->tag == LDKAPIError_RouteError);
5862                         LDKStr err_str = obj->route_error.err;
5863                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
5864         return err_conv;
5865 }
5866 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
5867         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5868         assert(obj->tag == LDKAPIError_ChannelUnavailable);
5869                         LDKStr err_str = obj->channel_unavailable.err;
5870                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
5871         return err_conv;
5872 }
5873 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
5874         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
5875         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
5876                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
5877                         uintptr_t script_ref = 0;
5878                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5879                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5880                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
5881                         script_ref = (uintptr_t)script_var.inner & ~1;
5882         return script_ref;
5883 }
5884 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5885 CHECK(owner->result_ok);
5886         return *owner->contents.result;
5887 }
5888 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
5889         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5890         CResult_NoneAPIErrorZ_get_ok(owner_conv);
5891 }
5892
5893 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
5894 CHECK(!owner->result_ok);
5895         return APIError_clone(&*owner->contents.err);
5896 }
5897 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
5898         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
5899         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5900         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
5901         uintptr_t ret_ref = (uintptr_t)ret_copy;
5902         return ret_ref;
5903 }
5904
5905 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
5906         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
5907         switch(obj->tag) {
5908                 case LDKCOption_u16Z_Some: return 0;
5909                 case LDKCOption_u16Z_None: return 1;
5910                 default: abort();
5911         }
5912 }
5913 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
5914         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
5915         assert(obj->tag == LDKCOption_u16Z_Some);
5916         return obj->some;
5917 }
5918 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
5919         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
5920         for (size_t i = 0; i < ret.datalen; i++) {
5921                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
5922         }
5923         return ret;
5924 }
5925 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
5926         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
5927         for (size_t i = 0; i < ret.datalen; i++) {
5928                 ret.data[i] = APIError_clone(&orig->data[i]);
5929         }
5930         return ret;
5931 }
5932 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5933 CHECK(owner->result_ok);
5934         return ThirtyTwoBytes_clone(&*owner->contents.result);
5935 }
5936 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
5937         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
5938         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5939         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
5940         return ret_arr;
5941 }
5942
5943 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
5944 CHECK(!owner->result_ok);
5945         return APIError_clone(&*owner->contents.err);
5946 }
5947 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
5948         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
5949         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5950         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
5951         uintptr_t ret_ref = (uintptr_t)ret_copy;
5952         return ret_ref;
5953 }
5954
5955 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
5956         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5957         switch(obj->tag) {
5958                 case LDKPaymentSendFailure_ParameterError: return 0;
5959                 case LDKPaymentSendFailure_PathParameterError: return 1;
5960                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
5961                 case LDKPaymentSendFailure_PartialFailure: return 3;
5962                 default: abort();
5963         }
5964 }
5965 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
5966         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5967         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
5968                         uintptr_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
5969         return parameter_error_ref;
5970 }
5971 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
5972         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5973         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
5974                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
5975                         uint32_tArray path_parameter_error_arr = NULL;
5976                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
5977                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
5978                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
5979                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5980                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
5981                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
5982                                 path_parameter_error_arr_ptr[w] = (uintptr_t)path_parameter_error_conv_22_conv;
5983                         }
5984                         
5985         return path_parameter_error_arr;
5986 }
5987 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
5988         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
5989         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
5990                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
5991                         uint32_tArray all_failed_retry_safe_arr = NULL;
5992                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
5993                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
5994                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
5995                                 uintptr_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
5996                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
5997                         }
5998                         
5999         return all_failed_retry_safe_arr;
6000 }
6001 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
6002         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
6003         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
6004                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
6005                         uint32_tArray results_arr = NULL;
6006                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
6007                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
6008                         for (size_t w = 0; w < results_var.datalen; w++) {
6009                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6010                                 *results_conv_22_conv = results_var.data[w];
6011                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
6012                                 results_arr_ptr[w] = (uintptr_t)results_conv_22_conv;
6013                         }
6014                         
6015         return results_arr;
6016 }
6017 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
6018         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
6019         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
6020                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
6021                         uintptr_t failed_paths_retry_ref = 0;
6022                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
6023                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6024                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6025                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
6026                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
6027                         }
6028         return failed_paths_retry_ref;
6029 }
6030 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
6031         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
6032         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
6033                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
6034                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
6035         return payment_id_arr;
6036 }
6037 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6038 CHECK(owner->result_ok);
6039         return ThirtyTwoBytes_clone(&*owner->contents.result);
6040 }
6041 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
6042         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
6043         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6044         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
6045         return ret_arr;
6046 }
6047
6048 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6049 CHECK(!owner->result_ok);
6050         return PaymentSendFailure_clone(&*owner->contents.err);
6051 }
6052 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
6053         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
6054         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6055         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
6056         uintptr_t ret_ref = (uintptr_t)ret_copy;
6057         return ret_ref;
6058 }
6059
6060 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6061 CHECK(owner->result_ok);
6062         return *owner->contents.result;
6063 }
6064 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
6065         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
6066         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
6067 }
6068
6069 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6070 CHECK(!owner->result_ok);
6071         return PaymentSendFailure_clone(&*owner->contents.err);
6072 }
6073 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
6074         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
6075         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6076         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
6077         uintptr_t ret_ref = (uintptr_t)ret_copy;
6078         return ret_ref;
6079 }
6080
6081 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6082         return ThirtyTwoBytes_clone(&owner->a);
6083 }
6084 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
6085         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
6086         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6087         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
6088         return ret_arr;
6089 }
6090
6091 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6092         return ThirtyTwoBytes_clone(&owner->b);
6093 }
6094 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
6095         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
6096         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6097         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
6098         return ret_arr;
6099 }
6100
6101 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6102 CHECK(owner->result_ok);
6103         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
6104 }
6105 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
6106         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
6107         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
6108         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
6109         return ((uintptr_t)ret_conv);
6110 }
6111
6112 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6113 CHECK(!owner->result_ok);
6114         return PaymentSendFailure_clone(&*owner->contents.err);
6115 }
6116 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
6117         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
6118         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6119         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
6120         uintptr_t ret_ref = (uintptr_t)ret_copy;
6121         return ret_ref;
6122 }
6123
6124 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6125         return ThirtyTwoBytes_clone(&owner->a);
6126 }
6127 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
6128         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6129         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6130         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
6131         return ret_arr;
6132 }
6133
6134 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6135         return ThirtyTwoBytes_clone(&owner->b);
6136 }
6137 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
6138         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
6139         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6140         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
6141         return ret_arr;
6142 }
6143
6144 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6145 CHECK(owner->result_ok);
6146         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6147 }
6148 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
6149         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6150         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6151         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
6152         return ((uintptr_t)ret_conv);
6153 }
6154
6155 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6156 CHECK(!owner->result_ok);
6157         return *owner->contents.err;
6158 }
6159 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
6160         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
6161         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
6162 }
6163
6164 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6165 CHECK(owner->result_ok);
6166         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6167 }
6168 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
6169         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6170         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6171         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
6172         return ((uintptr_t)ret_conv);
6173 }
6174
6175 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6176 CHECK(!owner->result_ok);
6177         return APIError_clone(&*owner->contents.err);
6178 }
6179 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
6180         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
6181         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6182         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
6183         uintptr_t ret_ref = (uintptr_t)ret_copy;
6184         return ret_ref;
6185 }
6186
6187 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6188 CHECK(owner->result_ok);
6189         return ThirtyTwoBytes_clone(&*owner->contents.result);
6190 }
6191 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
6192         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6193         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6194         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
6195         return ret_arr;
6196 }
6197
6198 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6199 CHECK(!owner->result_ok);
6200         return *owner->contents.err;
6201 }
6202 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
6203         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
6204         CResult_PaymentSecretNoneZ_get_err(owner_conv);
6205 }
6206
6207 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6208 CHECK(owner->result_ok);
6209         return ThirtyTwoBytes_clone(&*owner->contents.result);
6210 }
6211 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
6212         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6213         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6214         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
6215         return ret_arr;
6216 }
6217
6218 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6219 CHECK(!owner->result_ok);
6220         return APIError_clone(&*owner->contents.err);
6221 }
6222 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
6223         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
6224         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6225         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6226         uintptr_t ret_ref = (uintptr_t)ret_copy;
6227         return ret_ref;
6228 }
6229
6230 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6231 CHECK(owner->result_ok);
6232         return ThirtyTwoBytes_clone(&*owner->contents.result);
6233 }
6234 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
6235         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6236         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6237         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
6238         return ret_arr;
6239 }
6240
6241 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6242 CHECK(!owner->result_ok);
6243         return APIError_clone(&*owner->contents.err);
6244 }
6245 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
6246         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
6247         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6248         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6249         uintptr_t ret_ref = (uintptr_t)ret_copy;
6250         return ret_ref;
6251 }
6252
6253 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6254         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6255         for (size_t i = 0; i < ret.datalen; i++) {
6256                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6257         }
6258         return ret;
6259 }
6260 typedef struct LDKWatch_JCalls {
6261         atomic_size_t refcnt;
6262         uint32_t instance_ptr;
6263 } LDKWatch_JCalls;
6264 static void LDKWatch_JCalls_free(void* this_arg) {
6265         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6266         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6267                 FREE(j_calls);
6268         }
6269 }
6270 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6271         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6272         LDKOutPoint funding_txo_var = funding_txo;
6273         uintptr_t funding_txo_ref = 0;
6274         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6275         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6276         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6277         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6278         if (funding_txo_var.is_owned) {
6279                 funding_txo_ref |= 1;
6280         }
6281         LDKChannelMonitor monitor_var = monitor;
6282         uintptr_t monitor_ref = 0;
6283         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6284         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6285         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
6286         monitor_ref = (uintptr_t)monitor_var.inner;
6287         if (monitor_var.is_owned) {
6288                 monitor_ref |= 1;
6289         }
6290         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 20, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
6291         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6292         CHECK_ACCESS(ret_ptr);
6293         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6294         FREE((void*)ret);
6295         return ret_conv;
6296 }
6297 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
6298         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6299         LDKOutPoint funding_txo_var = funding_txo;
6300         uintptr_t funding_txo_ref = 0;
6301         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6302         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6303         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6304         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
6305         if (funding_txo_var.is_owned) {
6306                 funding_txo_ref |= 1;
6307         }
6308         LDKChannelMonitorUpdate update_var = update;
6309         uintptr_t update_ref = 0;
6310         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6311         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6312         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
6313         update_ref = (uintptr_t)update_var.inner;
6314         if (update_var.is_owned) {
6315                 update_ref |= 1;
6316         }
6317         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 21, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
6318         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6319         CHECK_ACCESS(ret_ptr);
6320         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6321         FREE((void*)ret);
6322         return ret_conv;
6323 }
6324 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
6325         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6326         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 22);
6327         LDKCVec_MonitorEventZ ret_constr;
6328         ret_constr.datalen = ret->arr_len;
6329         if (ret_constr.datalen > 0)
6330                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
6331         else
6332                 ret_constr.data = NULL;
6333         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
6334         for (size_t o = 0; o < ret_constr.datalen; o++) {
6335                 uint32_t ret_conv_14 = ret_vals[o];
6336                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
6337                 CHECK_ACCESS(ret_conv_14_ptr);
6338                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
6339                 FREE((void*)ret_conv_14);
6340                 ret_constr.data[o] = ret_conv_14_conv;
6341         }
6342         return ret_constr;
6343 }
6344 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
6345         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
6346         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6347 }
6348 static inline LDKWatch LDKWatch_init (JSValue o) {
6349         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
6350         atomic_init(&calls->refcnt, 1);
6351         calls->instance_ptr = o;
6352
6353         LDKWatch ret = {
6354                 .this_arg = (void*) calls,
6355                 .watch_channel = watch_channel_LDKWatch_jcall,
6356                 .update_channel = update_channel_LDKWatch_jcall,
6357                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
6358                 .free = LDKWatch_JCalls_free,
6359         };
6360         return ret;
6361 }
6362 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
6363         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
6364         *res_ptr = LDKWatch_init(o);
6365         return (long)res_ptr;
6366 }
6367 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
6368         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6369         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6370         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6371         LDKOutPoint funding_txo_conv;
6372         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6373         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6374         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6375         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6376         LDKChannelMonitor monitor_conv;
6377         monitor_conv.inner = (void*)(monitor & (~1));
6378         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
6379         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
6380         monitor_conv = ChannelMonitor_clone(&monitor_conv);
6381         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6382         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
6383         return (uintptr_t)ret_conv;
6384 }
6385
6386 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
6387         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6388         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6389         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6390         LDKOutPoint funding_txo_conv;
6391         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6392         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6393         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6394         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6395         LDKChannelMonitorUpdate update_conv;
6396         update_conv.inner = (void*)(update & (~1));
6397         update_conv.is_owned = (update & 1) || (update == 0);
6398         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
6399         update_conv = ChannelMonitorUpdate_clone(&update_conv);
6400         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6401         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
6402         return (uintptr_t)ret_conv;
6403 }
6404
6405 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
6406         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6407         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6408         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6409         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
6410         uint32_tArray ret_arr = NULL;
6411         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6412         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6413         for (size_t o = 0; o < ret_var.datalen; o++) {
6414                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
6415                 *ret_conv_14_copy = ret_var.data[o];
6416                 uintptr_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
6417                 ret_arr_ptr[o] = ret_conv_14_ref;
6418         }
6419         
6420         FREE(ret_var.data);
6421         return ret_arr;
6422 }
6423
6424 typedef struct LDKBroadcasterInterface_JCalls {
6425         atomic_size_t refcnt;
6426         uint32_t instance_ptr;
6427 } LDKBroadcasterInterface_JCalls;
6428 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
6429         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6430         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6431                 FREE(j_calls);
6432         }
6433 }
6434 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
6435         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
6436         LDKTransaction tx_var = tx;
6437         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
6438         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
6439         Transaction_free(tx_var);
6440         js_invoke_function_1(j_calls->instance_ptr, 23, (uint32_t)tx_arr);
6441 }
6442 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
6443         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
6444         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6445 }
6446 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
6447         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
6448         atomic_init(&calls->refcnt, 1);
6449         calls->instance_ptr = o;
6450
6451         LDKBroadcasterInterface ret = {
6452                 .this_arg = (void*) calls,
6453                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
6454                 .free = LDKBroadcasterInterface_JCalls_free,
6455         };
6456         return ret;
6457 }
6458 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
6459         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
6460         *res_ptr = LDKBroadcasterInterface_init(o);
6461         return (long)res_ptr;
6462 }
6463 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
6464         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6465         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6466         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
6467         LDKTransaction tx_ref;
6468         tx_ref.datalen = tx->arr_len;
6469         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
6470         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
6471         tx_ref.data_is_owned = true;
6472         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
6473 }
6474
6475 typedef struct LDKKeysInterface_JCalls {
6476         atomic_size_t refcnt;
6477         uint32_t instance_ptr;
6478 } LDKKeysInterface_JCalls;
6479 static void LDKKeysInterface_JCalls_free(void* this_arg) {
6480         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6481         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6482                 FREE(j_calls);
6483         }
6484 }
6485 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
6486         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6487         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 24);
6488         LDKSecretKey ret_ref;
6489         CHECK(ret->arr_len == 32);
6490         memcpy(ret_ref.bytes, ret->elems, 32); FREE(ret);
6491         return ret_ref;
6492 }
6493 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
6494         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6495         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 25);
6496         LDKCVec_u8Z ret_ref;
6497         ret_ref.datalen = ret->arr_len;
6498         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6499         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
6500         return ret_ref;
6501 }
6502 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
6503         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6504         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 26);
6505         LDKShutdownScript ret_conv;
6506         ret_conv.inner = (void*)(ret & (~1));
6507         ret_conv.is_owned = (ret & 1) || (ret == 0);
6508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
6509         return ret_conv;
6510 }
6511 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
6512         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6513         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 27, (uint32_t)inbound, (uint32_t)channel_value_satoshis);
6514         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6515         CHECK_ACCESS(ret_ptr);
6516         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
6517         FREE((void*)ret);
6518         return ret_conv;
6519 }
6520 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
6521         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6522         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 28);
6523         LDKThirtyTwoBytes ret_ref;
6524         CHECK(ret->arr_len == 32);
6525         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
6526         return ret_ref;
6527 }
6528 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
6529         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6530         LDKu8slice reader_var = reader;
6531         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
6532         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
6533         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 29, (uint32_t)reader_arr);
6534         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6535         CHECK_ACCESS(ret_ptr);
6536         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
6537         FREE((void*)ret);
6538         return ret_conv;
6539 }
6540 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
6541         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6542         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
6543         int8_tArray invoice_preimage_arr = init_int8_tArray(invoice_preimage_var.datalen, __LINE__);
6544         memcpy(invoice_preimage_arr->elems, invoice_preimage_var.data, invoice_preimage_var.datalen);
6545         CVec_u8Z_free(invoice_preimage_var);
6546         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 30, (uint32_t)invoice_preimage_arr);
6547         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6548         CHECK_ACCESS(ret_ptr);
6549         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
6550         FREE((void*)ret);
6551         return ret_conv;
6552 }
6553 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
6554         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
6555         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 31);
6556         LDKThirtyTwoBytes ret_ref;
6557         CHECK(ret->arr_len == 32);
6558         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
6559         return ret_ref;
6560 }
6561 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
6562         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
6563         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6564 }
6565 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
6566         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
6567         atomic_init(&calls->refcnt, 1);
6568         calls->instance_ptr = o;
6569
6570         LDKKeysInterface ret = {
6571                 .this_arg = (void*) calls,
6572                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
6573                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
6574                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
6575                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
6576                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
6577                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
6578                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
6579                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
6580                 .free = LDKKeysInterface_JCalls_free,
6581         };
6582         return ret;
6583 }
6584 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
6585         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6586         *res_ptr = LDKKeysInterface_init(o);
6587         return (long)res_ptr;
6588 }
6589 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
6590         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6591         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6592         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6593         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6594         memcpy(ret_arr->elems, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
6595         return ret_arr;
6596 }
6597
6598 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
6599         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6600         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6601         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6602         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
6603         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6604         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6605         CVec_u8Z_free(ret_var);
6606         return ret_arr;
6607 }
6608
6609 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
6610         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6611         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6612         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6613         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
6614         uintptr_t ret_ref = 0;
6615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6618         ret_ref = (uintptr_t)ret_var.inner;
6619         if (ret_var.is_owned) {
6620                 ret_ref |= 1;
6621         }
6622         return ret_ref;
6623 }
6624
6625 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) {
6626         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6627         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6628         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6629         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6630         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
6631         return (uintptr_t)ret_ret;
6632 }
6633
6634 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
6635         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6636         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6637         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6638         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6639         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
6640         return ret_arr;
6641 }
6642
6643 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
6644         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6645         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6646         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6647         LDKu8slice reader_ref;
6648         reader_ref.datalen = reader->arr_len;
6649         reader_ref.data = reader->elems /* XXX reader leaks */;
6650         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
6651         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
6652         return (uintptr_t)ret_conv;
6653 }
6654
6655 uint32_t  __attribute__((export_name("TS_KeysInterface_sign_invoice"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
6656         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6657         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6658         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6659         LDKCVec_u8Z invoice_preimage_ref;
6660         invoice_preimage_ref.datalen = invoice_preimage->arr_len;
6661         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
6662         memcpy(invoice_preimage_ref.data, invoice_preimage->elems, invoice_preimage_ref.datalen); FREE(invoice_preimage);
6663         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
6664         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
6665         return (uintptr_t)ret_conv;
6666 }
6667
6668 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
6669         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6670         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6671         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
6672         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6673         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
6674         return ret_arr;
6675 }
6676
6677 typedef struct LDKFeeEstimator_JCalls {
6678         atomic_size_t refcnt;
6679         uint32_t instance_ptr;
6680 } LDKFeeEstimator_JCalls;
6681 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
6682         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6683         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6684                 FREE(j_calls);
6685         }
6686 }
6687 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
6688         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
6689         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
6690         return js_invoke_function_1(j_calls->instance_ptr, 32, (uint32_t)confirmation_target_conv);
6691 }
6692 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
6693         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
6694         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6695 }
6696 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
6697         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
6698         atomic_init(&calls->refcnt, 1);
6699         calls->instance_ptr = o;
6700
6701         LDKFeeEstimator ret = {
6702                 .this_arg = (void*) calls,
6703                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
6704                 .free = LDKFeeEstimator_JCalls_free,
6705         };
6706         return ret;
6707 }
6708 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
6709         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
6710         *res_ptr = LDKFeeEstimator_init(o);
6711         return (long)res_ptr;
6712 }
6713 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) {
6714         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6715         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6716         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
6717         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
6718         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
6719         return ret_val;
6720 }
6721
6722 typedef struct LDKLogger_JCalls {
6723         atomic_size_t refcnt;
6724         uint32_t instance_ptr;
6725 } LDKLogger_JCalls;
6726 static void LDKLogger_JCalls_free(void* this_arg) {
6727         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6728         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6729                 FREE(j_calls);
6730         }
6731 }
6732 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
6733         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
6734         LDKRecord record_var = *record;
6735         uintptr_t record_ref = 0;
6736         record_var = Record_clone(record);
6737         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6738         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6739         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
6740         record_ref = (uintptr_t)record_var.inner;
6741         if (record_var.is_owned) {
6742                 record_ref |= 1;
6743         }
6744         js_invoke_function_1(j_calls->instance_ptr, 33, (uint32_t)record_ref);
6745 }
6746 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
6747         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
6748         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6749 }
6750 static inline LDKLogger LDKLogger_init (JSValue o) {
6751         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
6752         atomic_init(&calls->refcnt, 1);
6753         calls->instance_ptr = o;
6754
6755         LDKLogger ret = {
6756                 .this_arg = (void*) calls,
6757                 .log = log_LDKLogger_jcall,
6758                 .free = LDKLogger_JCalls_free,
6759         };
6760         return ret;
6761 }
6762 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
6763         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
6764         *res_ptr = LDKLogger_init(o);
6765         return (long)res_ptr;
6766 }
6767 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6768         return ThirtyTwoBytes_clone(&owner->a);
6769 }
6770 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
6771         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6772         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6773         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
6774         return ret_arr;
6775 }
6776
6777 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
6778         return &owner->b;
6779 }
6780 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
6781         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
6782         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
6783         uintptr_t ret_ref = 0;
6784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6787         ret_ref = (uintptr_t)ret_var.inner & ~1;
6788         return ret_ref;
6789 }
6790
6791 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6792 CHECK(owner->result_ok);
6793         return &*owner->contents.result;
6794 }
6795 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
6796         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6797         uintptr_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
6798         return ret_ret;
6799 }
6800
6801 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
6802 CHECK(!owner->result_ok);
6803         return DecodeError_clone(&*owner->contents.err);
6804 }
6805 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
6806         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
6807         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
6808         uintptr_t ret_ref = 0;
6809         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6810         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6812         ret_ref = (uintptr_t)ret_var.inner;
6813         if (ret_var.is_owned) {
6814                 ret_ref |= 1;
6815         }
6816         return ret_ref;
6817 }
6818
6819 typedef struct LDKMessageSendEventsProvider_JCalls {
6820         atomic_size_t refcnt;
6821         uint32_t instance_ptr;
6822 } LDKMessageSendEventsProvider_JCalls;
6823 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
6824         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6825         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6826                 FREE(j_calls);
6827         }
6828 }
6829 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
6830         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
6831         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 34);
6832         LDKCVec_MessageSendEventZ ret_constr;
6833         ret_constr.datalen = ret->arr_len;
6834         if (ret_constr.datalen > 0)
6835                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
6836         else
6837                 ret_constr.data = NULL;
6838         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
6839         for (size_t s = 0; s < ret_constr.datalen; s++) {
6840                 uint32_t ret_conv_18 = ret_vals[s];
6841                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
6842                 CHECK_ACCESS(ret_conv_18_ptr);
6843                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
6844                 FREE((void*)ret_conv_18);
6845                 ret_constr.data[s] = ret_conv_18_conv;
6846         }
6847         return ret_constr;
6848 }
6849 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
6850         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
6851         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6852 }
6853 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
6854         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
6855         atomic_init(&calls->refcnt, 1);
6856         calls->instance_ptr = o;
6857
6858         LDKMessageSendEventsProvider ret = {
6859                 .this_arg = (void*) calls,
6860                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
6861                 .free = LDKMessageSendEventsProvider_JCalls_free,
6862         };
6863         return ret;
6864 }
6865 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
6866         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6867         *res_ptr = LDKMessageSendEventsProvider_init(o);
6868         return (long)res_ptr;
6869 }
6870 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) {
6871         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6872         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6873         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
6874         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
6875         uint32_tArray ret_arr = NULL;
6876         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6877         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6878         for (size_t s = 0; s < ret_var.datalen; s++) {
6879                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6880                 *ret_conv_18_copy = ret_var.data[s];
6881                 uintptr_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
6882                 ret_arr_ptr[s] = ret_conv_18_ref;
6883         }
6884         
6885         FREE(ret_var.data);
6886         return ret_arr;
6887 }
6888
6889 typedef struct LDKEventHandler_JCalls {
6890         atomic_size_t refcnt;
6891         uint32_t instance_ptr;
6892 } LDKEventHandler_JCalls;
6893 static void LDKEventHandler_JCalls_free(void* this_arg) {
6894         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6895         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6896                 FREE(j_calls);
6897         }
6898 }
6899 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
6900         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
6901         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
6902         *ret_event = Event_clone(event);
6903         js_invoke_function_1(j_calls->instance_ptr, 35, (uint32_t)(uintptr_t)ret_event);
6904 }
6905 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
6906         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
6907         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6908 }
6909 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
6910         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
6911         atomic_init(&calls->refcnt, 1);
6912         calls->instance_ptr = o;
6913
6914         LDKEventHandler ret = {
6915                 .this_arg = (void*) calls,
6916                 .handle_event = handle_event_LDKEventHandler_jcall,
6917                 .free = LDKEventHandler_JCalls_free,
6918         };
6919         return ret;
6920 }
6921 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
6922         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6923         *res_ptr = LDKEventHandler_init(o);
6924         return (long)res_ptr;
6925 }
6926 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
6927         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6928         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6929         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
6930         LDKEvent* event_conv = (LDKEvent*)event;
6931         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
6932 }
6933
6934 typedef struct LDKEventsProvider_JCalls {
6935         atomic_size_t refcnt;
6936         uint32_t instance_ptr;
6937 } LDKEventsProvider_JCalls;
6938 static void LDKEventsProvider_JCalls_free(void* this_arg) {
6939         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6940         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6941                 FREE(j_calls);
6942         }
6943 }
6944 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
6945         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
6946         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
6947         *handler_ret = handler;
6948         js_invoke_function_1(j_calls->instance_ptr, 36, (uint32_t)(uintptr_t)handler_ret);
6949 }
6950 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
6951         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
6952         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6953 }
6954 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
6955         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
6956         atomic_init(&calls->refcnt, 1);
6957         calls->instance_ptr = o;
6958
6959         LDKEventsProvider ret = {
6960                 .this_arg = (void*) calls,
6961                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
6962                 .free = LDKEventsProvider_JCalls_free,
6963         };
6964         return ret;
6965 }
6966 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
6967         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6968         *res_ptr = LDKEventsProvider_init(o);
6969         return (long)res_ptr;
6970 }
6971 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
6972         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6973         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6974         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
6975         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
6976         CHECK_ACCESS(handler_ptr);
6977         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
6978         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
6979 }
6980
6981 typedef struct LDKListen_JCalls {
6982         atomic_size_t refcnt;
6983         uint32_t instance_ptr;
6984 } LDKListen_JCalls;
6985 static void LDKListen_JCalls_free(void* this_arg) {
6986         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6987         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6988                 FREE(j_calls);
6989         }
6990 }
6991 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
6992         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
6993         LDKu8slice block_var = block;
6994         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
6995         memcpy(block_arr->elems, block_var.data, block_var.datalen);
6996         js_invoke_function_2(j_calls->instance_ptr, 37, (uint32_t)block_arr, (uint32_t)height);
6997 }
6998 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
6999         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7000         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
7001         memcpy(header_arr->elems, *header, 80);
7002         js_invoke_function_2(j_calls->instance_ptr, 38, (uint32_t)header_arr, (uint32_t)height);
7003 }
7004 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
7005         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
7006         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7007 }
7008 static inline LDKListen LDKListen_init (JSValue o) {
7009         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
7010         atomic_init(&calls->refcnt, 1);
7011         calls->instance_ptr = o;
7012
7013         LDKListen ret = {
7014                 .this_arg = (void*) calls,
7015                 .block_connected = block_connected_LDKListen_jcall,
7016                 .block_disconnected = block_disconnected_LDKListen_jcall,
7017                 .free = LDKListen_JCalls_free,
7018         };
7019         return ret;
7020 }
7021 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
7022         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
7023         *res_ptr = LDKListen_init(o);
7024         return (long)res_ptr;
7025 }
7026 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
7027         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7028         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7029         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7030         LDKu8slice block_ref;
7031         block_ref.datalen = block->arr_len;
7032         block_ref.data = block->elems /* XXX block leaks */;
7033         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
7034 }
7035
7036 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
7037         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7038         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7039         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7040         unsigned char header_arr[80];
7041         CHECK(header->arr_len == 80);
7042         memcpy(header_arr, header->elems, 80); FREE(header);
7043         unsigned char (*header_ref)[80] = &header_arr;
7044         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
7045 }
7046
7047 typedef struct LDKConfirm_JCalls {
7048         atomic_size_t refcnt;
7049         uint32_t instance_ptr;
7050 } LDKConfirm_JCalls;
7051 static void LDKConfirm_JCalls_free(void* this_arg) {
7052         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7053         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7054                 FREE(j_calls);
7055         }
7056 }
7057 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
7058         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7059         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
7060         memcpy(header_arr->elems, *header, 80);
7061         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
7062         uint32_tArray txdata_arr = NULL;
7063         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
7064         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
7065         for (size_t c = 0; c < txdata_var.datalen; c++) {
7066                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7067                 *txdata_conv_28_conv = txdata_var.data[c];
7068                 txdata_arr_ptr[c] = ((uintptr_t)txdata_conv_28_conv);
7069         }
7070         
7071         FREE(txdata_var.data);
7072         js_invoke_function_3(j_calls->instance_ptr, 39, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height);
7073 }
7074 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
7075         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7076         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
7077         memcpy(txid_arr->elems, *txid, 32);
7078         js_invoke_function_1(j_calls->instance_ptr, 40, (uint32_t)txid_arr);
7079 }
7080 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7081         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7082         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
7083         memcpy(header_arr->elems, *header, 80);
7084         js_invoke_function_2(j_calls->instance_ptr, 41, (uint32_t)header_arr, (uint32_t)height);
7085 }
7086 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
7087         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7088         ptrArray ret = (ptrArray)js_invoke_function_0(j_calls->instance_ptr, 42);
7089         LDKCVec_TxidZ ret_constr;
7090         ret_constr.datalen = ret->arr_len;
7091         if (ret_constr.datalen > 0)
7092                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7093         else
7094                 ret_constr.data = NULL;
7095         int8_tArray* ret_vals = (void*) ret->elems /* XXX ret leaks */;
7096         for (size_t m = 0; m < ret_constr.datalen; m++) {
7097                 int8_tArray ret_conv_12 = ret_vals[m];
7098                 LDKThirtyTwoBytes ret_conv_12_ref;
7099                 CHECK(ret_conv_12->arr_len == 32);
7100                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
7101                 ret_constr.data[m] = ret_conv_12_ref;
7102         }
7103         return ret_constr;
7104 }
7105 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
7106         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
7107         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7108 }
7109 static inline LDKConfirm LDKConfirm_init (JSValue o) {
7110         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
7111         atomic_init(&calls->refcnt, 1);
7112         calls->instance_ptr = o;
7113
7114         LDKConfirm ret = {
7115                 .this_arg = (void*) calls,
7116                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
7117                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
7118                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
7119                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
7120                 .free = LDKConfirm_JCalls_free,
7121         };
7122         return ret;
7123 }
7124 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
7125         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
7126         *res_ptr = LDKConfirm_init(o);
7127         return (long)res_ptr;
7128 }
7129 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) {
7130         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7131         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7132         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7133         unsigned char header_arr[80];
7134         CHECK(header->arr_len == 80);
7135         memcpy(header_arr, header->elems, 80); FREE(header);
7136         unsigned char (*header_ref)[80] = &header_arr;
7137         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
7138         txdata_constr.datalen = txdata->arr_len;
7139         if (txdata_constr.datalen > 0)
7140                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7141         else
7142                 txdata_constr.data = NULL;
7143         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
7144         for (size_t c = 0; c < txdata_constr.datalen; c++) {
7145                 uint32_t txdata_conv_28 = txdata_vals[c];
7146                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
7147                 CHECK_ACCESS(txdata_conv_28_ptr);
7148                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
7149                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
7150                 txdata_constr.data[c] = txdata_conv_28_conv;
7151         }
7152         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
7153 }
7154
7155 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
7156         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7157         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7158         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7159         unsigned char txid_arr[32];
7160         CHECK(txid->arr_len == 32);
7161         memcpy(txid_arr, txid->elems, 32); FREE(txid);
7162         unsigned char (*txid_ref)[32] = &txid_arr;
7163         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
7164 }
7165
7166 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
7167         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7168         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7169         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7170         unsigned char header_arr[80];
7171         CHECK(header->arr_len == 80);
7172         memcpy(header_arr, header->elems, 80); FREE(header);
7173         unsigned char (*header_ref)[80] = &header_arr;
7174         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
7175 }
7176
7177 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
7178         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7179         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7180         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7181         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
7182         ptrArray ret_arr = NULL;
7183         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
7184         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
7185         for (size_t m = 0; m < ret_var.datalen; m++) {
7186                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
7187                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
7188                 ret_arr_ptr[m] = ret_conv_12_arr;
7189         }
7190         
7191         FREE(ret_var.data);
7192         return ret_arr;
7193 }
7194
7195 typedef struct LDKPersist_JCalls {
7196         atomic_size_t refcnt;
7197         uint32_t instance_ptr;
7198 } LDKPersist_JCalls;
7199 static void LDKPersist_JCalls_free(void* this_arg) {
7200         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7201         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7202                 FREE(j_calls);
7203         }
7204 }
7205 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
7206         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7207         LDKOutPoint channel_id_var = channel_id;
7208         uintptr_t channel_id_ref = 0;
7209         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7210         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7211         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
7212         channel_id_ref = (uintptr_t)channel_id_var.inner;
7213         if (channel_id_var.is_owned) {
7214                 channel_id_ref |= 1;
7215         }
7216         LDKChannelMonitor data_var = *data;
7217         uintptr_t data_ref = 0;
7218         data_var = ChannelMonitor_clone(data);
7219         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7220         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7221         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
7222         data_ref = (uintptr_t)data_var.inner;
7223         if (data_var.is_owned) {
7224                 data_ref |= 1;
7225         }
7226         LDKMonitorUpdateId update_id_var = update_id;
7227         uintptr_t update_id_ref = 0;
7228         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7229         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7230         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
7231         update_id_ref = (uintptr_t)update_id_var.inner;
7232         if (update_id_var.is_owned) {
7233                 update_id_ref |= 1;
7234         }
7235         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);
7236         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7237         CHECK_ACCESS(ret_ptr);
7238         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
7239         FREE((void*)ret);
7240         return ret_conv;
7241 }
7242 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
7243         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7244         LDKOutPoint channel_id_var = channel_id;
7245         uintptr_t channel_id_ref = 0;
7246         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7247         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7248         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
7249         channel_id_ref = (uintptr_t)channel_id_var.inner;
7250         if (channel_id_var.is_owned) {
7251                 channel_id_ref |= 1;
7252         }
7253         LDKChannelMonitorUpdate update_var = *update;
7254         uintptr_t update_ref = 0;
7255         if ((uintptr_t)update_var.inner > 4096) {
7256                 update_var = ChannelMonitorUpdate_clone(update);
7257                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7258                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7259         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
7260                 update_ref = (uintptr_t)update_var.inner;
7261                 if (update_var.is_owned) {
7262                         update_ref |= 1;
7263                 }
7264         }
7265         LDKChannelMonitor data_var = *data;
7266         uintptr_t data_ref = 0;
7267         data_var = ChannelMonitor_clone(data);
7268         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7269         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7270         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
7271         data_ref = (uintptr_t)data_var.inner;
7272         if (data_var.is_owned) {
7273                 data_ref |= 1;
7274         }
7275         LDKMonitorUpdateId update_id_var = update_id;
7276         uintptr_t update_id_ref = 0;
7277         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7278         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7279         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
7280         update_id_ref = (uintptr_t)update_id_var.inner;
7281         if (update_id_var.is_owned) {
7282                 update_id_ref |= 1;
7283         }
7284         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);
7285         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7286         CHECK_ACCESS(ret_ptr);
7287         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
7288         FREE((void*)ret);
7289         return ret_conv;
7290 }
7291 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
7292         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
7293         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7294 }
7295 static inline LDKPersist LDKPersist_init (JSValue o) {
7296         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
7297         atomic_init(&calls->refcnt, 1);
7298         calls->instance_ptr = o;
7299
7300         LDKPersist ret = {
7301                 .this_arg = (void*) calls,
7302                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
7303                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
7304                 .free = LDKPersist_JCalls_free,
7305         };
7306         return ret;
7307 }
7308 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
7309         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
7310         *res_ptr = LDKPersist_init(o);
7311         return (long)res_ptr;
7312 }
7313 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) {
7314         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7315         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7316         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
7317         LDKOutPoint channel_id_conv;
7318         channel_id_conv.inner = (void*)(channel_id & (~1));
7319         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
7320         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
7321         channel_id_conv = OutPoint_clone(&channel_id_conv);
7322         LDKChannelMonitor data_conv;
7323         data_conv.inner = (void*)(data & (~1));
7324         data_conv.is_owned = false;
7325         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
7326         LDKMonitorUpdateId update_id_conv;
7327         update_id_conv.inner = (void*)(update_id & (~1));
7328         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
7329         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
7330         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
7331         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7332         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
7333         return (uintptr_t)ret_conv;
7334 }
7335
7336 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) {
7337         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7338         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7339         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
7340         LDKOutPoint channel_id_conv;
7341         channel_id_conv.inner = (void*)(channel_id & (~1));
7342         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
7343         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
7344         channel_id_conv = OutPoint_clone(&channel_id_conv);
7345         LDKChannelMonitorUpdate update_conv;
7346         update_conv.inner = (void*)(update & (~1));
7347         update_conv.is_owned = false;
7348         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
7349         LDKChannelMonitor data_conv;
7350         data_conv.inner = (void*)(data & (~1));
7351         data_conv.is_owned = false;
7352         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
7353         LDKMonitorUpdateId update_id_conv;
7354         update_id_conv.inner = (void*)(update_id & (~1));
7355         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
7356         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
7357         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
7358         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
7359         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
7360         return (uintptr_t)ret_conv;
7361 }
7362
7363 typedef struct LDKChannelMessageHandler_JCalls {
7364         atomic_size_t refcnt;
7365         uint32_t instance_ptr;
7366         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
7367 } LDKChannelMessageHandler_JCalls;
7368 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
7369         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7370         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7371                 FREE(j_calls);
7372         }
7373 }
7374 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
7375         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7376         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7377         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7378         LDKInitFeatures their_features_var = their_features;
7379         uintptr_t their_features_ref = 0;
7380         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7381         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7382         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
7383         their_features_ref = (uintptr_t)their_features_var.inner;
7384         if (their_features_var.is_owned) {
7385                 their_features_ref |= 1;
7386         }
7387         LDKOpenChannel msg_var = *msg;
7388         uintptr_t msg_ref = 0;
7389         msg_var = OpenChannel_clone(msg);
7390         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7391         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7392         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7393         msg_ref = (uintptr_t)msg_var.inner;
7394         if (msg_var.is_owned) {
7395                 msg_ref |= 1;
7396         }
7397         js_invoke_function_3(j_calls->instance_ptr, 45, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
7398 }
7399 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
7400         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7401         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7402         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7403         LDKInitFeatures their_features_var = their_features;
7404         uintptr_t their_features_ref = 0;
7405         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7406         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7407         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
7408         their_features_ref = (uintptr_t)their_features_var.inner;
7409         if (their_features_var.is_owned) {
7410                 their_features_ref |= 1;
7411         }
7412         LDKAcceptChannel msg_var = *msg;
7413         uintptr_t msg_ref = 0;
7414         msg_var = AcceptChannel_clone(msg);
7415         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7416         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7417         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7418         msg_ref = (uintptr_t)msg_var.inner;
7419         if (msg_var.is_owned) {
7420                 msg_ref |= 1;
7421         }
7422         js_invoke_function_3(j_calls->instance_ptr, 46, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
7423 }
7424 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
7425         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7426         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7427         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7428         LDKFundingCreated msg_var = *msg;
7429         uintptr_t msg_ref = 0;
7430         msg_var = FundingCreated_clone(msg);
7431         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7432         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7433         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7434         msg_ref = (uintptr_t)msg_var.inner;
7435         if (msg_var.is_owned) {
7436                 msg_ref |= 1;
7437         }
7438         js_invoke_function_2(j_calls->instance_ptr, 47, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7439 }
7440 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
7441         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7442         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7443         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7444         LDKFundingSigned msg_var = *msg;
7445         uintptr_t msg_ref = 0;
7446         msg_var = FundingSigned_clone(msg);
7447         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7448         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7449         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7450         msg_ref = (uintptr_t)msg_var.inner;
7451         if (msg_var.is_owned) {
7452                 msg_ref |= 1;
7453         }
7454         js_invoke_function_2(j_calls->instance_ptr, 48, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7455 }
7456 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
7457         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7458         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7459         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7460         LDKFundingLocked msg_var = *msg;
7461         uintptr_t msg_ref = 0;
7462         msg_var = FundingLocked_clone(msg);
7463         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7464         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7465         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7466         msg_ref = (uintptr_t)msg_var.inner;
7467         if (msg_var.is_owned) {
7468                 msg_ref |= 1;
7469         }
7470         js_invoke_function_2(j_calls->instance_ptr, 49, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7471 }
7472 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
7473         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7474         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7475         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7476         LDKInitFeatures their_features_var = *their_features;
7477         uintptr_t their_features_ref = 0;
7478         their_features_var = InitFeatures_clone(their_features);
7479         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7480         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7481         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
7482         their_features_ref = (uintptr_t)their_features_var.inner;
7483         if (their_features_var.is_owned) {
7484                 their_features_ref |= 1;
7485         }
7486         LDKShutdown msg_var = *msg;
7487         uintptr_t msg_ref = 0;
7488         msg_var = Shutdown_clone(msg);
7489         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7490         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7491         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7492         msg_ref = (uintptr_t)msg_var.inner;
7493         if (msg_var.is_owned) {
7494                 msg_ref |= 1;
7495         }
7496         js_invoke_function_3(j_calls->instance_ptr, 50, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
7497 }
7498 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
7499         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7500         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7501         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7502         LDKClosingSigned msg_var = *msg;
7503         uintptr_t msg_ref = 0;
7504         msg_var = ClosingSigned_clone(msg);
7505         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7506         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7507         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7508         msg_ref = (uintptr_t)msg_var.inner;
7509         if (msg_var.is_owned) {
7510                 msg_ref |= 1;
7511         }
7512         js_invoke_function_2(j_calls->instance_ptr, 51, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7513 }
7514 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
7515         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7516         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7517         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7518         LDKUpdateAddHTLC msg_var = *msg;
7519         uintptr_t msg_ref = 0;
7520         msg_var = UpdateAddHTLC_clone(msg);
7521         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7522         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7523         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7524         msg_ref = (uintptr_t)msg_var.inner;
7525         if (msg_var.is_owned) {
7526                 msg_ref |= 1;
7527         }
7528         js_invoke_function_2(j_calls->instance_ptr, 52, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7529 }
7530 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
7531         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7532         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7533         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7534         LDKUpdateFulfillHTLC msg_var = *msg;
7535         uintptr_t msg_ref = 0;
7536         msg_var = UpdateFulfillHTLC_clone(msg);
7537         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7538         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7539         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7540         msg_ref = (uintptr_t)msg_var.inner;
7541         if (msg_var.is_owned) {
7542                 msg_ref |= 1;
7543         }
7544         js_invoke_function_2(j_calls->instance_ptr, 53, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7545 }
7546 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
7547         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7548         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7549         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7550         LDKUpdateFailHTLC msg_var = *msg;
7551         uintptr_t msg_ref = 0;
7552         msg_var = UpdateFailHTLC_clone(msg);
7553         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7554         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7555         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7556         msg_ref = (uintptr_t)msg_var.inner;
7557         if (msg_var.is_owned) {
7558                 msg_ref |= 1;
7559         }
7560         js_invoke_function_2(j_calls->instance_ptr, 54, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7561 }
7562 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
7563         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7564         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7565         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7566         LDKUpdateFailMalformedHTLC msg_var = *msg;
7567         uintptr_t msg_ref = 0;
7568         msg_var = UpdateFailMalformedHTLC_clone(msg);
7569         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7570         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7571         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7572         msg_ref = (uintptr_t)msg_var.inner;
7573         if (msg_var.is_owned) {
7574                 msg_ref |= 1;
7575         }
7576         js_invoke_function_2(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7577 }
7578 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
7579         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7580         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7581         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7582         LDKCommitmentSigned msg_var = *msg;
7583         uintptr_t msg_ref = 0;
7584         msg_var = CommitmentSigned_clone(msg);
7585         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7586         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7587         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7588         msg_ref = (uintptr_t)msg_var.inner;
7589         if (msg_var.is_owned) {
7590                 msg_ref |= 1;
7591         }
7592         js_invoke_function_2(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7593 }
7594 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
7595         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7596         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7597         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7598         LDKRevokeAndACK msg_var = *msg;
7599         uintptr_t msg_ref = 0;
7600         msg_var = RevokeAndACK_clone(msg);
7601         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7602         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7603         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7604         msg_ref = (uintptr_t)msg_var.inner;
7605         if (msg_var.is_owned) {
7606                 msg_ref |= 1;
7607         }
7608         js_invoke_function_2(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7609 }
7610 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
7611         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7612         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7613         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7614         LDKUpdateFee msg_var = *msg;
7615         uintptr_t msg_ref = 0;
7616         msg_var = UpdateFee_clone(msg);
7617         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7618         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7619         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7620         msg_ref = (uintptr_t)msg_var.inner;
7621         if (msg_var.is_owned) {
7622                 msg_ref |= 1;
7623         }
7624         js_invoke_function_2(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7625 }
7626 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
7627         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7628         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7629         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7630         LDKAnnouncementSignatures msg_var = *msg;
7631         uintptr_t msg_ref = 0;
7632         msg_var = AnnouncementSignatures_clone(msg);
7633         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7634         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7635         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7636         msg_ref = (uintptr_t)msg_var.inner;
7637         if (msg_var.is_owned) {
7638                 msg_ref |= 1;
7639         }
7640         js_invoke_function_2(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7641 }
7642 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
7643         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7644         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7645         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7646         js_invoke_function_2(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible);
7647 }
7648 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
7649         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7650         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7651         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7652         LDKInit msg_var = *msg;
7653         uintptr_t msg_ref = 0;
7654         msg_var = Init_clone(msg);
7655         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7656         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7657         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7658         msg_ref = (uintptr_t)msg_var.inner;
7659         if (msg_var.is_owned) {
7660                 msg_ref |= 1;
7661         }
7662         js_invoke_function_2(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7663 }
7664 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
7665         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7666         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7667         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7668         LDKChannelReestablish msg_var = *msg;
7669         uintptr_t msg_ref = 0;
7670         msg_var = ChannelReestablish_clone(msg);
7671         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7672         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7673         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7674         msg_ref = (uintptr_t)msg_var.inner;
7675         if (msg_var.is_owned) {
7676                 msg_ref |= 1;
7677         }
7678         js_invoke_function_2(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7679 }
7680 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
7681         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7682         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7683         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7684         LDKChannelUpdate msg_var = *msg;
7685         uintptr_t msg_ref = 0;
7686         msg_var = ChannelUpdate_clone(msg);
7687         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7688         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7689         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7690         msg_ref = (uintptr_t)msg_var.inner;
7691         if (msg_var.is_owned) {
7692                 msg_ref |= 1;
7693         }
7694         js_invoke_function_2(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7695 }
7696 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
7697         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
7698         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
7699         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
7700         LDKErrorMessage msg_var = *msg;
7701         uintptr_t msg_ref = 0;
7702         msg_var = ErrorMessage_clone(msg);
7703         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7704         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7705         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
7706         msg_ref = (uintptr_t)msg_var.inner;
7707         if (msg_var.is_owned) {
7708                 msg_ref |= 1;
7709         }
7710         js_invoke_function_2(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
7711 }
7712 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
7713         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
7714         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7715         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
7716 }
7717 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
7718         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
7719         atomic_init(&calls->refcnt, 1);
7720         calls->instance_ptr = o;
7721
7722         LDKChannelMessageHandler ret = {
7723                 .this_arg = (void*) calls,
7724                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
7725                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
7726                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
7727                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
7728                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
7729                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
7730                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
7731                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
7732                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
7733                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
7734                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
7735                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
7736                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
7737                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
7738                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
7739                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
7740                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
7741                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
7742                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
7743                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
7744                 .free = LDKChannelMessageHandler_JCalls_free,
7745                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
7746         };
7747         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
7748         return ret;
7749 }
7750 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
7751         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7752         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
7753         return (long)res_ptr;
7754 }
7755 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) {
7756         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7757         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7758         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7759         LDKPublicKey their_node_id_ref;
7760         CHECK(their_node_id->arr_len == 33);
7761         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7762         LDKInitFeatures their_features_conv;
7763         their_features_conv.inner = (void*)(their_features & (~1));
7764         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7765         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
7766         their_features_conv = InitFeatures_clone(&their_features_conv);
7767         LDKOpenChannel msg_conv;
7768         msg_conv.inner = (void*)(msg & (~1));
7769         msg_conv.is_owned = false;
7770         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7771         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7772 }
7773
7774 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) {
7775         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7776         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7777         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7778         LDKPublicKey their_node_id_ref;
7779         CHECK(their_node_id->arr_len == 33);
7780         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7781         LDKInitFeatures their_features_conv;
7782         their_features_conv.inner = (void*)(their_features & (~1));
7783         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
7784         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
7785         their_features_conv = InitFeatures_clone(&their_features_conv);
7786         LDKAcceptChannel msg_conv;
7787         msg_conv.inner = (void*)(msg & (~1));
7788         msg_conv.is_owned = false;
7789         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7790         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
7791 }
7792
7793 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) {
7794         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7795         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7796         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7797         LDKPublicKey their_node_id_ref;
7798         CHECK(their_node_id->arr_len == 33);
7799         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7800         LDKFundingCreated msg_conv;
7801         msg_conv.inner = (void*)(msg & (~1));
7802         msg_conv.is_owned = false;
7803         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7804         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7805 }
7806
7807 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) {
7808         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7809         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7810         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7811         LDKPublicKey their_node_id_ref;
7812         CHECK(their_node_id->arr_len == 33);
7813         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7814         LDKFundingSigned msg_conv;
7815         msg_conv.inner = (void*)(msg & (~1));
7816         msg_conv.is_owned = false;
7817         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7818         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7819 }
7820
7821 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) {
7822         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7823         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7824         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7825         LDKPublicKey their_node_id_ref;
7826         CHECK(their_node_id->arr_len == 33);
7827         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7828         LDKFundingLocked msg_conv;
7829         msg_conv.inner = (void*)(msg & (~1));
7830         msg_conv.is_owned = false;
7831         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7832         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7833 }
7834
7835 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) {
7836         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7837         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7838         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7839         LDKPublicKey their_node_id_ref;
7840         CHECK(their_node_id->arr_len == 33);
7841         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7842         LDKInitFeatures their_features_conv;
7843         their_features_conv.inner = (void*)(their_features & (~1));
7844         their_features_conv.is_owned = false;
7845         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
7846         LDKShutdown msg_conv;
7847         msg_conv.inner = (void*)(msg & (~1));
7848         msg_conv.is_owned = false;
7849         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7850         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
7851 }
7852
7853 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) {
7854         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7855         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7856         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7857         LDKPublicKey their_node_id_ref;
7858         CHECK(their_node_id->arr_len == 33);
7859         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7860         LDKClosingSigned msg_conv;
7861         msg_conv.inner = (void*)(msg & (~1));
7862         msg_conv.is_owned = false;
7863         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7864         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7865 }
7866
7867 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) {
7868         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7869         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7870         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7871         LDKPublicKey their_node_id_ref;
7872         CHECK(their_node_id->arr_len == 33);
7873         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7874         LDKUpdateAddHTLC msg_conv;
7875         msg_conv.inner = (void*)(msg & (~1));
7876         msg_conv.is_owned = false;
7877         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7878         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7879 }
7880
7881 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) {
7882         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7883         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7884         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7885         LDKPublicKey their_node_id_ref;
7886         CHECK(their_node_id->arr_len == 33);
7887         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7888         LDKUpdateFulfillHTLC msg_conv;
7889         msg_conv.inner = (void*)(msg & (~1));
7890         msg_conv.is_owned = false;
7891         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7892         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7893 }
7894
7895 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) {
7896         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7897         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7898         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7899         LDKPublicKey their_node_id_ref;
7900         CHECK(their_node_id->arr_len == 33);
7901         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7902         LDKUpdateFailHTLC msg_conv;
7903         msg_conv.inner = (void*)(msg & (~1));
7904         msg_conv.is_owned = false;
7905         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7906         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7907 }
7908
7909 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) {
7910         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7911         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7912         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7913         LDKPublicKey their_node_id_ref;
7914         CHECK(their_node_id->arr_len == 33);
7915         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7916         LDKUpdateFailMalformedHTLC msg_conv;
7917         msg_conv.inner = (void*)(msg & (~1));
7918         msg_conv.is_owned = false;
7919         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7920         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7921 }
7922
7923 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) {
7924         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7925         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7926         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7927         LDKPublicKey their_node_id_ref;
7928         CHECK(their_node_id->arr_len == 33);
7929         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7930         LDKCommitmentSigned msg_conv;
7931         msg_conv.inner = (void*)(msg & (~1));
7932         msg_conv.is_owned = false;
7933         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7934         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7935 }
7936
7937 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) {
7938         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7939         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7940         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7941         LDKPublicKey their_node_id_ref;
7942         CHECK(their_node_id->arr_len == 33);
7943         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7944         LDKRevokeAndACK msg_conv;
7945         msg_conv.inner = (void*)(msg & (~1));
7946         msg_conv.is_owned = false;
7947         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7948         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7949 }
7950
7951 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) {
7952         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7953         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7954         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7955         LDKPublicKey their_node_id_ref;
7956         CHECK(their_node_id->arr_len == 33);
7957         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7958         LDKUpdateFee msg_conv;
7959         msg_conv.inner = (void*)(msg & (~1));
7960         msg_conv.is_owned = false;
7961         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7962         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7963 }
7964
7965 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) {
7966         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7967         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7968         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7969         LDKPublicKey their_node_id_ref;
7970         CHECK(their_node_id->arr_len == 33);
7971         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7972         LDKAnnouncementSignatures msg_conv;
7973         msg_conv.inner = (void*)(msg & (~1));
7974         msg_conv.is_owned = false;
7975         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
7976         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
7977 }
7978
7979 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) {
7980         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7981         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7982         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7983         LDKPublicKey their_node_id_ref;
7984         CHECK(their_node_id->arr_len == 33);
7985         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7986         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
7987 }
7988
7989 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
7990         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7991         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7992         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
7993         LDKPublicKey their_node_id_ref;
7994         CHECK(their_node_id->arr_len == 33);
7995         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
7996         LDKInit msg_conv;
7997         msg_conv.inner = (void*)(msg & (~1));
7998         msg_conv.is_owned = false;
7999         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8000         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8001 }
8002
8003 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) {
8004         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8005         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8006         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8007         LDKPublicKey their_node_id_ref;
8008         CHECK(their_node_id->arr_len == 33);
8009         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8010         LDKChannelReestablish msg_conv;
8011         msg_conv.inner = (void*)(msg & (~1));
8012         msg_conv.is_owned = false;
8013         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8014         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8015 }
8016
8017 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) {
8018         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8019         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8020         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8021         LDKPublicKey their_node_id_ref;
8022         CHECK(their_node_id->arr_len == 33);
8023         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8024         LDKChannelUpdate msg_conv;
8025         msg_conv.inner = (void*)(msg & (~1));
8026         msg_conv.is_owned = false;
8027         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8028         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8029 }
8030
8031 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
8032         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8033         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8034         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8035         LDKPublicKey their_node_id_ref;
8036         CHECK(their_node_id->arr_len == 33);
8037         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8038         LDKErrorMessage msg_conv;
8039         msg_conv.inner = (void*)(msg & (~1));
8040         msg_conv.is_owned = false;
8041         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8042         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8043 }
8044
8045 typedef struct LDKRoutingMessageHandler_JCalls {
8046         atomic_size_t refcnt;
8047         uint32_t instance_ptr;
8048         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8049 } LDKRoutingMessageHandler_JCalls;
8050 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
8051         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8052         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8053                 FREE(j_calls);
8054         }
8055 }
8056 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
8057         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8058         LDKNodeAnnouncement msg_var = *msg;
8059         uintptr_t msg_ref = 0;
8060         msg_var = NodeAnnouncement_clone(msg);
8061         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8062         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8063         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8064         msg_ref = (uintptr_t)msg_var.inner;
8065         if (msg_var.is_owned) {
8066                 msg_ref |= 1;
8067         }
8068         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 65, (uint32_t)msg_ref);
8069         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8070         CHECK_ACCESS(ret_ptr);
8071         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
8072         FREE((void*)ret);
8073         return ret_conv;
8074 }
8075 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
8076         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8077         LDKChannelAnnouncement msg_var = *msg;
8078         uintptr_t msg_ref = 0;
8079         msg_var = ChannelAnnouncement_clone(msg);
8080         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8081         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8082         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8083         msg_ref = (uintptr_t)msg_var.inner;
8084         if (msg_var.is_owned) {
8085                 msg_ref |= 1;
8086         }
8087         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 66, (uint32_t)msg_ref);
8088         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8089         CHECK_ACCESS(ret_ptr);
8090         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
8091         FREE((void*)ret);
8092         return ret_conv;
8093 }
8094 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
8095         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8096         LDKChannelUpdate msg_var = *msg;
8097         uintptr_t msg_ref = 0;
8098         msg_var = ChannelUpdate_clone(msg);
8099         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8100         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8101         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8102         msg_ref = (uintptr_t)msg_var.inner;
8103         if (msg_var.is_owned) {
8104                 msg_ref |= 1;
8105         }
8106         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 67, (uint32_t)msg_ref);
8107         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8108         CHECK_ACCESS(ret_ptr);
8109         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
8110         FREE((void*)ret);
8111         return ret_conv;
8112 }
8113 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
8114         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8115         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 68, (uint32_t)starting_point, (uint32_t)batch_amount);
8116         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
8117         ret_constr.datalen = ret->arr_len;
8118         if (ret_constr.datalen > 0)
8119                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
8120         else
8121                 ret_constr.data = NULL;
8122         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
8123         for (size_t h = 0; h < ret_constr.datalen; h++) {
8124                 uint32_t ret_conv_59 = ret_vals[h];
8125                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
8126                 CHECK_ACCESS(ret_conv_59_ptr);
8127                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
8128                 FREE((void*)ret_conv_59);
8129                 ret_constr.data[h] = ret_conv_59_conv;
8130         }
8131         return ret_constr;
8132 }
8133 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
8134         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8135         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
8136         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
8137         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 69, (uint32_t)starting_point_arr, (uint32_t)batch_amount);
8138         LDKCVec_NodeAnnouncementZ ret_constr;
8139         ret_constr.datalen = ret->arr_len;
8140         if (ret_constr.datalen > 0)
8141                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
8142         else
8143                 ret_constr.data = NULL;
8144         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
8145         for (size_t s = 0; s < ret_constr.datalen; s++) {
8146                 uint32_t ret_conv_18 = ret_vals[s];
8147                 LDKNodeAnnouncement ret_conv_18_conv;
8148                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
8149                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
8150                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
8151                 ret_constr.data[s] = ret_conv_18_conv;
8152         }
8153         return ret_constr;
8154 }
8155 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
8156         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8157         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8158         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8159         LDKInit init_var = *init;
8160         uintptr_t init_ref = 0;
8161         init_var = Init_clone(init);
8162         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8163         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8164         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
8165         init_ref = (uintptr_t)init_var.inner;
8166         if (init_var.is_owned) {
8167                 init_ref |= 1;
8168         }
8169         js_invoke_function_2(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
8170 }
8171 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
8172         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8173         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8174         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8175         LDKReplyChannelRange msg_var = msg;
8176         uintptr_t msg_ref = 0;
8177         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8178         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8179         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8180         msg_ref = (uintptr_t)msg_var.inner;
8181         if (msg_var.is_owned) {
8182                 msg_ref |= 1;
8183         }
8184         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8185         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8186         CHECK_ACCESS(ret_ptr);
8187         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8188         FREE((void*)ret);
8189         return ret_conv;
8190 }
8191 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
8192         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8193         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8194         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8195         LDKReplyShortChannelIdsEnd msg_var = msg;
8196         uintptr_t msg_ref = 0;
8197         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8198         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8199         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8200         msg_ref = (uintptr_t)msg_var.inner;
8201         if (msg_var.is_owned) {
8202                 msg_ref |= 1;
8203         }
8204         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8205         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8206         CHECK_ACCESS(ret_ptr);
8207         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8208         FREE((void*)ret);
8209         return ret_conv;
8210 }
8211 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
8212         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8213         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8214         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8215         LDKQueryChannelRange msg_var = msg;
8216         uintptr_t msg_ref = 0;
8217         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8218         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8219         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8220         msg_ref = (uintptr_t)msg_var.inner;
8221         if (msg_var.is_owned) {
8222                 msg_ref |= 1;
8223         }
8224         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8225         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8226         CHECK_ACCESS(ret_ptr);
8227         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8228         FREE((void*)ret);
8229         return ret_conv;
8230 }
8231 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
8232         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
8233         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8234         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8235         LDKQueryShortChannelIds msg_var = msg;
8236         uintptr_t msg_ref = 0;
8237         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8238         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8239         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8240         msg_ref = (uintptr_t)msg_var.inner;
8241         if (msg_var.is_owned) {
8242                 msg_ref |= 1;
8243         }
8244         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8245         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8246         CHECK_ACCESS(ret_ptr);
8247         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8248         FREE((void*)ret);
8249         return ret_conv;
8250 }
8251 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
8252         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
8253         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8254         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8255 }
8256 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
8257         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
8258         atomic_init(&calls->refcnt, 1);
8259         calls->instance_ptr = o;
8260
8261         LDKRoutingMessageHandler ret = {
8262                 .this_arg = (void*) calls,
8263                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
8264                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
8265                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
8266                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
8267                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
8268                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
8269                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
8270                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
8271                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
8272                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
8273                 .free = LDKRoutingMessageHandler_JCalls_free,
8274                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
8275         };
8276         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8277         return ret;
8278 }
8279 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
8280         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
8281         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
8282         return (long)res_ptr;
8283 }
8284 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
8285         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8286         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8287         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8288         LDKNodeAnnouncement msg_conv;
8289         msg_conv.inner = (void*)(msg & (~1));
8290         msg_conv.is_owned = false;
8291         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8292         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8293         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
8294         return (uintptr_t)ret_conv;
8295 }
8296
8297 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
8298         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8299         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8300         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8301         LDKChannelAnnouncement msg_conv;
8302         msg_conv.inner = (void*)(msg & (~1));
8303         msg_conv.is_owned = false;
8304         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8305         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8306         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
8307         return (uintptr_t)ret_conv;
8308 }
8309
8310 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
8311         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8312         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8313         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8314         LDKChannelUpdate msg_conv;
8315         msg_conv.inner = (void*)(msg & (~1));
8316         msg_conv.is_owned = false;
8317         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8318         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
8319         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
8320         return (uintptr_t)ret_conv;
8321 }
8322
8323 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) {
8324         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8325         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8326         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8327         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
8328         uint32_tArray ret_arr = NULL;
8329         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8330         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8331         for (size_t h = 0; h < ret_var.datalen; h++) {
8332                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
8333                 *ret_conv_59_conv = ret_var.data[h];
8334                 ret_arr_ptr[h] = ((uintptr_t)ret_conv_59_conv);
8335         }
8336         
8337         FREE(ret_var.data);
8338         return ret_arr;
8339 }
8340
8341 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) {
8342         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8343         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8344         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8345         LDKPublicKey starting_point_ref;
8346         CHECK(starting_point->arr_len == 33);
8347         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
8348         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
8349         uint32_tArray ret_arr = NULL;
8350         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8351         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8352         for (size_t s = 0; s < ret_var.datalen; s++) {
8353                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
8354                 uintptr_t ret_conv_18_ref = 0;
8355                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8356                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8357                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
8358                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
8359                 if (ret_conv_18_var.is_owned) {
8360                         ret_conv_18_ref |= 1;
8361                 }
8362                 ret_arr_ptr[s] = ret_conv_18_ref;
8363         }
8364         
8365         FREE(ret_var.data);
8366         return ret_arr;
8367 }
8368
8369 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) {
8370         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8371         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8372         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8373         LDKPublicKey their_node_id_ref;
8374         CHECK(their_node_id->arr_len == 33);
8375         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8376         LDKInit init_conv;
8377         init_conv.inner = (void*)(init & (~1));
8378         init_conv.is_owned = false;
8379         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
8380         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
8381 }
8382
8383 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) {
8384         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8385         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8386         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8387         LDKPublicKey their_node_id_ref;
8388         CHECK(their_node_id->arr_len == 33);
8389         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8390         LDKReplyChannelRange msg_conv;
8391         msg_conv.inner = (void*)(msg & (~1));
8392         msg_conv.is_owned = (msg & 1) || (msg == 0);
8393         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8394         msg_conv = ReplyChannelRange_clone(&msg_conv);
8395         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8396         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8397         return (uintptr_t)ret_conv;
8398 }
8399
8400 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) {
8401         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8402         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8403         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8404         LDKPublicKey their_node_id_ref;
8405         CHECK(their_node_id->arr_len == 33);
8406         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8407         LDKReplyShortChannelIdsEnd msg_conv;
8408         msg_conv.inner = (void*)(msg & (~1));
8409         msg_conv.is_owned = (msg & 1) || (msg == 0);
8410         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8411         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
8412         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8413         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8414         return (uintptr_t)ret_conv;
8415 }
8416
8417 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) {
8418         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8419         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8420         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8421         LDKPublicKey their_node_id_ref;
8422         CHECK(their_node_id->arr_len == 33);
8423         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8424         LDKQueryChannelRange msg_conv;
8425         msg_conv.inner = (void*)(msg & (~1));
8426         msg_conv.is_owned = (msg & 1) || (msg == 0);
8427         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8428         msg_conv = QueryChannelRange_clone(&msg_conv);
8429         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8430         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8431         return (uintptr_t)ret_conv;
8432 }
8433
8434 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) {
8435         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8436         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8437         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
8438         LDKPublicKey their_node_id_ref;
8439         CHECK(their_node_id->arr_len == 33);
8440         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8441         LDKQueryShortChannelIds msg_conv;
8442         msg_conv.inner = (void*)(msg & (~1));
8443         msg_conv.is_owned = (msg & 1) || (msg == 0);
8444         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8445         msg_conv = QueryShortChannelIds_clone(&msg_conv);
8446         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8447         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
8448         return (uintptr_t)ret_conv;
8449 }
8450
8451 typedef struct LDKCustomMessageReader_JCalls {
8452         atomic_size_t refcnt;
8453         uint32_t instance_ptr;
8454 } LDKCustomMessageReader_JCalls;
8455 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
8456         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
8457         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8458                 FREE(j_calls);
8459         }
8460 }
8461 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
8462         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
8463         LDKu8slice buffer_var = buffer;
8464         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
8465         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
8466         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 75, (uint32_t)message_type, (uint32_t)buffer_arr);
8467         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8468         CHECK_ACCESS(ret_ptr);
8469         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
8470         FREE((void*)ret);
8471         return ret_conv;
8472 }
8473 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
8474         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
8475         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8476 }
8477 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
8478         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
8479         atomic_init(&calls->refcnt, 1);
8480         calls->instance_ptr = o;
8481
8482         LDKCustomMessageReader ret = {
8483                 .this_arg = (void*) calls,
8484                 .read = read_LDKCustomMessageReader_jcall,
8485                 .free = LDKCustomMessageReader_JCalls_free,
8486         };
8487         return ret;
8488 }
8489 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
8490         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
8491         *res_ptr = LDKCustomMessageReader_init(o);
8492         return (long)res_ptr;
8493 }
8494 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
8495         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8496         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8497         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
8498         LDKu8slice buffer_ref;
8499         buffer_ref.datalen = buffer->arr_len;
8500         buffer_ref.data = buffer->elems /* XXX buffer leaks */;
8501         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
8502         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
8503         return (uintptr_t)ret_conv;
8504 }
8505
8506 typedef struct LDKCustomMessageHandler_JCalls {
8507         atomic_size_t refcnt;
8508         uint32_t instance_ptr;
8509         LDKCustomMessageReader_JCalls* CustomMessageReader;
8510 } LDKCustomMessageHandler_JCalls;
8511 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
8512         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
8513         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8514                 FREE(j_calls);
8515         }
8516 }
8517 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
8518         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
8519         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
8520         *msg_ret = msg;
8521         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
8522         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
8523         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 76, (uint32_t)(uintptr_t)msg_ret, (uint32_t)sender_node_id_arr);
8524         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8525         CHECK_ACCESS(ret_ptr);
8526         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
8527         FREE((void*)ret);
8528         return ret_conv;
8529 }
8530 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
8531         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
8532         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 77);
8533         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
8534         ret_constr.datalen = ret->arr_len;
8535         if (ret_constr.datalen > 0)
8536                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
8537         else
8538                 ret_constr.data = NULL;
8539         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
8540         for (size_t z = 0; z < ret_constr.datalen; z++) {
8541                 uint32_t ret_conv_25 = ret_vals[z];
8542                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
8543                 CHECK_ACCESS(ret_conv_25_ptr);
8544                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
8545                 FREE((void*)ret_conv_25);
8546                 ret_constr.data[z] = ret_conv_25_conv;
8547         }
8548         return ret_constr;
8549 }
8550 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
8551         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
8552         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8553         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
8554 }
8555 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
8556         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
8557         atomic_init(&calls->refcnt, 1);
8558         calls->instance_ptr = o;
8559
8560         LDKCustomMessageHandler ret = {
8561                 .this_arg = (void*) calls,
8562                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
8563                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
8564                 .free = LDKCustomMessageHandler_JCalls_free,
8565                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
8566         };
8567         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
8568         return ret;
8569 }
8570 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
8571         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
8572         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
8573         return (long)res_ptr;
8574 }
8575 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) {
8576         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8577         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8578         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
8579         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
8580         CHECK_ACCESS(msg_ptr);
8581         LDKType msg_conv = *(LDKType*)(msg_ptr);
8582         LDKPublicKey sender_node_id_ref;
8583         CHECK(sender_node_id->arr_len == 33);
8584         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
8585         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
8586         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
8587         return (uintptr_t)ret_conv;
8588 }
8589
8590 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
8591         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8592         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8593         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
8594         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
8595         uint32_tArray ret_arr = NULL;
8596         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8597         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8598         for (size_t z = 0; z < ret_var.datalen; z++) {
8599                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
8600                 *ret_conv_25_conv = ret_var.data[z];
8601                 ret_arr_ptr[z] = ((uintptr_t)ret_conv_25_conv);
8602         }
8603         
8604         FREE(ret_var.data);
8605         return ret_arr;
8606 }
8607
8608 typedef struct LDKSocketDescriptor_JCalls {
8609         atomic_size_t refcnt;
8610         uint32_t instance_ptr;
8611 } LDKSocketDescriptor_JCalls;
8612 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
8613         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8614         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8615                 FREE(j_calls);
8616         }
8617 }
8618 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
8619         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8620         LDKu8slice data_var = data;
8621         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
8622         memcpy(data_arr->elems, data_var.data, data_var.datalen);
8623         return js_invoke_function_2(j_calls->instance_ptr, 78, (uint32_t)data_arr, (uint32_t)resume_read);
8624 }
8625 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
8626         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8627         js_invoke_function_0(j_calls->instance_ptr, 79);
8628 }
8629 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
8630         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8631         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8632         *other_arg_clone = SocketDescriptor_clone(other_arg);
8633         return js_invoke_function_1(j_calls->instance_ptr, 80, (uint32_t)(uintptr_t)other_arg_clone);
8634 }
8635 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
8636         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
8637         return js_invoke_function_0(j_calls->instance_ptr, 81);
8638 }
8639 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
8640         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
8641         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8642 }
8643 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
8644         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
8645         atomic_init(&calls->refcnt, 1);
8646         calls->instance_ptr = o;
8647
8648         LDKSocketDescriptor ret = {
8649                 .this_arg = (void*) calls,
8650                 .send_data = send_data_LDKSocketDescriptor_jcall,
8651                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
8652                 .eq = eq_LDKSocketDescriptor_jcall,
8653                 .hash = hash_LDKSocketDescriptor_jcall,
8654                 .cloned = LDKSocketDescriptor_JCalls_cloned,
8655                 .free = LDKSocketDescriptor_JCalls_free,
8656         };
8657         return ret;
8658 }
8659 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
8660         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
8661         *res_ptr = LDKSocketDescriptor_init(o);
8662         return (long)res_ptr;
8663 }
8664 intptr_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
8665         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8666         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8667         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
8668         LDKu8slice data_ref;
8669         data_ref.datalen = data->arr_len;
8670         data_ref.data = data->elems /* XXX data leaks */;
8671         intptr_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
8672         return ret_val;
8673 }
8674
8675 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
8676         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8677         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8678         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
8679         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
8680 }
8681
8682 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
8683         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8684         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8685         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
8686         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
8687         return ret_val;
8688 }
8689
8690 typedef struct LDKScore_JCalls {
8691         atomic_size_t refcnt;
8692         uint32_t instance_ptr;
8693 } LDKScore_JCalls;
8694 static void LDKScore_JCalls_free(void* this_arg) {
8695         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8696         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8697                 FREE(j_calls);
8698         }
8699 }
8700 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) {
8701         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8702         LDKCOption_u64Z *channel_capacity_msat_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
8703         *channel_capacity_msat_copy = channel_capacity_msat;
8704         uintptr_t channel_capacity_msat_ref = (uintptr_t)channel_capacity_msat_copy;
8705         LDKNodeId source_var = *source;
8706         uintptr_t source_ref = 0;
8707         source_var = NodeId_clone(source);
8708         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8709         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8710         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
8711         source_ref = (uintptr_t)source_var.inner;
8712         if (source_var.is_owned) {
8713                 source_ref |= 1;
8714         }
8715         LDKNodeId target_var = *target;
8716         uintptr_t target_ref = 0;
8717         target_var = NodeId_clone(target);
8718         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8719         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8720         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
8721         target_ref = (uintptr_t)target_var.inner;
8722         if (target_var.is_owned) {
8723                 target_ref |= 1;
8724         }
8725         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);
8726 }
8727 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8728         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8729         LDKCVec_RouteHopZ path_var = path;
8730         uint32_tArray path_arr = NULL;
8731         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8732         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8733         for (size_t k = 0; k < path_var.datalen; k++) {
8734                 LDKRouteHop path_conv_10_var = path_var.data[k];
8735                 uintptr_t path_conv_10_ref = 0;
8736                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8737                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8738                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8739                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8740                 if (path_conv_10_var.is_owned) {
8741                         path_conv_10_ref |= 1;
8742                 }
8743                 path_arr_ptr[k] = path_conv_10_ref;
8744         }
8745         
8746         FREE(path_var.data);
8747         js_invoke_function_2(j_calls->instance_ptr, 83, (uint32_t)path_arr, (uint32_t)short_channel_id);
8748 }
8749 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8750         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8751         LDKCVec_RouteHopZ path_var = path;
8752         uint32_tArray path_arr = NULL;
8753         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8754         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8755         for (size_t k = 0; k < path_var.datalen; k++) {
8756                 LDKRouteHop path_conv_10_var = path_var.data[k];
8757                 uintptr_t path_conv_10_ref = 0;
8758                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8759                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8760                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8761                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8762                 if (path_conv_10_var.is_owned) {
8763                         path_conv_10_ref |= 1;
8764                 }
8765                 path_arr_ptr[k] = path_conv_10_ref;
8766         }
8767         
8768         FREE(path_var.data);
8769         js_invoke_function_1(j_calls->instance_ptr, 84, (uint32_t)path_arr);
8770 }
8771 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
8772         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8773         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 85);
8774         LDKCVec_u8Z ret_ref;
8775         ret_ref.datalen = ret->arr_len;
8776         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8777         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
8778         return ret_ref;
8779 }
8780 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
8781         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
8782         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8783 }
8784 static inline LDKScore LDKScore_init (JSValue o) {
8785         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
8786         atomic_init(&calls->refcnt, 1);
8787         calls->instance_ptr = o;
8788
8789         LDKScore ret = {
8790                 .this_arg = (void*) calls,
8791                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
8792                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
8793                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
8794                 .write = write_LDKScore_jcall,
8795                 .free = LDKScore_JCalls_free,
8796         };
8797         return ret;
8798 }
8799 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
8800         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
8801         *res_ptr = LDKScore_init(o);
8802         return (long)res_ptr;
8803 }
8804 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) {
8805         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8806         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8807         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8808         void* channel_capacity_msat_ptr = (void*)(((uintptr_t)channel_capacity_msat) & ~1);
8809         CHECK_ACCESS(channel_capacity_msat_ptr);
8810         LDKCOption_u64Z channel_capacity_msat_conv = *(LDKCOption_u64Z*)(channel_capacity_msat_ptr);
8811         channel_capacity_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)channel_capacity_msat) & ~1));
8812         LDKNodeId source_conv;
8813         source_conv.inner = (void*)(source & (~1));
8814         source_conv.is_owned = false;
8815         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
8816         LDKNodeId target_conv;
8817         target_conv.inner = (void*)(target & (~1));
8818         target_conv.is_owned = false;
8819         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
8820         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);
8821         return ret_val;
8822 }
8823
8824 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) {
8825         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8826         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8827         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8828         LDKCVec_RouteHopZ path_constr;
8829         path_constr.datalen = path->arr_len;
8830         if (path_constr.datalen > 0)
8831                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8832         else
8833                 path_constr.data = NULL;
8834         uint32_t* path_vals = path->elems /* XXX path leaks */;
8835         for (size_t k = 0; k < path_constr.datalen; k++) {
8836                 uint32_t path_conv_10 = path_vals[k];
8837                 LDKRouteHop path_conv_10_conv;
8838                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8839                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8840                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8841                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8842                 path_constr.data[k] = path_conv_10_conv;
8843         }
8844         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8845 }
8846
8847 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
8848         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8849         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8850         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8851         LDKCVec_RouteHopZ path_constr;
8852         path_constr.datalen = path->arr_len;
8853         if (path_constr.datalen > 0)
8854                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8855         else
8856                 path_constr.data = NULL;
8857         uint32_t* path_vals = path->elems /* XXX path leaks */;
8858         for (size_t k = 0; k < path_constr.datalen; k++) {
8859                 uint32_t path_conv_10 = path_vals[k];
8860                 LDKRouteHop path_conv_10_conv;
8861                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8862                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8863                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8864                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8865                 path_constr.data[k] = path_conv_10_conv;
8866         }
8867         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
8868 }
8869
8870 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
8871         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8872         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8873         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8874         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8875         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
8876         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
8877         CVec_u8Z_free(ret_var);
8878         return ret_arr;
8879 }
8880
8881 typedef struct LDKLockableScore_JCalls {
8882         atomic_size_t refcnt;
8883         uint32_t instance_ptr;
8884 } LDKLockableScore_JCalls;
8885 static void LDKLockableScore_JCalls_free(void* this_arg) {
8886         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
8887         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8888                 FREE(j_calls);
8889         }
8890 }
8891 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
8892         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
8893         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 86);
8894         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8895         CHECK_ACCESS(ret_ptr);
8896         LDKScore ret_conv = *(LDKScore*)(ret_ptr);// Warning: we may need a move here but no clone is available for LDKScore
8897         
8898         return ret_conv;
8899 }
8900 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
8901         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
8902         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8903 }
8904 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
8905         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
8906         atomic_init(&calls->refcnt, 1);
8907         calls->instance_ptr = o;
8908
8909         LDKLockableScore ret = {
8910                 .this_arg = (void*) calls,
8911                 .lock = lock_LDKLockableScore_jcall,
8912                 .free = LDKLockableScore_JCalls_free,
8913         };
8914         return ret;
8915 }
8916 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
8917         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
8918         *res_ptr = LDKLockableScore_init(o);
8919         return (long)res_ptr;
8920 }
8921 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
8922         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8923         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8924         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
8925         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
8926         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
8927         return (uintptr_t)ret_ret;
8928 }
8929
8930 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
8931         LDKStr ret_str = _ldk_get_compiled_version();
8932         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
8933         Str_free(ret_str);
8934         return ret_conv;
8935 }
8936
8937 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
8938         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
8939         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
8940         Str_free(ret_str);
8941         return ret_conv;
8942 }
8943
8944 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
8945         LDKTransaction _res_ref;
8946         _res_ref.datalen = _res->arr_len;
8947         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
8948         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
8949         _res_ref.data_is_owned = true;
8950         Transaction_free(_res_ref);
8951 }
8952
8953 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
8954         LDKCVec_u8Z script_pubkey_ref;
8955         script_pubkey_ref.datalen = script_pubkey->arr_len;
8956         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
8957         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
8958         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8959         *ret_ref = TxOut_new(script_pubkey_ref, value);
8960         return (uintptr_t)ret_ref;
8961 }
8962
8963 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
8964         if ((_res & 1) != 0) return;
8965         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
8966         CHECK_ACCESS(_res_ptr);
8967         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
8968         FREE((void*)_res);
8969         TxOut_free(_res_conv);
8970 }
8971
8972 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
8973         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8974         *ret_ref = TxOut_clone(arg);
8975         return (uintptr_t)ret_ref;
8976 }
8977 intptr_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
8978         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
8979         intptr_t ret_val = TxOut_clone_ptr(arg_conv);
8980         return ret_val;
8981 }
8982
8983 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
8984         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
8985         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8986         *ret_ref = TxOut_clone(orig_conv);
8987         return (uintptr_t)ret_ref;
8988 }
8989
8990 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
8991         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
8992         Str_free(dummy);
8993 }
8994
8995 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
8996         LDKChannelConfig o_conv;
8997         o_conv.inner = (void*)(o & (~1));
8998         o_conv.is_owned = (o & 1) || (o == 0);
8999         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9000         o_conv = ChannelConfig_clone(&o_conv);
9001         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9002         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
9003         return (uintptr_t)ret_conv;
9004 }
9005
9006 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
9007         LDKDecodeError e_conv;
9008         e_conv.inner = (void*)(e & (~1));
9009         e_conv.is_owned = (e & 1) || (e == 0);
9010         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9011         e_conv = DecodeError_clone(&e_conv);
9012         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9013         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
9014         return (uintptr_t)ret_conv;
9015 }
9016
9017 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
9018         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
9019         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
9020         return ret_val;
9021 }
9022
9023 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
9024         if ((_res & 1) != 0) return;
9025         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9026         CHECK_ACCESS(_res_ptr);
9027         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
9028         FREE((void*)_res);
9029         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
9030 }
9031
9032 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
9033         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9034         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
9035         return (uintptr_t)ret_conv;
9036 }
9037 intptr_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
9038         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
9039         intptr_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
9040         return ret_val;
9041 }
9042
9043 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
9044         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
9045         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
9046         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
9047         return (uintptr_t)ret_conv;
9048 }
9049
9050 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
9051         LDKOutPoint o_conv;
9052         o_conv.inner = (void*)(o & (~1));
9053         o_conv.is_owned = (o & 1) || (o == 0);
9054         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9055         o_conv = OutPoint_clone(&o_conv);
9056         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9057         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
9058         return (uintptr_t)ret_conv;
9059 }
9060
9061 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
9062         LDKDecodeError e_conv;
9063         e_conv.inner = (void*)(e & (~1));
9064         e_conv.is_owned = (e & 1) || (e == 0);
9065         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9066         e_conv = DecodeError_clone(&e_conv);
9067         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9068         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
9069         return (uintptr_t)ret_conv;
9070 }
9071
9072 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
9073         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
9074         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
9075         return ret_val;
9076 }
9077
9078 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
9079         if ((_res & 1) != 0) return;
9080         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9081         CHECK_ACCESS(_res_ptr);
9082         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
9083         FREE((void*)_res);
9084         CResult_OutPointDecodeErrorZ_free(_res_conv);
9085 }
9086
9087 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
9088         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9089         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
9090         return (uintptr_t)ret_conv;
9091 }
9092 intptr_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
9093         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
9094         intptr_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
9095         return ret_val;
9096 }
9097
9098 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
9099         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
9100         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
9101         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
9102         return (uintptr_t)ret_conv;
9103 }
9104
9105 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
9106         LDKSecretKey o_ref;
9107         CHECK(o->arr_len == 32);
9108         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
9109         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9110         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
9111         return (uintptr_t)ret_conv;
9112 }
9113
9114 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
9115         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9116         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
9117         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
9118         return (uintptr_t)ret_conv;
9119 }
9120
9121 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
9122         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
9123         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
9124         return ret_val;
9125 }
9126
9127 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
9128         if ((_res & 1) != 0) return;
9129         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9130         CHECK_ACCESS(_res_ptr);
9131         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
9132         FREE((void*)_res);
9133         CResult_SecretKeyErrorZ_free(_res_conv);
9134 }
9135
9136 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
9137         LDKPublicKey o_ref;
9138         CHECK(o->arr_len == 33);
9139         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
9140         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9141         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
9142         return (uintptr_t)ret_conv;
9143 }
9144
9145 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
9146         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9147         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9148         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
9149         return (uintptr_t)ret_conv;
9150 }
9151
9152 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
9153         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
9154         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
9155         return ret_val;
9156 }
9157
9158 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
9159         if ((_res & 1) != 0) return;
9160         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9161         CHECK_ACCESS(_res_ptr);
9162         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
9163         FREE((void*)_res);
9164         CResult_PublicKeyErrorZ_free(_res_conv);
9165 }
9166
9167 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
9168         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9169         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
9170         return (uintptr_t)ret_conv;
9171 }
9172 intptr_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
9173         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
9174         intptr_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
9175         return ret_val;
9176 }
9177
9178 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
9179         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
9180         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
9181         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
9182         return (uintptr_t)ret_conv;
9183 }
9184
9185 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
9186         LDKTxCreationKeys o_conv;
9187         o_conv.inner = (void*)(o & (~1));
9188         o_conv.is_owned = (o & 1) || (o == 0);
9189         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9190         o_conv = TxCreationKeys_clone(&o_conv);
9191         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9192         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
9193         return (uintptr_t)ret_conv;
9194 }
9195
9196 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
9197         LDKDecodeError e_conv;
9198         e_conv.inner = (void*)(e & (~1));
9199         e_conv.is_owned = (e & 1) || (e == 0);
9200         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9201         e_conv = DecodeError_clone(&e_conv);
9202         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9203         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
9204         return (uintptr_t)ret_conv;
9205 }
9206
9207 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
9208         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
9209         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
9210         return ret_val;
9211 }
9212
9213 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
9214         if ((_res & 1) != 0) return;
9215         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9216         CHECK_ACCESS(_res_ptr);
9217         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
9218         FREE((void*)_res);
9219         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
9220 }
9221
9222 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
9223         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9224         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
9225         return (uintptr_t)ret_conv;
9226 }
9227 intptr_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
9228         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
9229         intptr_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
9230         return ret_val;
9231 }
9232
9233 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
9234         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
9235         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
9236         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
9237         return (uintptr_t)ret_conv;
9238 }
9239
9240 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
9241         LDKChannelPublicKeys o_conv;
9242         o_conv.inner = (void*)(o & (~1));
9243         o_conv.is_owned = (o & 1) || (o == 0);
9244         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9245         o_conv = ChannelPublicKeys_clone(&o_conv);
9246         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9247         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
9248         return (uintptr_t)ret_conv;
9249 }
9250
9251 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
9252         LDKDecodeError e_conv;
9253         e_conv.inner = (void*)(e & (~1));
9254         e_conv.is_owned = (e & 1) || (e == 0);
9255         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9256         e_conv = DecodeError_clone(&e_conv);
9257         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9258         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
9259         return (uintptr_t)ret_conv;
9260 }
9261
9262 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
9263         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
9264         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
9265         return ret_val;
9266 }
9267
9268 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
9269         if ((_res & 1) != 0) return;
9270         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9271         CHECK_ACCESS(_res_ptr);
9272         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
9273         FREE((void*)_res);
9274         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
9275 }
9276
9277 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
9278         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9279         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
9280         return (uintptr_t)ret_conv;
9281 }
9282 intptr_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
9283         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
9284         intptr_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
9285         return ret_val;
9286 }
9287
9288 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
9289         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
9290         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
9291         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
9292         return (uintptr_t)ret_conv;
9293 }
9294
9295 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
9296         LDKTxCreationKeys o_conv;
9297         o_conv.inner = (void*)(o & (~1));
9298         o_conv.is_owned = (o & 1) || (o == 0);
9299         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9300         o_conv = TxCreationKeys_clone(&o_conv);
9301         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9302         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
9303         return (uintptr_t)ret_conv;
9304 }
9305
9306 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
9307         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
9308         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9309         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
9310         return (uintptr_t)ret_conv;
9311 }
9312
9313 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
9314         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
9315         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
9316         return ret_val;
9317 }
9318
9319 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
9320         if ((_res & 1) != 0) return;
9321         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9322         CHECK_ACCESS(_res_ptr);
9323         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
9324         FREE((void*)_res);
9325         CResult_TxCreationKeysErrorZ_free(_res_conv);
9326 }
9327
9328 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
9329         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9330         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
9331         return (uintptr_t)ret_conv;
9332 }
9333 intptr_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
9334         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
9335         intptr_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
9336         return ret_val;
9337 }
9338
9339 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
9340         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
9341         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
9342         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
9343         return (uintptr_t)ret_conv;
9344 }
9345
9346 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
9347         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9348         *ret_copy = COption_u32Z_some(o);
9349         uintptr_t ret_ref = (uintptr_t)ret_copy;
9350         return ret_ref;
9351 }
9352
9353 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
9354         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9355         *ret_copy = COption_u32Z_none();
9356         uintptr_t ret_ref = (uintptr_t)ret_copy;
9357         return ret_ref;
9358 }
9359
9360 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
9361         if ((_res & 1) != 0) return;
9362         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9363         CHECK_ACCESS(_res_ptr);
9364         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
9365         FREE((void*)_res);
9366         COption_u32Z_free(_res_conv);
9367 }
9368
9369 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
9370         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9371         *ret_copy = COption_u32Z_clone(arg);
9372 uintptr_t ret_ref = (uintptr_t)ret_copy;
9373         return ret_ref;
9374 }
9375 intptr_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
9376         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
9377         intptr_t ret_val = COption_u32Z_clone_ptr(arg_conv);
9378         return ret_val;
9379 }
9380
9381 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
9382         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
9383         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
9384         *ret_copy = COption_u32Z_clone(orig_conv);
9385         uintptr_t ret_ref = (uintptr_t)ret_copy;
9386         return ret_ref;
9387 }
9388
9389 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
9390         LDKHTLCOutputInCommitment o_conv;
9391         o_conv.inner = (void*)(o & (~1));
9392         o_conv.is_owned = (o & 1) || (o == 0);
9393         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9394         o_conv = HTLCOutputInCommitment_clone(&o_conv);
9395         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9396         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
9397         return (uintptr_t)ret_conv;
9398 }
9399
9400 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
9401         LDKDecodeError e_conv;
9402         e_conv.inner = (void*)(e & (~1));
9403         e_conv.is_owned = (e & 1) || (e == 0);
9404         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9405         e_conv = DecodeError_clone(&e_conv);
9406         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9407         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
9408         return (uintptr_t)ret_conv;
9409 }
9410
9411 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
9412         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
9413         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
9414         return ret_val;
9415 }
9416
9417 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
9418         if ((_res & 1) != 0) return;
9419         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9420         CHECK_ACCESS(_res_ptr);
9421         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
9422         FREE((void*)_res);
9423         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
9424 }
9425
9426 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
9427         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9428         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
9429         return (uintptr_t)ret_conv;
9430 }
9431 intptr_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
9432         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
9433         intptr_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
9434         return ret_val;
9435 }
9436
9437 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
9438         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
9439         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
9440         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
9441         return (uintptr_t)ret_conv;
9442 }
9443
9444 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
9445         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
9446         return ret_conv;
9447 }
9448
9449 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
9450         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
9451         return ret_conv;
9452 }
9453
9454 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
9455         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
9456         COption_NoneZ_free(_res_conv);
9457 }
9458
9459 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
9460         LDKCounterpartyChannelTransactionParameters o_conv;
9461         o_conv.inner = (void*)(o & (~1));
9462         o_conv.is_owned = (o & 1) || (o == 0);
9463         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9464         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
9465         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9466         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9467         return (uintptr_t)ret_conv;
9468 }
9469
9470 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
9471         LDKDecodeError e_conv;
9472         e_conv.inner = (void*)(e & (~1));
9473         e_conv.is_owned = (e & 1) || (e == 0);
9474         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9475         e_conv = DecodeError_clone(&e_conv);
9476         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9477         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
9478         return (uintptr_t)ret_conv;
9479 }
9480
9481 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
9482         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
9483         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
9484         return ret_val;
9485 }
9486
9487 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
9488         if ((_res & 1) != 0) return;
9489         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9490         CHECK_ACCESS(_res_ptr);
9491         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
9492         FREE((void*)_res);
9493         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9494 }
9495
9496 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
9497         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9498         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
9499         return (uintptr_t)ret_conv;
9500 }
9501 intptr_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
9502         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
9503         intptr_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
9504         return ret_val;
9505 }
9506
9507 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
9508         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9509         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
9510         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9511         return (uintptr_t)ret_conv;
9512 }
9513
9514 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
9515         LDKChannelTransactionParameters o_conv;
9516         o_conv.inner = (void*)(o & (~1));
9517         o_conv.is_owned = (o & 1) || (o == 0);
9518         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9519         o_conv = ChannelTransactionParameters_clone(&o_conv);
9520         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9521         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
9522         return (uintptr_t)ret_conv;
9523 }
9524
9525 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
9526         LDKDecodeError e_conv;
9527         e_conv.inner = (void*)(e & (~1));
9528         e_conv.is_owned = (e & 1) || (e == 0);
9529         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9530         e_conv = DecodeError_clone(&e_conv);
9531         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9532         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
9533         return (uintptr_t)ret_conv;
9534 }
9535
9536 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
9537         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
9538         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
9539         return ret_val;
9540 }
9541
9542 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
9543         if ((_res & 1) != 0) return;
9544         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9545         CHECK_ACCESS(_res_ptr);
9546         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
9547         FREE((void*)_res);
9548         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
9549 }
9550
9551 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
9552         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9553         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
9554         return (uintptr_t)ret_conv;
9555 }
9556 intptr_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
9557         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
9558         intptr_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
9559         return ret_val;
9560 }
9561
9562 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
9563         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
9564         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
9565         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
9566         return (uintptr_t)ret_conv;
9567 }
9568
9569 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
9570         LDKCVec_SignatureZ _res_constr;
9571         _res_constr.datalen = _res->arr_len;
9572         if (_res_constr.datalen > 0)
9573                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9574         else
9575                 _res_constr.data = NULL;
9576         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
9577         for (size_t m = 0; m < _res_constr.datalen; m++) {
9578                 int8_tArray _res_conv_12 = _res_vals[m];
9579                 LDKSignature _res_conv_12_ref;
9580                 CHECK(_res_conv_12->arr_len == 64);
9581                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
9582                 _res_constr.data[m] = _res_conv_12_ref;
9583         }
9584         CVec_SignatureZ_free(_res_constr);
9585 }
9586
9587 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
9588         LDKHolderCommitmentTransaction o_conv;
9589         o_conv.inner = (void*)(o & (~1));
9590         o_conv.is_owned = (o & 1) || (o == 0);
9591         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9592         o_conv = HolderCommitmentTransaction_clone(&o_conv);
9593         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9594         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
9595         return (uintptr_t)ret_conv;
9596 }
9597
9598 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
9599         LDKDecodeError e_conv;
9600         e_conv.inner = (void*)(e & (~1));
9601         e_conv.is_owned = (e & 1) || (e == 0);
9602         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9603         e_conv = DecodeError_clone(&e_conv);
9604         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9605         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
9606         return (uintptr_t)ret_conv;
9607 }
9608
9609 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
9610         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
9611         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
9612         return ret_val;
9613 }
9614
9615 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
9616         if ((_res & 1) != 0) return;
9617         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9618         CHECK_ACCESS(_res_ptr);
9619         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
9620         FREE((void*)_res);
9621         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
9622 }
9623
9624 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
9625         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9626         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
9627         return (uintptr_t)ret_conv;
9628 }
9629 intptr_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
9630         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
9631         intptr_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
9632         return ret_val;
9633 }
9634
9635 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
9636         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9637         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
9638         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9639         return (uintptr_t)ret_conv;
9640 }
9641
9642 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
9643         LDKBuiltCommitmentTransaction o_conv;
9644         o_conv.inner = (void*)(o & (~1));
9645         o_conv.is_owned = (o & 1) || (o == 0);
9646         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9647         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
9648         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9649         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
9650         return (uintptr_t)ret_conv;
9651 }
9652
9653 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
9654         LDKDecodeError e_conv;
9655         e_conv.inner = (void*)(e & (~1));
9656         e_conv.is_owned = (e & 1) || (e == 0);
9657         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9658         e_conv = DecodeError_clone(&e_conv);
9659         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9660         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
9661         return (uintptr_t)ret_conv;
9662 }
9663
9664 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
9665         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
9666         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
9667         return ret_val;
9668 }
9669
9670 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
9671         if ((_res & 1) != 0) return;
9672         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9673         CHECK_ACCESS(_res_ptr);
9674         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
9675         FREE((void*)_res);
9676         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
9677 }
9678
9679 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
9680         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9681         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
9682         return (uintptr_t)ret_conv;
9683 }
9684 intptr_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
9685         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
9686         intptr_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
9687         return ret_val;
9688 }
9689
9690 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
9691         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
9692         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
9693         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
9694         return (uintptr_t)ret_conv;
9695 }
9696
9697 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
9698         LDKTrustedClosingTransaction o_conv;
9699         o_conv.inner = (void*)(o & (~1));
9700         o_conv.is_owned = (o & 1) || (o == 0);
9701         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9702         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
9703         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
9704         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
9705         return (uintptr_t)ret_conv;
9706 }
9707
9708 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
9709         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
9710         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
9711         return (uintptr_t)ret_conv;
9712 }
9713
9714 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
9715         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
9716         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
9717         return ret_val;
9718 }
9719
9720 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
9721         if ((_res & 1) != 0) return;
9722         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9723         CHECK_ACCESS(_res_ptr);
9724         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
9725         FREE((void*)_res);
9726         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
9727 }
9728
9729 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
9730         LDKCommitmentTransaction o_conv;
9731         o_conv.inner = (void*)(o & (~1));
9732         o_conv.is_owned = (o & 1) || (o == 0);
9733         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9734         o_conv = CommitmentTransaction_clone(&o_conv);
9735         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9736         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
9737         return (uintptr_t)ret_conv;
9738 }
9739
9740 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
9741         LDKDecodeError e_conv;
9742         e_conv.inner = (void*)(e & (~1));
9743         e_conv.is_owned = (e & 1) || (e == 0);
9744         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9745         e_conv = DecodeError_clone(&e_conv);
9746         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9747         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
9748         return (uintptr_t)ret_conv;
9749 }
9750
9751 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
9752         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
9753         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
9754         return ret_val;
9755 }
9756
9757 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
9758         if ((_res & 1) != 0) return;
9759         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9760         CHECK_ACCESS(_res_ptr);
9761         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
9762         FREE((void*)_res);
9763         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
9764 }
9765
9766 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
9767         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9768         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
9769         return (uintptr_t)ret_conv;
9770 }
9771 intptr_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
9772         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
9773         intptr_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
9774         return ret_val;
9775 }
9776
9777 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
9778         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
9779         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
9780         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
9781         return (uintptr_t)ret_conv;
9782 }
9783
9784 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
9785         LDKTrustedCommitmentTransaction o_conv;
9786         o_conv.inner = (void*)(o & (~1));
9787         o_conv.is_owned = (o & 1) || (o == 0);
9788         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9789         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
9790         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9791         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
9792         return (uintptr_t)ret_conv;
9793 }
9794
9795 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
9796         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
9797         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
9798         return (uintptr_t)ret_conv;
9799 }
9800
9801 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
9802         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
9803         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
9804         return ret_val;
9805 }
9806
9807 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
9808         if ((_res & 1) != 0) return;
9809         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9810         CHECK_ACCESS(_res_ptr);
9811         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
9812         FREE((void*)_res);
9813         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
9814 }
9815
9816 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
9817         LDKCVec_SignatureZ o_constr;
9818         o_constr.datalen = o->arr_len;
9819         if (o_constr.datalen > 0)
9820                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9821         else
9822                 o_constr.data = NULL;
9823         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
9824         for (size_t m = 0; m < o_constr.datalen; m++) {
9825                 int8_tArray o_conv_12 = o_vals[m];
9826                 LDKSignature o_conv_12_ref;
9827                 CHECK(o_conv_12->arr_len == 64);
9828                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
9829                 o_constr.data[m] = o_conv_12_ref;
9830         }
9831         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9832         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
9833         return (uintptr_t)ret_conv;
9834 }
9835
9836 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
9837         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9838         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
9839         return (uintptr_t)ret_conv;
9840 }
9841
9842 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
9843         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
9844         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
9845         return ret_val;
9846 }
9847
9848 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
9849         if ((_res & 1) != 0) return;
9850         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9851         CHECK_ACCESS(_res_ptr);
9852         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
9853         FREE((void*)_res);
9854         CResult_CVec_SignatureZNoneZ_free(_res_conv);
9855 }
9856
9857 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
9858         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9859         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
9860         return (uintptr_t)ret_conv;
9861 }
9862 intptr_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
9863         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
9864         intptr_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
9865         return ret_val;
9866 }
9867
9868 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
9869         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
9870         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
9871         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
9872         return (uintptr_t)ret_conv;
9873 }
9874
9875 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
9876         LDKShutdownScript o_conv;
9877         o_conv.inner = (void*)(o & (~1));
9878         o_conv.is_owned = (o & 1) || (o == 0);
9879         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9880         o_conv = ShutdownScript_clone(&o_conv);
9881         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9882         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
9883         return (uintptr_t)ret_conv;
9884 }
9885
9886 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
9887         LDKDecodeError e_conv;
9888         e_conv.inner = (void*)(e & (~1));
9889         e_conv.is_owned = (e & 1) || (e == 0);
9890         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9891         e_conv = DecodeError_clone(&e_conv);
9892         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9893         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
9894         return (uintptr_t)ret_conv;
9895 }
9896
9897 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
9898         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
9899         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
9900         return ret_val;
9901 }
9902
9903 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
9904         if ((_res & 1) != 0) return;
9905         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9906         CHECK_ACCESS(_res_ptr);
9907         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
9908         FREE((void*)_res);
9909         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
9910 }
9911
9912 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
9913         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9914         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
9915         return (uintptr_t)ret_conv;
9916 }
9917 intptr_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
9918         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
9919         intptr_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
9920         return ret_val;
9921 }
9922
9923 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
9924         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
9925         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
9926         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
9927         return (uintptr_t)ret_conv;
9928 }
9929
9930 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
9931         LDKShutdownScript o_conv;
9932         o_conv.inner = (void*)(o & (~1));
9933         o_conv.is_owned = (o & 1) || (o == 0);
9934         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
9935         o_conv = ShutdownScript_clone(&o_conv);
9936         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9937         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
9938         return (uintptr_t)ret_conv;
9939 }
9940
9941 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
9942         LDKInvalidShutdownScript e_conv;
9943         e_conv.inner = (void*)(e & (~1));
9944         e_conv.is_owned = (e & 1) || (e == 0);
9945         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
9946         e_conv = InvalidShutdownScript_clone(&e_conv);
9947         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9948         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
9949         return (uintptr_t)ret_conv;
9950 }
9951
9952 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
9953         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
9954         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
9955         return ret_val;
9956 }
9957
9958 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
9959         if ((_res & 1) != 0) return;
9960         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
9961         CHECK_ACCESS(_res_ptr);
9962         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
9963         FREE((void*)_res);
9964         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
9965 }
9966
9967 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
9968         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9969         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
9970         return (uintptr_t)ret_conv;
9971 }
9972 intptr_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
9973         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
9974         intptr_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
9975         return ret_val;
9976 }
9977
9978 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
9979         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
9980         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
9981         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
9982         return (uintptr_t)ret_conv;
9983 }
9984
9985 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
9986         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
9987         CHECK_ACCESS(o_ptr);
9988         LDKType o_conv = *(LDKType*)(o_ptr);
9989         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9990         *ret_copy = COption_TypeZ_some(o_conv);
9991         uintptr_t ret_ref = (uintptr_t)ret_copy;
9992         return ret_ref;
9993 }
9994
9995 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
9996         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
9997         *ret_copy = COption_TypeZ_none();
9998         uintptr_t ret_ref = (uintptr_t)ret_copy;
9999         return ret_ref;
10000 }
10001
10002 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
10003         if ((_res & 1) != 0) return;
10004         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10005         CHECK_ACCESS(_res_ptr);
10006         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
10007         FREE((void*)_res);
10008         COption_TypeZ_free(_res_conv);
10009 }
10010
10011 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
10012         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
10013         *ret_copy = COption_TypeZ_clone(arg);
10014 uintptr_t ret_ref = (uintptr_t)ret_copy;
10015         return ret_ref;
10016 }
10017 intptr_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
10018         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
10019         intptr_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
10020         return ret_val;
10021 }
10022
10023 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
10024         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
10025         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
10026         *ret_copy = COption_TypeZ_clone(orig_conv);
10027         uintptr_t ret_ref = (uintptr_t)ret_copy;
10028         return ret_ref;
10029 }
10030
10031 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
10032         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
10033         CHECK_ACCESS(o_ptr);
10034         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
10035         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
10036         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10037         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
10038         return (uintptr_t)ret_conv;
10039 }
10040
10041 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
10042         LDKDecodeError e_conv;
10043         e_conv.inner = (void*)(e & (~1));
10044         e_conv.is_owned = (e & 1) || (e == 0);
10045         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10046         e_conv = DecodeError_clone(&e_conv);
10047         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10048         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
10049         return (uintptr_t)ret_conv;
10050 }
10051
10052 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
10053         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
10054         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
10055         return ret_val;
10056 }
10057
10058 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
10059         if ((_res & 1) != 0) return;
10060         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10061         CHECK_ACCESS(_res_ptr);
10062         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
10063         FREE((void*)_res);
10064         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
10065 }
10066
10067 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
10068         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10069         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
10070         return (uintptr_t)ret_conv;
10071 }
10072 intptr_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
10073         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
10074         intptr_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
10075         return ret_val;
10076 }
10077
10078 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
10079         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
10080         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10081         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
10082         return (uintptr_t)ret_conv;
10083 }
10084
10085 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
10086         LDKStr o_conv = str_ref_to_owned_c(o);
10087         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10088         *ret_conv = CResult_StringErrorZ_ok(o_conv);
10089         return (uintptr_t)ret_conv;
10090 }
10091
10092 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
10093         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10094         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
10095         *ret_conv = CResult_StringErrorZ_err(e_conv);
10096         return (uintptr_t)ret_conv;
10097 }
10098
10099 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
10100         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
10101         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
10102         return ret_val;
10103 }
10104
10105 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
10106         if ((_res & 1) != 0) return;
10107         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10108         CHECK_ACCESS(_res_ptr);
10109         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
10110         FREE((void*)_res);
10111         CResult_StringErrorZ_free(_res_conv);
10112 }
10113
10114 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
10115         LDKChannelMonitorUpdate o_conv;
10116         o_conv.inner = (void*)(o & (~1));
10117         o_conv.is_owned = (o & 1) || (o == 0);
10118         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10119         o_conv = ChannelMonitorUpdate_clone(&o_conv);
10120         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10121         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
10122         return (uintptr_t)ret_conv;
10123 }
10124
10125 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
10126         LDKDecodeError e_conv;
10127         e_conv.inner = (void*)(e & (~1));
10128         e_conv.is_owned = (e & 1) || (e == 0);
10129         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10130         e_conv = DecodeError_clone(&e_conv);
10131         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10132         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
10133         return (uintptr_t)ret_conv;
10134 }
10135
10136 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
10137         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
10138         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
10139         return ret_val;
10140 }
10141
10142 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
10143         if ((_res & 1) != 0) return;
10144         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10145         CHECK_ACCESS(_res_ptr);
10146         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
10147         FREE((void*)_res);
10148         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
10149 }
10150
10151 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
10152         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10153         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
10154         return (uintptr_t)ret_conv;
10155 }
10156 intptr_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
10157         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
10158         intptr_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
10159         return ret_val;
10160 }
10161
10162 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
10163         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
10164         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
10165         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
10166         return (uintptr_t)ret_conv;
10167 }
10168
10169 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
10170         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
10171         CHECK_ACCESS(o_ptr);
10172         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
10173         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
10174         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
10175         *ret_copy = COption_MonitorEventZ_some(o_conv);
10176         uintptr_t ret_ref = (uintptr_t)ret_copy;
10177         return ret_ref;
10178 }
10179
10180 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
10181         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
10182         *ret_copy = COption_MonitorEventZ_none();
10183         uintptr_t ret_ref = (uintptr_t)ret_copy;
10184         return ret_ref;
10185 }
10186
10187 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
10188         if ((_res & 1) != 0) return;
10189         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10190         CHECK_ACCESS(_res_ptr);
10191         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
10192         FREE((void*)_res);
10193         COption_MonitorEventZ_free(_res_conv);
10194 }
10195
10196 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
10197         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
10198         *ret_copy = COption_MonitorEventZ_clone(arg);
10199 uintptr_t ret_ref = (uintptr_t)ret_copy;
10200         return ret_ref;
10201 }
10202 intptr_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
10203         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
10204         intptr_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
10205         return ret_val;
10206 }
10207
10208 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
10209         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
10210         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
10211         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
10212         uintptr_t ret_ref = (uintptr_t)ret_copy;
10213         return ret_ref;
10214 }
10215
10216 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
10217         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
10218         CHECK_ACCESS(o_ptr);
10219         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
10220         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
10221         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
10222         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
10223         return (uintptr_t)ret_conv;
10224 }
10225
10226 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
10227         LDKDecodeError e_conv;
10228         e_conv.inner = (void*)(e & (~1));
10229         e_conv.is_owned = (e & 1) || (e == 0);
10230         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10231         e_conv = DecodeError_clone(&e_conv);
10232         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
10233         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
10234         return (uintptr_t)ret_conv;
10235 }
10236
10237 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
10238         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
10239         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
10240         return ret_val;
10241 }
10242
10243 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
10244         if ((_res & 1) != 0) return;
10245         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10246         CHECK_ACCESS(_res_ptr);
10247         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
10248         FREE((void*)_res);
10249         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
10250 }
10251
10252 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
10253         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
10254         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
10255         return (uintptr_t)ret_conv;
10256 }
10257 intptr_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
10258         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
10259         intptr_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
10260         return ret_val;
10261 }
10262
10263 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
10264         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
10265         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
10266         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
10267         return (uintptr_t)ret_conv;
10268 }
10269
10270 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
10271         LDKHTLCUpdate o_conv;
10272         o_conv.inner = (void*)(o & (~1));
10273         o_conv.is_owned = (o & 1) || (o == 0);
10274         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10275         o_conv = HTLCUpdate_clone(&o_conv);
10276         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10277         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
10278         return (uintptr_t)ret_conv;
10279 }
10280
10281 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
10282         LDKDecodeError e_conv;
10283         e_conv.inner = (void*)(e & (~1));
10284         e_conv.is_owned = (e & 1) || (e == 0);
10285         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10286         e_conv = DecodeError_clone(&e_conv);
10287         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10288         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
10289         return (uintptr_t)ret_conv;
10290 }
10291
10292 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
10293         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
10294         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
10295         return ret_val;
10296 }
10297
10298 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
10299         if ((_res & 1) != 0) return;
10300         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10301         CHECK_ACCESS(_res_ptr);
10302         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
10303         FREE((void*)_res);
10304         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
10305 }
10306
10307 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
10308         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10309         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
10310         return (uintptr_t)ret_conv;
10311 }
10312 intptr_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
10313         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
10314         intptr_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
10315         return ret_val;
10316 }
10317
10318 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
10319         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
10320         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
10321         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
10322         return (uintptr_t)ret_conv;
10323 }
10324
10325 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
10326         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10327         *ret_conv = CResult_NoneNoneZ_ok();
10328         return (uintptr_t)ret_conv;
10329 }
10330
10331 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
10332         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10333         *ret_conv = CResult_NoneNoneZ_err();
10334         return (uintptr_t)ret_conv;
10335 }
10336
10337 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
10338         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
10339         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
10340         return ret_val;
10341 }
10342
10343 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
10344         if ((_res & 1) != 0) return;
10345         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10346         CHECK_ACCESS(_res_ptr);
10347         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
10348         FREE((void*)_res);
10349         CResult_NoneNoneZ_free(_res_conv);
10350 }
10351
10352 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
10353         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10354         *ret_conv = CResult_NoneNoneZ_clone(arg);
10355         return (uintptr_t)ret_conv;
10356 }
10357 intptr_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
10358         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
10359         intptr_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
10360         return ret_val;
10361 }
10362
10363 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
10364         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
10365         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10366         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
10367         return (uintptr_t)ret_conv;
10368 }
10369
10370 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
10371         LDKOutPoint a_conv;
10372         a_conv.inner = (void*)(a & (~1));
10373         a_conv.is_owned = (a & 1) || (a == 0);
10374         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
10375         a_conv = OutPoint_clone(&a_conv);
10376         LDKCVec_u8Z b_ref;
10377         b_ref.datalen = b->arr_len;
10378         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10379         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
10380         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
10381         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
10382         return ((uintptr_t)ret_conv);
10383 }
10384
10385 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
10386         if ((_res & 1) != 0) return;
10387         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10388         CHECK_ACCESS(_res_ptr);
10389         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
10390         FREE((void*)_res);
10391         C2Tuple_OutPointScriptZ_free(_res_conv);
10392 }
10393
10394 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
10395         LDKCVec_u8Z b_ref;
10396         b_ref.datalen = b->arr_len;
10397         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
10398         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
10399         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
10400         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
10401         return ((uintptr_t)ret_conv);
10402 }
10403
10404 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
10405         if ((_res & 1) != 0) return;
10406         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10407         CHECK_ACCESS(_res_ptr);
10408         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
10409         FREE((void*)_res);
10410         C2Tuple_u32ScriptZ_free(_res_conv);
10411 }
10412
10413 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
10414         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
10415         _res_constr.datalen = _res->arr_len;
10416         if (_res_constr.datalen > 0)
10417                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10418         else
10419                 _res_constr.data = NULL;
10420         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10421         for (size_t v = 0; v < _res_constr.datalen; v++) {
10422                 uint32_t _res_conv_21 = _res_vals[v];
10423                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
10424                 CHECK_ACCESS(_res_conv_21_ptr);
10425                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
10426                 FREE((void*)_res_conv_21);
10427                 _res_constr.data[v] = _res_conv_21_conv;
10428         }
10429         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
10430 }
10431
10432 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
10433         LDKThirtyTwoBytes a_ref;
10434         CHECK(a->arr_len == 32);
10435         memcpy(a_ref.data, a->elems, 32); FREE(a);
10436         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
10437         b_constr.datalen = b->arr_len;
10438         if (b_constr.datalen > 0)
10439                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
10440         else
10441                 b_constr.data = NULL;
10442         uint32_t* b_vals = b->elems /* XXX b leaks */;
10443         for (size_t v = 0; v < b_constr.datalen; v++) {
10444                 uint32_t b_conv_21 = b_vals[v];
10445                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
10446                 CHECK_ACCESS(b_conv_21_ptr);
10447                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
10448                 // Warning: we may need a move here but no clone is available for LDKC2Tuple_u32ScriptZ
10449                 b_constr.data[v] = b_conv_21_conv;
10450         }
10451         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
10452         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
10453         return ((uintptr_t)ret_conv);
10454 }
10455
10456 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
10457         if ((_res & 1) != 0) return;
10458         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10459         CHECK_ACCESS(_res_ptr);
10460         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
10461         FREE((void*)_res);
10462         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
10463 }
10464
10465 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
10466         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
10467         _res_constr.datalen = _res->arr_len;
10468         if (_res_constr.datalen > 0)
10469                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
10470         else
10471                 _res_constr.data = NULL;
10472         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10473         for (size_t o = 0; o < _res_constr.datalen; o++) {
10474                 uint32_t _res_conv_40 = _res_vals[o];
10475                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
10476                 CHECK_ACCESS(_res_conv_40_ptr);
10477                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
10478                 FREE((void*)_res_conv_40);
10479                 _res_constr.data[o] = _res_conv_40_conv;
10480         }
10481         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
10482 }
10483
10484 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
10485         LDKCVec_MonitorEventZ _res_constr;
10486         _res_constr.datalen = _res->arr_len;
10487         if (_res_constr.datalen > 0)
10488                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
10489         else
10490                 _res_constr.data = NULL;
10491         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10492         for (size_t o = 0; o < _res_constr.datalen; o++) {
10493                 uint32_t _res_conv_14 = _res_vals[o];
10494                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
10495                 CHECK_ACCESS(_res_conv_14_ptr);
10496                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
10497                 FREE((void*)_res_conv_14);
10498                 _res_constr.data[o] = _res_conv_14_conv;
10499         }
10500         CVec_MonitorEventZ_free(_res_constr);
10501 }
10502
10503 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
10504         LDKCVec_EventZ _res_constr;
10505         _res_constr.datalen = _res->arr_len;
10506         if (_res_constr.datalen > 0)
10507                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
10508         else
10509                 _res_constr.data = NULL;
10510         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10511         for (size_t h = 0; h < _res_constr.datalen; h++) {
10512                 uint32_t _res_conv_7 = _res_vals[h];
10513                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
10514                 CHECK_ACCESS(_res_conv_7_ptr);
10515                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
10516                 FREE((void*)_res_conv_7);
10517                 _res_constr.data[h] = _res_conv_7_conv;
10518         }
10519         CVec_EventZ_free(_res_constr);
10520 }
10521
10522 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
10523         LDKCVec_TransactionZ _res_constr;
10524         _res_constr.datalen = _res->arr_len;
10525         if (_res_constr.datalen > 0)
10526                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
10527         else
10528                 _res_constr.data = NULL;
10529         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
10530         for (size_t m = 0; m < _res_constr.datalen; m++) {
10531                 int8_tArray _res_conv_12 = _res_vals[m];
10532                 LDKTransaction _res_conv_12_ref;
10533                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
10534                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
10535                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
10536                 _res_conv_12_ref.data_is_owned = true;
10537                 _res_constr.data[m] = _res_conv_12_ref;
10538         }
10539         CVec_TransactionZ_free(_res_constr);
10540 }
10541
10542 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
10543         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10544         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
10545         return ((uintptr_t)ret_conv);
10546 }
10547 intptr_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
10548         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
10549         intptr_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
10550         return ret_val;
10551 }
10552
10553 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
10554         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
10555         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10556         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
10557         return ((uintptr_t)ret_conv);
10558 }
10559
10560 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(intptr_t a, int8_tArray b) {
10561         LDKTransaction b_ref;
10562         b_ref.datalen = b->arr_len;
10563         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
10564         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
10565         b_ref.data_is_owned = true;
10566         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
10567         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
10568         return ((uintptr_t)ret_conv);
10569 }
10570
10571 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
10572         if ((_res & 1) != 0) return;
10573         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10574         CHECK_ACCESS(_res_ptr);
10575         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
10576         FREE((void*)_res);
10577         C2Tuple_usizeTransactionZ_free(_res_conv);
10578 }
10579
10580 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
10581         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
10582         _res_constr.datalen = _res->arr_len;
10583         if (_res_constr.datalen > 0)
10584                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
10585         else
10586                 _res_constr.data = NULL;
10587         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10588         for (size_t c = 0; c < _res_constr.datalen; c++) {
10589                 uint32_t _res_conv_28 = _res_vals[c];
10590                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
10591                 CHECK_ACCESS(_res_conv_28_ptr);
10592                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
10593                 FREE((void*)_res_conv_28);
10594                 _res_constr.data[c] = _res_conv_28_conv;
10595         }
10596         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
10597 }
10598
10599 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
10600         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
10601         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
10602         return ((uintptr_t)ret_conv);
10603 }
10604 intptr_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
10605         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
10606         intptr_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
10607         return ret_val;
10608 }
10609
10610 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
10611         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
10612         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
10613         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
10614         return ((uintptr_t)ret_conv);
10615 }
10616
10617 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
10618         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
10619         CHECK_ACCESS(b_ptr);
10620         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
10621         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
10622         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
10623         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
10624         return ((uintptr_t)ret_conv);
10625 }
10626
10627 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
10628         if ((_res & 1) != 0) return;
10629         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10630         CHECK_ACCESS(_res_ptr);
10631         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
10632         FREE((void*)_res);
10633         C2Tuple_u32TxOutZ_free(_res_conv);
10634 }
10635
10636 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
10637         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
10638         _res_constr.datalen = _res->arr_len;
10639         if (_res_constr.datalen > 0)
10640                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
10641         else
10642                 _res_constr.data = NULL;
10643         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10644         for (size_t u = 0; u < _res_constr.datalen; u++) {
10645                 uint32_t _res_conv_20 = _res_vals[u];
10646                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
10647                 CHECK_ACCESS(_res_conv_20_ptr);
10648                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
10649                 FREE((void*)_res_conv_20);
10650                 _res_constr.data[u] = _res_conv_20_conv;
10651         }
10652         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
10653 }
10654
10655 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
10656         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10657         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
10658         return ((uintptr_t)ret_conv);
10659 }
10660 intptr_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
10661         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
10662         intptr_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
10663         return ret_val;
10664 }
10665
10666 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
10667         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
10668         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10669         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
10670         return ((uintptr_t)ret_conv);
10671 }
10672
10673 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
10674         LDKThirtyTwoBytes a_ref;
10675         CHECK(a->arr_len == 32);
10676         memcpy(a_ref.data, a->elems, 32); FREE(a);
10677         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
10678         b_constr.datalen = b->arr_len;
10679         if (b_constr.datalen > 0)
10680                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
10681         else
10682                 b_constr.data = NULL;
10683         uint32_t* b_vals = b->elems /* XXX b leaks */;
10684         for (size_t u = 0; u < b_constr.datalen; u++) {
10685                 uint32_t b_conv_20 = b_vals[u];
10686                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
10687                 CHECK_ACCESS(b_conv_20_ptr);
10688                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
10689                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
10690                 b_constr.data[u] = b_conv_20_conv;
10691         }
10692         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
10693         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
10694         return ((uintptr_t)ret_conv);
10695 }
10696
10697 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
10698         if ((_res & 1) != 0) return;
10699         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10700         CHECK_ACCESS(_res_ptr);
10701         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
10702         FREE((void*)_res);
10703         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
10704 }
10705
10706 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
10707         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
10708         _res_constr.datalen = _res->arr_len;
10709         if (_res_constr.datalen > 0)
10710                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
10711         else
10712                 _res_constr.data = NULL;
10713         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10714         for (size_t n = 0; n < _res_constr.datalen; n++) {
10715                 uint32_t _res_conv_39 = _res_vals[n];
10716                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
10717                 CHECK_ACCESS(_res_conv_39_ptr);
10718                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
10719                 FREE((void*)_res_conv_39);
10720                 _res_constr.data[n] = _res_conv_39_conv;
10721         }
10722         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
10723 }
10724
10725 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
10726         LDKCVec_TxidZ _res_constr;
10727         _res_constr.datalen = _res->arr_len;
10728         if (_res_constr.datalen > 0)
10729                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
10730         else
10731                 _res_constr.data = NULL;
10732         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
10733         for (size_t m = 0; m < _res_constr.datalen; m++) {
10734                 int8_tArray _res_conv_12 = _res_vals[m];
10735                 LDKThirtyTwoBytes _res_conv_12_ref;
10736                 CHECK(_res_conv_12->arr_len == 32);
10737                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
10738                 _res_constr.data[m] = _res_conv_12_ref;
10739         }
10740         CVec_TxidZ_free(_res_constr);
10741 }
10742
10743 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
10744         LDKCVec_BalanceZ _res_constr;
10745         _res_constr.datalen = _res->arr_len;
10746         if (_res_constr.datalen > 0)
10747                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
10748         else
10749                 _res_constr.data = NULL;
10750         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10751         for (size_t j = 0; j < _res_constr.datalen; j++) {
10752                 uint32_t _res_conv_9 = _res_vals[j];
10753                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
10754                 CHECK_ACCESS(_res_conv_9_ptr);
10755                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
10756                 FREE((void*)_res_conv_9);
10757                 _res_constr.data[j] = _res_conv_9_conv;
10758         }
10759         CVec_BalanceZ_free(_res_constr);
10760 }
10761
10762 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
10763         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10764         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
10765         return ((uintptr_t)ret_conv);
10766 }
10767 intptr_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
10768         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
10769         intptr_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
10770         return ret_val;
10771 }
10772
10773 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
10774         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
10775         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10776         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
10777         return ((uintptr_t)ret_conv);
10778 }
10779
10780 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
10781         LDKThirtyTwoBytes a_ref;
10782         CHECK(a->arr_len == 32);
10783         memcpy(a_ref.data, a->elems, 32); FREE(a);
10784         LDKChannelMonitor b_conv;
10785         b_conv.inner = (void*)(b & (~1));
10786         b_conv.is_owned = (b & 1) || (b == 0);
10787         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
10788         b_conv = ChannelMonitor_clone(&b_conv);
10789         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
10790         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
10791         return ((uintptr_t)ret_conv);
10792 }
10793
10794 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
10795         if ((_res & 1) != 0) return;
10796         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10797         CHECK_ACCESS(_res_ptr);
10798         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
10799         FREE((void*)_res);
10800         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
10801 }
10802
10803 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
10804         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
10805         CHECK_ACCESS(o_ptr);
10806         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
10807         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
10808         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10809         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
10810         return (uintptr_t)ret_conv;
10811 }
10812
10813 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
10814         LDKDecodeError e_conv;
10815         e_conv.inner = (void*)(e & (~1));
10816         e_conv.is_owned = (e & 1) || (e == 0);
10817         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10818         e_conv = DecodeError_clone(&e_conv);
10819         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10820         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
10821         return (uintptr_t)ret_conv;
10822 }
10823
10824 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
10825         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
10826         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
10827         return ret_val;
10828 }
10829
10830 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
10831         if ((_res & 1) != 0) return;
10832         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10833         CHECK_ACCESS(_res_ptr);
10834         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
10835         FREE((void*)_res);
10836         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
10837 }
10838
10839 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
10840         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10841         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
10842         return (uintptr_t)ret_conv;
10843 }
10844 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
10845         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
10846         intptr_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
10847         return ret_val;
10848 }
10849
10850 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
10851         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
10852         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
10853         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
10854         return (uintptr_t)ret_conv;
10855 }
10856
10857 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
10858         LDKRouteHop o_conv;
10859         o_conv.inner = (void*)(o & (~1));
10860         o_conv.is_owned = (o & 1) || (o == 0);
10861         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10862         o_conv = RouteHop_clone(&o_conv);
10863         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10864         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
10865         return (uintptr_t)ret_conv;
10866 }
10867
10868 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
10869         LDKDecodeError e_conv;
10870         e_conv.inner = (void*)(e & (~1));
10871         e_conv.is_owned = (e & 1) || (e == 0);
10872         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10873         e_conv = DecodeError_clone(&e_conv);
10874         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10875         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
10876         return (uintptr_t)ret_conv;
10877 }
10878
10879 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
10880         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
10881         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
10882         return ret_val;
10883 }
10884
10885 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
10886         if ((_res & 1) != 0) return;
10887         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10888         CHECK_ACCESS(_res_ptr);
10889         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
10890         FREE((void*)_res);
10891         CResult_RouteHopDecodeErrorZ_free(_res_conv);
10892 }
10893
10894 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
10895         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10896         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
10897         return (uintptr_t)ret_conv;
10898 }
10899 intptr_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
10900         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
10901         intptr_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
10902         return ret_val;
10903 }
10904
10905 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
10906         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
10907         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
10908         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
10909         return (uintptr_t)ret_conv;
10910 }
10911
10912 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
10913         LDKCVec_RouteHopZ _res_constr;
10914         _res_constr.datalen = _res->arr_len;
10915         if (_res_constr.datalen > 0)
10916                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10917         else
10918                 _res_constr.data = NULL;
10919         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
10920         for (size_t k = 0; k < _res_constr.datalen; k++) {
10921                 uint32_t _res_conv_10 = _res_vals[k];
10922                 LDKRouteHop _res_conv_10_conv;
10923                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
10924                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
10925                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
10926                 _res_constr.data[k] = _res_conv_10_conv;
10927         }
10928         CVec_RouteHopZ_free(_res_constr);
10929 }
10930
10931 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
10932         LDKCVec_CVec_RouteHopZZ _res_constr;
10933         _res_constr.datalen = _res->arr_len;
10934         if (_res_constr.datalen > 0)
10935                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
10936         else
10937                 _res_constr.data = NULL;
10938         uint32_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
10939         for (size_t m = 0; m < _res_constr.datalen; m++) {
10940                 uint32_tArray _res_conv_12 = _res_vals[m];
10941                 LDKCVec_RouteHopZ _res_conv_12_constr;
10942                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
10943                 if (_res_conv_12_constr.datalen > 0)
10944                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10945                 else
10946                         _res_conv_12_constr.data = NULL;
10947                 uint32_t* _res_conv_12_vals = _res_conv_12->elems /* XXX _res_conv_12 leaks */;
10948                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
10949                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
10950                         LDKRouteHop _res_conv_12_conv_10_conv;
10951                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
10952                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
10953                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
10954                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
10955                 }
10956                 _res_constr.data[m] = _res_conv_12_constr;
10957         }
10958         CVec_CVec_RouteHopZZ_free(_res_constr);
10959 }
10960
10961 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
10962         LDKRoute o_conv;
10963         o_conv.inner = (void*)(o & (~1));
10964         o_conv.is_owned = (o & 1) || (o == 0);
10965         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10966         o_conv = Route_clone(&o_conv);
10967         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
10968         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
10969         return (uintptr_t)ret_conv;
10970 }
10971
10972 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
10973         LDKDecodeError e_conv;
10974         e_conv.inner = (void*)(e & (~1));
10975         e_conv.is_owned = (e & 1) || (e == 0);
10976         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10977         e_conv = DecodeError_clone(&e_conv);
10978         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
10979         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
10980         return (uintptr_t)ret_conv;
10981 }
10982
10983 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
10984         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
10985         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
10986         return ret_val;
10987 }
10988
10989 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
10990         if ((_res & 1) != 0) return;
10991         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10992         CHECK_ACCESS(_res_ptr);
10993         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
10994         FREE((void*)_res);
10995         CResult_RouteDecodeErrorZ_free(_res_conv);
10996 }
10997
10998 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
10999         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11000         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
11001         return (uintptr_t)ret_conv;
11002 }
11003 intptr_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
11004         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
11005         intptr_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
11006         return ret_val;
11007 }
11008
11009 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
11010         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
11011         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11012         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
11013         return (uintptr_t)ret_conv;
11014 }
11015
11016 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
11017         LDKRouteParameters o_conv;
11018         o_conv.inner = (void*)(o & (~1));
11019         o_conv.is_owned = (o & 1) || (o == 0);
11020         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11021         o_conv = RouteParameters_clone(&o_conv);
11022         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11023         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
11024         return (uintptr_t)ret_conv;
11025 }
11026
11027 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
11028         LDKDecodeError e_conv;
11029         e_conv.inner = (void*)(e & (~1));
11030         e_conv.is_owned = (e & 1) || (e == 0);
11031         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11032         e_conv = DecodeError_clone(&e_conv);
11033         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11034         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
11035         return (uintptr_t)ret_conv;
11036 }
11037
11038 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
11039         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
11040         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
11041         return ret_val;
11042 }
11043
11044 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
11045         if ((_res & 1) != 0) return;
11046         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11047         CHECK_ACCESS(_res_ptr);
11048         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
11049         FREE((void*)_res);
11050         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
11051 }
11052
11053 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
11054         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11055         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
11056         return (uintptr_t)ret_conv;
11057 }
11058 intptr_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11059         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
11060         intptr_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
11061         return ret_val;
11062 }
11063
11064 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
11065         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
11066         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11067         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
11068         return (uintptr_t)ret_conv;
11069 }
11070
11071 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
11072         LDKCVec_RouteHintZ _res_constr;
11073         _res_constr.datalen = _res->arr_len;
11074         if (_res_constr.datalen > 0)
11075                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
11076         else
11077                 _res_constr.data = NULL;
11078         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11079         for (size_t l = 0; l < _res_constr.datalen; l++) {
11080                 uint32_t _res_conv_11 = _res_vals[l];
11081                 LDKRouteHint _res_conv_11_conv;
11082                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
11083                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
11084                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
11085                 _res_constr.data[l] = _res_conv_11_conv;
11086         }
11087         CVec_RouteHintZ_free(_res_constr);
11088 }
11089
11090 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
11091         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11092         *ret_copy = COption_u64Z_some(o);
11093         uintptr_t ret_ref = (uintptr_t)ret_copy;
11094         return ret_ref;
11095 }
11096
11097 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
11098         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11099         *ret_copy = COption_u64Z_none();
11100         uintptr_t ret_ref = (uintptr_t)ret_copy;
11101         return ret_ref;
11102 }
11103
11104 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
11105         if ((_res & 1) != 0) return;
11106         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11107         CHECK_ACCESS(_res_ptr);
11108         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
11109         FREE((void*)_res);
11110         COption_u64Z_free(_res_conv);
11111 }
11112
11113 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
11114         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11115         *ret_copy = COption_u64Z_clone(arg);
11116 uintptr_t ret_ref = (uintptr_t)ret_copy;
11117         return ret_ref;
11118 }
11119 intptr_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
11120         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
11121         intptr_t ret_val = COption_u64Z_clone_ptr(arg_conv);
11122         return ret_val;
11123 }
11124
11125 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
11126         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
11127         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11128         *ret_copy = COption_u64Z_clone(orig_conv);
11129         uintptr_t ret_ref = (uintptr_t)ret_copy;
11130         return ret_ref;
11131 }
11132
11133 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_ok"))) TS_CResult_PayeeDecodeErrorZ_ok(uint32_t o) {
11134         LDKPayee o_conv;
11135         o_conv.inner = (void*)(o & (~1));
11136         o_conv.is_owned = (o & 1) || (o == 0);
11137         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11138         o_conv = Payee_clone(&o_conv);
11139         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
11140         *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
11141         return (uintptr_t)ret_conv;
11142 }
11143
11144 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_err"))) TS_CResult_PayeeDecodeErrorZ_err(uint32_t e) {
11145         LDKDecodeError e_conv;
11146         e_conv.inner = (void*)(e & (~1));
11147         e_conv.is_owned = (e & 1) || (e == 0);
11148         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11149         e_conv = DecodeError_clone(&e_conv);
11150         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
11151         *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
11152         return (uintptr_t)ret_conv;
11153 }
11154
11155 jboolean  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_is_ok"))) TS_CResult_PayeeDecodeErrorZ_is_ok(uint32_t o) {
11156         LDKCResult_PayeeDecodeErrorZ* o_conv = (LDKCResult_PayeeDecodeErrorZ*)(o & ~1);
11157         jboolean ret_val = CResult_PayeeDecodeErrorZ_is_ok(o_conv);
11158         return ret_val;
11159 }
11160
11161 void  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_free"))) TS_CResult_PayeeDecodeErrorZ_free(uint32_t _res) {
11162         if ((_res & 1) != 0) return;
11163         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11164         CHECK_ACCESS(_res_ptr);
11165         LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
11166         FREE((void*)_res);
11167         CResult_PayeeDecodeErrorZ_free(_res_conv);
11168 }
11169
11170 static inline uintptr_t CResult_PayeeDecodeErrorZ_clone_ptr(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR arg) {
11171         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
11172         *ret_conv = CResult_PayeeDecodeErrorZ_clone(arg);
11173         return (uintptr_t)ret_conv;
11174 }
11175 intptr_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_clone_ptr"))) TS_CResult_PayeeDecodeErrorZ_clone_ptr(uint32_t arg) {
11176         LDKCResult_PayeeDecodeErrorZ* arg_conv = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
11177         intptr_t ret_val = CResult_PayeeDecodeErrorZ_clone_ptr(arg_conv);
11178         return ret_val;
11179 }
11180
11181 uint32_t  __attribute__((export_name("TS_CResult_PayeeDecodeErrorZ_clone"))) TS_CResult_PayeeDecodeErrorZ_clone(uint32_t orig) {
11182         LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
11183         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
11184         *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
11185         return (uintptr_t)ret_conv;
11186 }
11187
11188 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
11189         LDKCVec_RouteHintHopZ _res_constr;
11190         _res_constr.datalen = _res->arr_len;
11191         if (_res_constr.datalen > 0)
11192                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
11193         else
11194                 _res_constr.data = NULL;
11195         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11196         for (size_t o = 0; o < _res_constr.datalen; o++) {
11197                 uint32_t _res_conv_14 = _res_vals[o];
11198                 LDKRouteHintHop _res_conv_14_conv;
11199                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
11200                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
11201                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
11202                 _res_constr.data[o] = _res_conv_14_conv;
11203         }
11204         CVec_RouteHintHopZ_free(_res_constr);
11205 }
11206
11207 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
11208         LDKRouteHint o_conv;
11209         o_conv.inner = (void*)(o & (~1));
11210         o_conv.is_owned = (o & 1) || (o == 0);
11211         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11212         o_conv = RouteHint_clone(&o_conv);
11213         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11214         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
11215         return (uintptr_t)ret_conv;
11216 }
11217
11218 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
11219         LDKDecodeError e_conv;
11220         e_conv.inner = (void*)(e & (~1));
11221         e_conv.is_owned = (e & 1) || (e == 0);
11222         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11223         e_conv = DecodeError_clone(&e_conv);
11224         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11225         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
11226         return (uintptr_t)ret_conv;
11227 }
11228
11229 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
11230         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
11231         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
11232         return ret_val;
11233 }
11234
11235 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
11236         if ((_res & 1) != 0) return;
11237         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11238         CHECK_ACCESS(_res_ptr);
11239         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
11240         FREE((void*)_res);
11241         CResult_RouteHintDecodeErrorZ_free(_res_conv);
11242 }
11243
11244 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
11245         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11246         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
11247         return (uintptr_t)ret_conv;
11248 }
11249 intptr_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
11250         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
11251         intptr_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
11252         return ret_val;
11253 }
11254
11255 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
11256         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
11257         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
11258         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
11259         return (uintptr_t)ret_conv;
11260 }
11261
11262 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
11263         LDKRouteHintHop o_conv;
11264         o_conv.inner = (void*)(o & (~1));
11265         o_conv.is_owned = (o & 1) || (o == 0);
11266         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11267         o_conv = RouteHintHop_clone(&o_conv);
11268         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11269         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
11270         return (uintptr_t)ret_conv;
11271 }
11272
11273 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
11274         LDKDecodeError e_conv;
11275         e_conv.inner = (void*)(e & (~1));
11276         e_conv.is_owned = (e & 1) || (e == 0);
11277         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11278         e_conv = DecodeError_clone(&e_conv);
11279         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11280         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
11281         return (uintptr_t)ret_conv;
11282 }
11283
11284 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
11285         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
11286         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
11287         return ret_val;
11288 }
11289
11290 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
11291         if ((_res & 1) != 0) return;
11292         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11293         CHECK_ACCESS(_res_ptr);
11294         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
11295         FREE((void*)_res);
11296         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
11297 }
11298
11299 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
11300         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11301         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
11302         return (uintptr_t)ret_conv;
11303 }
11304 intptr_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
11305         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
11306         intptr_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
11307         return ret_val;
11308 }
11309
11310 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
11311         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
11312         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
11313         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
11314         return (uintptr_t)ret_conv;
11315 }
11316
11317 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
11318         LDKCVec_ChannelDetailsZ _res_constr;
11319         _res_constr.datalen = _res->arr_len;
11320         if (_res_constr.datalen > 0)
11321                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
11322         else
11323                 _res_constr.data = NULL;
11324         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11325         for (size_t q = 0; q < _res_constr.datalen; q++) {
11326                 uint32_t _res_conv_16 = _res_vals[q];
11327                 LDKChannelDetails _res_conv_16_conv;
11328                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
11329                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
11330                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
11331                 _res_constr.data[q] = _res_conv_16_conv;
11332         }
11333         CVec_ChannelDetailsZ_free(_res_constr);
11334 }
11335
11336 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
11337         LDKRoute o_conv;
11338         o_conv.inner = (void*)(o & (~1));
11339         o_conv.is_owned = (o & 1) || (o == 0);
11340         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11341         o_conv = Route_clone(&o_conv);
11342         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11343         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
11344         return (uintptr_t)ret_conv;
11345 }
11346
11347 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
11348         LDKLightningError e_conv;
11349         e_conv.inner = (void*)(e & (~1));
11350         e_conv.is_owned = (e & 1) || (e == 0);
11351         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11352         e_conv = LightningError_clone(&e_conv);
11353         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11354         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
11355         return (uintptr_t)ret_conv;
11356 }
11357
11358 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
11359         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
11360         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
11361         return ret_val;
11362 }
11363
11364 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
11365         if ((_res & 1) != 0) return;
11366         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11367         CHECK_ACCESS(_res_ptr);
11368         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
11369         FREE((void*)_res);
11370         CResult_RouteLightningErrorZ_free(_res_conv);
11371 }
11372
11373 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
11374         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11375         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
11376         return (uintptr_t)ret_conv;
11377 }
11378 intptr_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
11379         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
11380         intptr_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
11381         return ret_val;
11382 }
11383
11384 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
11385         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
11386         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11387         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
11388         return (uintptr_t)ret_conv;
11389 }
11390
11391 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
11392         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11393         *ret_conv = CResult_NoneLightningErrorZ_ok();
11394         return (uintptr_t)ret_conv;
11395 }
11396
11397 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
11398         LDKLightningError e_conv;
11399         e_conv.inner = (void*)(e & (~1));
11400         e_conv.is_owned = (e & 1) || (e == 0);
11401         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11402         e_conv = LightningError_clone(&e_conv);
11403         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11404         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
11405         return (uintptr_t)ret_conv;
11406 }
11407
11408 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
11409         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
11410         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
11411         return ret_val;
11412 }
11413
11414 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
11415         if ((_res & 1) != 0) return;
11416         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11417         CHECK_ACCESS(_res_ptr);
11418         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
11419         FREE((void*)_res);
11420         CResult_NoneLightningErrorZ_free(_res_conv);
11421 }
11422
11423 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
11424         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11425         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
11426         return (uintptr_t)ret_conv;
11427 }
11428 intptr_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
11429         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
11430         intptr_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
11431         return ret_val;
11432 }
11433
11434 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
11435         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
11436         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
11437         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
11438         return (uintptr_t)ret_conv;
11439 }
11440
11441 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
11442         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
11443         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
11444         return ((uintptr_t)ret_conv);
11445 }
11446 intptr_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
11447         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
11448         intptr_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
11449         return ret_val;
11450 }
11451
11452 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
11453         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
11454         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
11455         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
11456         return ((uintptr_t)ret_conv);
11457 }
11458
11459 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
11460         LDKPublicKey a_ref;
11461         CHECK(a->arr_len == 33);
11462         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
11463         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
11464         CHECK_ACCESS(b_ptr);
11465         LDKType b_conv = *(LDKType*)(b_ptr);
11466         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
11467         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
11468         return ((uintptr_t)ret_conv);
11469 }
11470
11471 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
11472         if ((_res & 1) != 0) return;
11473         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11474         CHECK_ACCESS(_res_ptr);
11475         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
11476         FREE((void*)_res);
11477         C2Tuple_PublicKeyTypeZ_free(_res_conv);
11478 }
11479
11480 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
11481         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
11482         _res_constr.datalen = _res->arr_len;
11483         if (_res_constr.datalen > 0)
11484                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
11485         else
11486                 _res_constr.data = NULL;
11487         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11488         for (size_t z = 0; z < _res_constr.datalen; z++) {
11489                 uint32_t _res_conv_25 = _res_vals[z];
11490                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
11491                 CHECK_ACCESS(_res_conv_25_ptr);
11492                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
11493                 FREE((void*)_res_conv_25);
11494                 _res_constr.data[z] = _res_conv_25_conv;
11495         }
11496         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
11497 }
11498
11499 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
11500         LDKCVec_MessageSendEventZ _res_constr;
11501         _res_constr.datalen = _res->arr_len;
11502         if (_res_constr.datalen > 0)
11503                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
11504         else
11505                 _res_constr.data = NULL;
11506         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11507         for (size_t s = 0; s < _res_constr.datalen; s++) {
11508                 uint32_t _res_conv_18 = _res_vals[s];
11509                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
11510                 CHECK_ACCESS(_res_conv_18_ptr);
11511                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
11512                 FREE((void*)_res_conv_18);
11513                 _res_constr.data[s] = _res_conv_18_conv;
11514         }
11515         CVec_MessageSendEventZ_free(_res_constr);
11516 }
11517
11518 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
11519         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11520         *ret_conv = CResult_boolLightningErrorZ_ok(o);
11521         return (uintptr_t)ret_conv;
11522 }
11523
11524 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
11525         LDKLightningError e_conv;
11526         e_conv.inner = (void*)(e & (~1));
11527         e_conv.is_owned = (e & 1) || (e == 0);
11528         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11529         e_conv = LightningError_clone(&e_conv);
11530         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11531         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
11532         return (uintptr_t)ret_conv;
11533 }
11534
11535 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
11536         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
11537         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
11538         return ret_val;
11539 }
11540
11541 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
11542         if ((_res & 1) != 0) return;
11543         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11544         CHECK_ACCESS(_res_ptr);
11545         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
11546         FREE((void*)_res);
11547         CResult_boolLightningErrorZ_free(_res_conv);
11548 }
11549
11550 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
11551         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11552         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
11553         return (uintptr_t)ret_conv;
11554 }
11555 intptr_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
11556         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
11557         intptr_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
11558         return ret_val;
11559 }
11560
11561 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
11562         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
11563         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
11564         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
11565         return (uintptr_t)ret_conv;
11566 }
11567
11568 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
11569         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11570         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
11571         return ((uintptr_t)ret_conv);
11572 }
11573 intptr_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
11574         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
11575         intptr_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
11576         return ret_val;
11577 }
11578
11579 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
11580         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
11581         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11582         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
11583         return ((uintptr_t)ret_conv);
11584 }
11585
11586 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
11587         LDKChannelAnnouncement a_conv;
11588         a_conv.inner = (void*)(a & (~1));
11589         a_conv.is_owned = (a & 1) || (a == 0);
11590         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
11591         a_conv = ChannelAnnouncement_clone(&a_conv);
11592         LDKChannelUpdate b_conv;
11593         b_conv.inner = (void*)(b & (~1));
11594         b_conv.is_owned = (b & 1) || (b == 0);
11595         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
11596         b_conv = ChannelUpdate_clone(&b_conv);
11597         LDKChannelUpdate c_conv;
11598         c_conv.inner = (void*)(c & (~1));
11599         c_conv.is_owned = (c & 1) || (c == 0);
11600         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
11601         c_conv = ChannelUpdate_clone(&c_conv);
11602         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
11603         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
11604         return ((uintptr_t)ret_conv);
11605 }
11606
11607 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
11608         if ((_res & 1) != 0) return;
11609         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11610         CHECK_ACCESS(_res_ptr);
11611         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
11612         FREE((void*)_res);
11613         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
11614 }
11615
11616 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
11617         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
11618         _res_constr.datalen = _res->arr_len;
11619         if (_res_constr.datalen > 0)
11620                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
11621         else
11622                 _res_constr.data = NULL;
11623         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11624         for (size_t h = 0; h < _res_constr.datalen; h++) {
11625                 uint32_t _res_conv_59 = _res_vals[h];
11626                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
11627                 CHECK_ACCESS(_res_conv_59_ptr);
11628                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
11629                 FREE((void*)_res_conv_59);
11630                 _res_constr.data[h] = _res_conv_59_conv;
11631         }
11632         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
11633 }
11634
11635 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
11636         LDKCVec_NodeAnnouncementZ _res_constr;
11637         _res_constr.datalen = _res->arr_len;
11638         if (_res_constr.datalen > 0)
11639                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
11640         else
11641                 _res_constr.data = NULL;
11642         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11643         for (size_t s = 0; s < _res_constr.datalen; s++) {
11644                 uint32_t _res_conv_18 = _res_vals[s];
11645                 LDKNodeAnnouncement _res_conv_18_conv;
11646                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
11647                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
11648                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
11649                 _res_constr.data[s] = _res_conv_18_conv;
11650         }
11651         CVec_NodeAnnouncementZ_free(_res_constr);
11652 }
11653
11654 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
11655         LDKCVec_PublicKeyZ _res_constr;
11656         _res_constr.datalen = _res->arr_len;
11657         if (_res_constr.datalen > 0)
11658                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
11659         else
11660                 _res_constr.data = NULL;
11661         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11662         for (size_t m = 0; m < _res_constr.datalen; m++) {
11663                 int8_tArray _res_conv_12 = _res_vals[m];
11664                 LDKPublicKey _res_conv_12_ref;
11665                 CHECK(_res_conv_12->arr_len == 33);
11666                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
11667                 _res_constr.data[m] = _res_conv_12_ref;
11668         }
11669         CVec_PublicKeyZ_free(_res_constr);
11670 }
11671
11672 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
11673         LDKCVec_u8Z _res_ref;
11674         _res_ref.datalen = _res->arr_len;
11675         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
11676         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
11677         CVec_u8Z_free(_res_ref);
11678 }
11679
11680 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
11681         LDKCVec_u8Z o_ref;
11682         o_ref.datalen = o->arr_len;
11683         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
11684         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
11685         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11686         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
11687         return (uintptr_t)ret_conv;
11688 }
11689
11690 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
11691         LDKPeerHandleError e_conv;
11692         e_conv.inner = (void*)(e & (~1));
11693         e_conv.is_owned = (e & 1) || (e == 0);
11694         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11695         e_conv = PeerHandleError_clone(&e_conv);
11696         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11697         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
11698         return (uintptr_t)ret_conv;
11699 }
11700
11701 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
11702         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
11703         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
11704         return ret_val;
11705 }
11706
11707 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
11708         if ((_res & 1) != 0) return;
11709         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11710         CHECK_ACCESS(_res_ptr);
11711         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
11712         FREE((void*)_res);
11713         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
11714 }
11715
11716 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
11717         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11718         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
11719         return (uintptr_t)ret_conv;
11720 }
11721 intptr_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
11722         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
11723         intptr_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
11724         return ret_val;
11725 }
11726
11727 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
11728         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
11729         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11730         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
11731         return (uintptr_t)ret_conv;
11732 }
11733
11734 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
11735         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11736         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
11737         return (uintptr_t)ret_conv;
11738 }
11739
11740 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
11741         LDKPeerHandleError e_conv;
11742         e_conv.inner = (void*)(e & (~1));
11743         e_conv.is_owned = (e & 1) || (e == 0);
11744         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11745         e_conv = PeerHandleError_clone(&e_conv);
11746         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11747         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
11748         return (uintptr_t)ret_conv;
11749 }
11750
11751 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
11752         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
11753         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
11754         return ret_val;
11755 }
11756
11757 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
11758         if ((_res & 1) != 0) return;
11759         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11760         CHECK_ACCESS(_res_ptr);
11761         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
11762         FREE((void*)_res);
11763         CResult_NonePeerHandleErrorZ_free(_res_conv);
11764 }
11765
11766 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
11767         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11768         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
11769         return (uintptr_t)ret_conv;
11770 }
11771 intptr_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
11772         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
11773         intptr_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
11774         return ret_val;
11775 }
11776
11777 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
11778         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
11779         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11780         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
11781         return (uintptr_t)ret_conv;
11782 }
11783
11784 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
11785         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11786         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
11787         return (uintptr_t)ret_conv;
11788 }
11789
11790 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
11791         LDKPeerHandleError e_conv;
11792         e_conv.inner = (void*)(e & (~1));
11793         e_conv.is_owned = (e & 1) || (e == 0);
11794         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11795         e_conv = PeerHandleError_clone(&e_conv);
11796         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11797         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
11798         return (uintptr_t)ret_conv;
11799 }
11800
11801 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
11802         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
11803         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
11804         return ret_val;
11805 }
11806
11807 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
11808         if ((_res & 1) != 0) return;
11809         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11810         CHECK_ACCESS(_res_ptr);
11811         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
11812         FREE((void*)_res);
11813         CResult_boolPeerHandleErrorZ_free(_res_conv);
11814 }
11815
11816 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
11817         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11818         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
11819         return (uintptr_t)ret_conv;
11820 }
11821 intptr_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
11822         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
11823         intptr_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
11824         return ret_val;
11825 }
11826
11827 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
11828         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
11829         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11830         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
11831         return (uintptr_t)ret_conv;
11832 }
11833
11834 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
11835         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
11836         CHECK_ACCESS(o_ptr);
11837         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
11838         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
11839         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11840         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
11841         return (uintptr_t)ret_conv;
11842 }
11843
11844 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
11845         LDKAccessError e_conv = LDKAccessError_from_js(e);
11846         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11847         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
11848         return (uintptr_t)ret_conv;
11849 }
11850
11851 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
11852         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
11853         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
11854         return ret_val;
11855 }
11856
11857 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
11858         if ((_res & 1) != 0) return;
11859         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11860         CHECK_ACCESS(_res_ptr);
11861         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
11862         FREE((void*)_res);
11863         CResult_TxOutAccessErrorZ_free(_res_conv);
11864 }
11865
11866 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
11867         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11868         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
11869         return (uintptr_t)ret_conv;
11870 }
11871 intptr_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
11872         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
11873         intptr_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
11874         return ret_val;
11875 }
11876
11877 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
11878         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
11879         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
11880         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
11881         return (uintptr_t)ret_conv;
11882 }
11883
11884 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
11885         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11886         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
11887         return (uintptr_t)ret_conv;
11888 }
11889
11890 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
11891         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
11892         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11893         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
11894         return (uintptr_t)ret_conv;
11895 }
11896
11897 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
11898         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
11899         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
11900         return ret_val;
11901 }
11902
11903 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
11904         if ((_res & 1) != 0) return;
11905         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11906         CHECK_ACCESS(_res_ptr);
11907         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
11908         FREE((void*)_res);
11909         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
11910 }
11911
11912 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
11913         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11914         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
11915         return (uintptr_t)ret_conv;
11916 }
11917 intptr_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
11918         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
11919         intptr_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
11920         return ret_val;
11921 }
11922
11923 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
11924         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
11925         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11926         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
11927         return (uintptr_t)ret_conv;
11928 }
11929
11930 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
11931         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
11932         CHECK_ACCESS(o_ptr);
11933         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
11934         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
11935         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11936         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
11937         uintptr_t ret_ref = (uintptr_t)ret_copy;
11938         return ret_ref;
11939 }
11940
11941 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
11942         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11943         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
11944         uintptr_t ret_ref = (uintptr_t)ret_copy;
11945         return ret_ref;
11946 }
11947
11948 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
11949         if ((_res & 1) != 0) return;
11950         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11951         CHECK_ACCESS(_res_ptr);
11952         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
11953         FREE((void*)_res);
11954         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
11955 }
11956
11957 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
11958         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11959         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
11960 uintptr_t ret_ref = (uintptr_t)ret_copy;
11961         return ret_ref;
11962 }
11963 intptr_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
11964         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
11965         intptr_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
11966         return ret_val;
11967 }
11968
11969 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
11970         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
11971         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
11972         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
11973         uintptr_t ret_ref = (uintptr_t)ret_copy;
11974         return ret_ref;
11975 }
11976
11977 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
11978         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
11979         CHECK_ACCESS(o_ptr);
11980         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
11981         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
11982         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
11983         *ret_copy = COption_ClosureReasonZ_some(o_conv);
11984         uintptr_t ret_ref = (uintptr_t)ret_copy;
11985         return ret_ref;
11986 }
11987
11988 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
11989         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
11990         *ret_copy = COption_ClosureReasonZ_none();
11991         uintptr_t ret_ref = (uintptr_t)ret_copy;
11992         return ret_ref;
11993 }
11994
11995 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
11996         if ((_res & 1) != 0) return;
11997         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11998         CHECK_ACCESS(_res_ptr);
11999         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12000         FREE((void*)_res);
12001         COption_ClosureReasonZ_free(_res_conv);
12002 }
12003
12004 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12005         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12006         *ret_copy = COption_ClosureReasonZ_clone(arg);
12007 uintptr_t ret_ref = (uintptr_t)ret_copy;
12008         return ret_ref;
12009 }
12010 intptr_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
12011         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12012         intptr_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
12013         return ret_val;
12014 }
12015
12016 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
12017         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12018         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12019         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12020         uintptr_t ret_ref = (uintptr_t)ret_copy;
12021         return ret_ref;
12022 }
12023
12024 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
12025         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12026         CHECK_ACCESS(o_ptr);
12027         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12028         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
12029         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12030         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12031         return (uintptr_t)ret_conv;
12032 }
12033
12034 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
12035         LDKDecodeError e_conv;
12036         e_conv.inner = (void*)(e & (~1));
12037         e_conv.is_owned = (e & 1) || (e == 0);
12038         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12039         e_conv = DecodeError_clone(&e_conv);
12040         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12041         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12042         return (uintptr_t)ret_conv;
12043 }
12044
12045 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
12046         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12047         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12048         return ret_val;
12049 }
12050
12051 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
12052         if ((_res & 1) != 0) return;
12053         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12054         CHECK_ACCESS(_res_ptr);
12055         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12056         FREE((void*)_res);
12057         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12058 }
12059
12060 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12061         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12062         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12063         return (uintptr_t)ret_conv;
12064 }
12065 intptr_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
12066         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12067         intptr_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12068         return ret_val;
12069 }
12070
12071 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
12072         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12073         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12074         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12075         return (uintptr_t)ret_conv;
12076 }
12077
12078 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
12079         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12080         CHECK_ACCESS(o_ptr);
12081         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12082         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
12083         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12084         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12085         uintptr_t ret_ref = (uintptr_t)ret_copy;
12086         return ret_ref;
12087 }
12088
12089 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
12090         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12091         *ret_copy = COption_NetworkUpdateZ_none();
12092         uintptr_t ret_ref = (uintptr_t)ret_copy;
12093         return ret_ref;
12094 }
12095
12096 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
12097         if ((_res & 1) != 0) return;
12098         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12099         CHECK_ACCESS(_res_ptr);
12100         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12101         FREE((void*)_res);
12102         COption_NetworkUpdateZ_free(_res_conv);
12103 }
12104
12105 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12106         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12107         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12108 uintptr_t ret_ref = (uintptr_t)ret_copy;
12109         return ret_ref;
12110 }
12111 intptr_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
12112         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12113         intptr_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12114         return ret_val;
12115 }
12116
12117 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
12118         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12119         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12120         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12121         uintptr_t ret_ref = (uintptr_t)ret_copy;
12122         return ret_ref;
12123 }
12124
12125 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
12126         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12127         _res_constr.datalen = _res->arr_len;
12128         if (_res_constr.datalen > 0)
12129                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12130         else
12131                 _res_constr.data = NULL;
12132         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12133         for (size_t b = 0; b < _res_constr.datalen; b++) {
12134                 uint32_t _res_conv_27 = _res_vals[b];
12135                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
12136                 CHECK_ACCESS(_res_conv_27_ptr);
12137                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12138                 FREE((void*)_res_conv_27);
12139                 _res_constr.data[b] = _res_conv_27_conv;
12140         }
12141         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12142 }
12143
12144 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
12145         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12146         CHECK_ACCESS(o_ptr);
12147         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12148         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
12149         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12150         *ret_copy = COption_EventZ_some(o_conv);
12151         uintptr_t ret_ref = (uintptr_t)ret_copy;
12152         return ret_ref;
12153 }
12154
12155 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
12156         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12157         *ret_copy = COption_EventZ_none();
12158         uintptr_t ret_ref = (uintptr_t)ret_copy;
12159         return ret_ref;
12160 }
12161
12162 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
12163         if ((_res & 1) != 0) return;
12164         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12165         CHECK_ACCESS(_res_ptr);
12166         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12167         FREE((void*)_res);
12168         COption_EventZ_free(_res_conv);
12169 }
12170
12171 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12172         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12173         *ret_copy = COption_EventZ_clone(arg);
12174 uintptr_t ret_ref = (uintptr_t)ret_copy;
12175         return ret_ref;
12176 }
12177 intptr_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
12178         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12179         intptr_t ret_val = COption_EventZ_clone_ptr(arg_conv);
12180         return ret_val;
12181 }
12182
12183 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
12184         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12185         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12186         *ret_copy = COption_EventZ_clone(orig_conv);
12187         uintptr_t ret_ref = (uintptr_t)ret_copy;
12188         return ret_ref;
12189 }
12190
12191 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
12192         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12193         CHECK_ACCESS(o_ptr);
12194         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12195         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
12196         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12197         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12198         return (uintptr_t)ret_conv;
12199 }
12200
12201 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
12202         LDKDecodeError e_conv;
12203         e_conv.inner = (void*)(e & (~1));
12204         e_conv.is_owned = (e & 1) || (e == 0);
12205         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12206         e_conv = DecodeError_clone(&e_conv);
12207         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12208         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
12209         return (uintptr_t)ret_conv;
12210 }
12211
12212 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
12213         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
12214         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
12215         return ret_val;
12216 }
12217
12218 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
12219         if ((_res & 1) != 0) return;
12220         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12221         CHECK_ACCESS(_res_ptr);
12222         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
12223         FREE((void*)_res);
12224         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
12225 }
12226
12227 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
12228         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12229         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
12230         return (uintptr_t)ret_conv;
12231 }
12232 intptr_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12233         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
12234         intptr_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
12235         return ret_val;
12236 }
12237
12238 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
12239         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
12240         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12241         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
12242         return (uintptr_t)ret_conv;
12243 }
12244
12245 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
12246         LDKNodeId o_conv;
12247         o_conv.inner = (void*)(o & (~1));
12248         o_conv.is_owned = (o & 1) || (o == 0);
12249         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12250         o_conv = NodeId_clone(&o_conv);
12251         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12252         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
12253         return (uintptr_t)ret_conv;
12254 }
12255
12256 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
12257         LDKDecodeError e_conv;
12258         e_conv.inner = (void*)(e & (~1));
12259         e_conv.is_owned = (e & 1) || (e == 0);
12260         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12261         e_conv = DecodeError_clone(&e_conv);
12262         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12263         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
12264         return (uintptr_t)ret_conv;
12265 }
12266
12267 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
12268         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
12269         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
12270         return ret_val;
12271 }
12272
12273 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
12274         if ((_res & 1) != 0) return;
12275         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12276         CHECK_ACCESS(_res_ptr);
12277         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
12278         FREE((void*)_res);
12279         CResult_NodeIdDecodeErrorZ_free(_res_conv);
12280 }
12281
12282 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
12283         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12284         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
12285         return (uintptr_t)ret_conv;
12286 }
12287 intptr_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
12288         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
12289         intptr_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
12290         return ret_val;
12291 }
12292
12293 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
12294         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
12295         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
12296         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
12297         return (uintptr_t)ret_conv;
12298 }
12299
12300 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
12301         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12302         CHECK_ACCESS(o_ptr);
12303         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
12304         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
12305         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
12306         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
12307         return (uintptr_t)ret_conv;
12308 }
12309
12310 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
12311         LDKDecodeError e_conv;
12312         e_conv.inner = (void*)(e & (~1));
12313         e_conv.is_owned = (e & 1) || (e == 0);
12314         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12315         e_conv = DecodeError_clone(&e_conv);
12316         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
12317         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
12318         return (uintptr_t)ret_conv;
12319 }
12320
12321 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
12322         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
12323         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
12324         return ret_val;
12325 }
12326
12327 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
12328         if ((_res & 1) != 0) return;
12329         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12330         CHECK_ACCESS(_res_ptr);
12331         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
12332         FREE((void*)_res);
12333         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
12334 }
12335
12336 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
12337         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
12338         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
12339         return (uintptr_t)ret_conv;
12340 }
12341 intptr_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
12342         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
12343         intptr_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
12344         return ret_val;
12345 }
12346
12347 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
12348         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
12349         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
12350         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
12351         return (uintptr_t)ret_conv;
12352 }
12353
12354 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
12355         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12356         CHECK_ACCESS(o_ptr);
12357         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
12358         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
12359         *ret_copy = COption_AccessZ_some(o_conv);
12360         uintptr_t ret_ref = (uintptr_t)ret_copy;
12361         return ret_ref;
12362 }
12363
12364 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
12365         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
12366         *ret_copy = COption_AccessZ_none();
12367         uintptr_t ret_ref = (uintptr_t)ret_copy;
12368         return ret_ref;
12369 }
12370
12371 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
12372         if ((_res & 1) != 0) return;
12373         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12374         CHECK_ACCESS(_res_ptr);
12375         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
12376         FREE((void*)_res);
12377         COption_AccessZ_free(_res_conv);
12378 }
12379
12380 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_ok(uint32_t o) {
12381         LDKDirectionalChannelInfo o_conv;
12382         o_conv.inner = (void*)(o & (~1));
12383         o_conv.is_owned = (o & 1) || (o == 0);
12384         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12385         o_conv = DirectionalChannelInfo_clone(&o_conv);
12386         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12387         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
12388         return (uintptr_t)ret_conv;
12389 }
12390
12391 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_err"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_err(uint32_t e) {
12392         LDKDecodeError e_conv;
12393         e_conv.inner = (void*)(e & (~1));
12394         e_conv.is_owned = (e & 1) || (e == 0);
12395         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12396         e_conv = DecodeError_clone(&e_conv);
12397         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12398         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
12399         return (uintptr_t)ret_conv;
12400 }
12401
12402 jboolean  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
12403         LDKCResult_DirectionalChannelInfoDecodeErrorZ* o_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(o & ~1);
12404         jboolean ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(o_conv);
12405         return ret_val;
12406 }
12407
12408 void  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_free"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_free(uint32_t _res) {
12409         if ((_res & 1) != 0) return;
12410         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12411         CHECK_ACCESS(_res_ptr);
12412         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
12413         FREE((void*)_res);
12414         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
12415 }
12416
12417 static inline uintptr_t CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
12418         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12419         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(arg);
12420         return (uintptr_t)ret_conv;
12421 }
12422 intptr_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
12423         LDKCResult_DirectionalChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
12424         intptr_t ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
12425         return ret_val;
12426 }
12427
12428 uint32_t  __attribute__((export_name("TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone"))) TS_CResult_DirectionalChannelInfoDecodeErrorZ_clone(uint32_t orig) {
12429         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
12430         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
12431         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
12432         return (uintptr_t)ret_conv;
12433 }
12434
12435 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
12436         LDKChannelInfo o_conv;
12437         o_conv.inner = (void*)(o & (~1));
12438         o_conv.is_owned = (o & 1) || (o == 0);
12439         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12440         o_conv = ChannelInfo_clone(&o_conv);
12441         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12442         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
12443         return (uintptr_t)ret_conv;
12444 }
12445
12446 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
12447         LDKDecodeError e_conv;
12448         e_conv.inner = (void*)(e & (~1));
12449         e_conv.is_owned = (e & 1) || (e == 0);
12450         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12451         e_conv = DecodeError_clone(&e_conv);
12452         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12453         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
12454         return (uintptr_t)ret_conv;
12455 }
12456
12457 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
12458         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
12459         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
12460         return ret_val;
12461 }
12462
12463 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
12464         if ((_res & 1) != 0) return;
12465         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12466         CHECK_ACCESS(_res_ptr);
12467         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
12468         FREE((void*)_res);
12469         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
12470 }
12471
12472 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
12473         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12474         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
12475         return (uintptr_t)ret_conv;
12476 }
12477 intptr_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
12478         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
12479         intptr_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
12480         return ret_val;
12481 }
12482
12483 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
12484         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
12485         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
12486         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
12487         return (uintptr_t)ret_conv;
12488 }
12489
12490 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
12491         LDKRoutingFees o_conv;
12492         o_conv.inner = (void*)(o & (~1));
12493         o_conv.is_owned = (o & 1) || (o == 0);
12494         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12495         o_conv = RoutingFees_clone(&o_conv);
12496         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12497         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
12498         return (uintptr_t)ret_conv;
12499 }
12500
12501 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
12502         LDKDecodeError e_conv;
12503         e_conv.inner = (void*)(e & (~1));
12504         e_conv.is_owned = (e & 1) || (e == 0);
12505         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12506         e_conv = DecodeError_clone(&e_conv);
12507         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12508         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
12509         return (uintptr_t)ret_conv;
12510 }
12511
12512 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
12513         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
12514         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
12515         return ret_val;
12516 }
12517
12518 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
12519         if ((_res & 1) != 0) return;
12520         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12521         CHECK_ACCESS(_res_ptr);
12522         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
12523         FREE((void*)_res);
12524         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
12525 }
12526
12527 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
12528         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12529         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
12530         return (uintptr_t)ret_conv;
12531 }
12532 intptr_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
12533         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
12534         intptr_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
12535         return ret_val;
12536 }
12537
12538 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
12539         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
12540         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
12541         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
12542         return (uintptr_t)ret_conv;
12543 }
12544
12545 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
12546         LDKCVec_NetAddressZ _res_constr;
12547         _res_constr.datalen = _res->arr_len;
12548         if (_res_constr.datalen > 0)
12549                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12550         else
12551                 _res_constr.data = NULL;
12552         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12553         for (size_t m = 0; m < _res_constr.datalen; m++) {
12554                 uint32_t _res_conv_12 = _res_vals[m];
12555                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
12556                 CHECK_ACCESS(_res_conv_12_ptr);
12557                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
12558                 FREE((void*)_res_conv_12);
12559                 _res_constr.data[m] = _res_conv_12_conv;
12560         }
12561         CVec_NetAddressZ_free(_res_constr);
12562 }
12563
12564 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
12565         LDKNodeAnnouncementInfo o_conv;
12566         o_conv.inner = (void*)(o & (~1));
12567         o_conv.is_owned = (o & 1) || (o == 0);
12568         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12569         o_conv = NodeAnnouncementInfo_clone(&o_conv);
12570         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12571         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
12572         return (uintptr_t)ret_conv;
12573 }
12574
12575 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
12576         LDKDecodeError e_conv;
12577         e_conv.inner = (void*)(e & (~1));
12578         e_conv.is_owned = (e & 1) || (e == 0);
12579         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12580         e_conv = DecodeError_clone(&e_conv);
12581         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12582         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
12583         return (uintptr_t)ret_conv;
12584 }
12585
12586 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
12587         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
12588         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
12589         return ret_val;
12590 }
12591
12592 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
12593         if ((_res & 1) != 0) return;
12594         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12595         CHECK_ACCESS(_res_ptr);
12596         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
12597         FREE((void*)_res);
12598         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
12599 }
12600
12601 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
12602         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12603         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
12604         return (uintptr_t)ret_conv;
12605 }
12606 intptr_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
12607         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
12608         intptr_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
12609         return ret_val;
12610 }
12611
12612 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
12613         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
12614         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
12615         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
12616         return (uintptr_t)ret_conv;
12617 }
12618
12619 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
12620         LDKCVec_u64Z _res_constr;
12621         _res_constr.datalen = _res->arr_len;
12622         if (_res_constr.datalen > 0)
12623                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
12624         else
12625                 _res_constr.data = NULL;
12626         int64_t* _res_vals = _res->elems /* XXX _res leaks */;
12627         for (size_t i = 0; i < _res_constr.datalen; i++) {
12628                 int64_t _res_conv_8 = _res_vals[i];
12629                 _res_constr.data[i] = _res_conv_8;
12630         }
12631         CVec_u64Z_free(_res_constr);
12632 }
12633
12634 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
12635         LDKNodeInfo o_conv;
12636         o_conv.inner = (void*)(o & (~1));
12637         o_conv.is_owned = (o & 1) || (o == 0);
12638         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12639         o_conv = NodeInfo_clone(&o_conv);
12640         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12641         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
12642         return (uintptr_t)ret_conv;
12643 }
12644
12645 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
12646         LDKDecodeError e_conv;
12647         e_conv.inner = (void*)(e & (~1));
12648         e_conv.is_owned = (e & 1) || (e == 0);
12649         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12650         e_conv = DecodeError_clone(&e_conv);
12651         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12652         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
12653         return (uintptr_t)ret_conv;
12654 }
12655
12656 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
12657         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
12658         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
12659         return ret_val;
12660 }
12661
12662 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
12663         if ((_res & 1) != 0) return;
12664         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12665         CHECK_ACCESS(_res_ptr);
12666         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
12667         FREE((void*)_res);
12668         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
12669 }
12670
12671 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
12672         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12673         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
12674         return (uintptr_t)ret_conv;
12675 }
12676 intptr_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
12677         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
12678         intptr_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
12679         return ret_val;
12680 }
12681
12682 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
12683         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
12684         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
12685         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
12686         return (uintptr_t)ret_conv;
12687 }
12688
12689 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
12690         LDKNetworkGraph o_conv;
12691         o_conv.inner = (void*)(o & (~1));
12692         o_conv.is_owned = (o & 1) || (o == 0);
12693         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12694         o_conv = NetworkGraph_clone(&o_conv);
12695         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12696         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
12697         return (uintptr_t)ret_conv;
12698 }
12699
12700 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
12701         LDKDecodeError e_conv;
12702         e_conv.inner = (void*)(e & (~1));
12703         e_conv.is_owned = (e & 1) || (e == 0);
12704         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12705         e_conv = DecodeError_clone(&e_conv);
12706         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12707         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
12708         return (uintptr_t)ret_conv;
12709 }
12710
12711 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
12712         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
12713         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
12714         return ret_val;
12715 }
12716
12717 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
12718         if ((_res & 1) != 0) return;
12719         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12720         CHECK_ACCESS(_res_ptr);
12721         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
12722         FREE((void*)_res);
12723         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
12724 }
12725
12726 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
12727         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12728         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
12729         return (uintptr_t)ret_conv;
12730 }
12731 intptr_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr"))) TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr(uint32_t arg) {
12732         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
12733         intptr_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
12734         return ret_val;
12735 }
12736
12737 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
12738         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
12739         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
12740         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
12741         return (uintptr_t)ret_conv;
12742 }
12743
12744 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
12745         LDKCVec_NetAddressZ o_constr;
12746         o_constr.datalen = o->arr_len;
12747         if (o_constr.datalen > 0)
12748                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
12749         else
12750                 o_constr.data = NULL;
12751         uint32_t* o_vals = o->elems /* XXX o leaks */;
12752         for (size_t m = 0; m < o_constr.datalen; m++) {
12753                 uint32_t o_conv_12 = o_vals[m];
12754                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
12755                 CHECK_ACCESS(o_conv_12_ptr);
12756                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
12757                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
12758                 o_constr.data[m] = o_conv_12_conv;
12759         }
12760         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12761         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
12762         uintptr_t ret_ref = (uintptr_t)ret_copy;
12763         return ret_ref;
12764 }
12765
12766 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
12767         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12768         *ret_copy = COption_CVec_NetAddressZZ_none();
12769         uintptr_t ret_ref = (uintptr_t)ret_copy;
12770         return ret_ref;
12771 }
12772
12773 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
12774         if ((_res & 1) != 0) return;
12775         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12776         CHECK_ACCESS(_res_ptr);
12777         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
12778         FREE((void*)_res);
12779         COption_CVec_NetAddressZZ_free(_res_conv);
12780 }
12781
12782 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
12783         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12784         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
12785 uintptr_t ret_ref = (uintptr_t)ret_copy;
12786         return ret_ref;
12787 }
12788 intptr_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
12789         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
12790         intptr_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
12791         return ret_val;
12792 }
12793
12794 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
12795         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
12796         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
12797         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
12798         uintptr_t ret_ref = (uintptr_t)ret_copy;
12799         return ret_ref;
12800 }
12801
12802 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
12803         LDKScoringParameters o_conv;
12804         o_conv.inner = (void*)(o & (~1));
12805         o_conv.is_owned = (o & 1) || (o == 0);
12806         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12807         // Warning: we need a move here but no clone is available for LDKScoringParameters
12808         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12809         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
12810         return (uintptr_t)ret_conv;
12811 }
12812
12813 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_err"))) TS_CResult_ScoringParametersDecodeErrorZ_err(uint32_t e) {
12814         LDKDecodeError e_conv;
12815         e_conv.inner = (void*)(e & (~1));
12816         e_conv.is_owned = (e & 1) || (e == 0);
12817         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12818         e_conv = DecodeError_clone(&e_conv);
12819         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12820         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
12821         return (uintptr_t)ret_conv;
12822 }
12823
12824 jboolean  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_is_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
12825         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
12826         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
12827         return ret_val;
12828 }
12829
12830 void  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_free"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
12831         if ((_res & 1) != 0) return;
12832         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12833         CHECK_ACCESS(_res_ptr);
12834         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
12835         FREE((void*)_res);
12836         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
12837 }
12838
12839 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
12840         LDKInitFeatures o_conv;
12841         o_conv.inner = (void*)(o & (~1));
12842         o_conv.is_owned = (o & 1) || (o == 0);
12843         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12844         o_conv = InitFeatures_clone(&o_conv);
12845         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12846         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
12847         return (uintptr_t)ret_conv;
12848 }
12849
12850 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
12851         LDKDecodeError e_conv;
12852         e_conv.inner = (void*)(e & (~1));
12853         e_conv.is_owned = (e & 1) || (e == 0);
12854         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12855         e_conv = DecodeError_clone(&e_conv);
12856         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12857         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
12858         return (uintptr_t)ret_conv;
12859 }
12860
12861 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12862         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
12863         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
12864         return ret_val;
12865 }
12866
12867 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
12868         if ((_res & 1) != 0) return;
12869         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12870         CHECK_ACCESS(_res_ptr);
12871         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
12872         FREE((void*)_res);
12873         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
12874 }
12875
12876 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
12877         LDKChannelFeatures o_conv;
12878         o_conv.inner = (void*)(o & (~1));
12879         o_conv.is_owned = (o & 1) || (o == 0);
12880         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12881         o_conv = ChannelFeatures_clone(&o_conv);
12882         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12883         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
12884         return (uintptr_t)ret_conv;
12885 }
12886
12887 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
12888         LDKDecodeError e_conv;
12889         e_conv.inner = (void*)(e & (~1));
12890         e_conv.is_owned = (e & 1) || (e == 0);
12891         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12892         e_conv = DecodeError_clone(&e_conv);
12893         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12894         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
12895         return (uintptr_t)ret_conv;
12896 }
12897
12898 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12899         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
12900         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
12901         return ret_val;
12902 }
12903
12904 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
12905         if ((_res & 1) != 0) return;
12906         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12907         CHECK_ACCESS(_res_ptr);
12908         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
12909         FREE((void*)_res);
12910         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
12911 }
12912
12913 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
12914         LDKNodeFeatures o_conv;
12915         o_conv.inner = (void*)(o & (~1));
12916         o_conv.is_owned = (o & 1) || (o == 0);
12917         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12918         o_conv = NodeFeatures_clone(&o_conv);
12919         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12920         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
12921         return (uintptr_t)ret_conv;
12922 }
12923
12924 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
12925         LDKDecodeError e_conv;
12926         e_conv.inner = (void*)(e & (~1));
12927         e_conv.is_owned = (e & 1) || (e == 0);
12928         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12929         e_conv = DecodeError_clone(&e_conv);
12930         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12931         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
12932         return (uintptr_t)ret_conv;
12933 }
12934
12935 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12936         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
12937         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
12938         return ret_val;
12939 }
12940
12941 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
12942         if ((_res & 1) != 0) return;
12943         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12944         CHECK_ACCESS(_res_ptr);
12945         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
12946         FREE((void*)_res);
12947         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
12948 }
12949
12950 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
12951         LDKInvoiceFeatures o_conv;
12952         o_conv.inner = (void*)(o & (~1));
12953         o_conv.is_owned = (o & 1) || (o == 0);
12954         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12955         o_conv = InvoiceFeatures_clone(&o_conv);
12956         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12957         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
12958         return (uintptr_t)ret_conv;
12959 }
12960
12961 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
12962         LDKDecodeError e_conv;
12963         e_conv.inner = (void*)(e & (~1));
12964         e_conv.is_owned = (e & 1) || (e == 0);
12965         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12966         e_conv = DecodeError_clone(&e_conv);
12967         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
12968         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
12969         return (uintptr_t)ret_conv;
12970 }
12971
12972 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12973         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
12974         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
12975         return ret_val;
12976 }
12977
12978 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
12979         if ((_res & 1) != 0) return;
12980         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12981         CHECK_ACCESS(_res_ptr);
12982         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
12983         FREE((void*)_res);
12984         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
12985 }
12986
12987 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
12988         LDKChannelTypeFeatures o_conv;
12989         o_conv.inner = (void*)(o & (~1));
12990         o_conv.is_owned = (o & 1) || (o == 0);
12991         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12992         o_conv = ChannelTypeFeatures_clone(&o_conv);
12993         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
12994         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
12995         return (uintptr_t)ret_conv;
12996 }
12997
12998 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
12999         LDKDecodeError e_conv;
13000         e_conv.inner = (void*)(e & (~1));
13001         e_conv.is_owned = (e & 1) || (e == 0);
13002         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13003         e_conv = DecodeError_clone(&e_conv);
13004         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13005         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
13006         return (uintptr_t)ret_conv;
13007 }
13008
13009 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13010         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
13011         jboolean ret_val = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
13012         return ret_val;
13013 }
13014
13015 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
13016         if ((_res & 1) != 0) return;
13017         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13018         CHECK_ACCESS(_res_ptr);
13019         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
13020         FREE((void*)_res);
13021         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
13022 }
13023
13024 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
13025         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13026         CHECK_ACCESS(o_ptr);
13027         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
13028         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
13029         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13030         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
13031         return (uintptr_t)ret_conv;
13032 }
13033
13034 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
13035         LDKDecodeError e_conv;
13036         e_conv.inner = (void*)(e & (~1));
13037         e_conv.is_owned = (e & 1) || (e == 0);
13038         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13039         e_conv = DecodeError_clone(&e_conv);
13040         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13041         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
13042         return (uintptr_t)ret_conv;
13043 }
13044
13045 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
13046         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
13047         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
13048         return ret_val;
13049 }
13050
13051 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
13052         if ((_res & 1) != 0) return;
13053         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13054         CHECK_ACCESS(_res_ptr);
13055         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
13056         FREE((void*)_res);
13057         CResult_NetAddressDecodeErrorZ_free(_res_conv);
13058 }
13059
13060 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
13061         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13062         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
13063         return (uintptr_t)ret_conv;
13064 }
13065 intptr_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
13066         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
13067         intptr_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
13068         return ret_val;
13069 }
13070
13071 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
13072         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
13073         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
13074         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
13075         return (uintptr_t)ret_conv;
13076 }
13077
13078 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
13079         LDKCVec_UpdateAddHTLCZ _res_constr;
13080         _res_constr.datalen = _res->arr_len;
13081         if (_res_constr.datalen > 0)
13082                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
13083         else
13084                 _res_constr.data = NULL;
13085         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13086         for (size_t p = 0; p < _res_constr.datalen; p++) {
13087                 uint32_t _res_conv_15 = _res_vals[p];
13088                 LDKUpdateAddHTLC _res_conv_15_conv;
13089                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
13090                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
13091                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
13092                 _res_constr.data[p] = _res_conv_15_conv;
13093         }
13094         CVec_UpdateAddHTLCZ_free(_res_constr);
13095 }
13096
13097 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
13098         LDKCVec_UpdateFulfillHTLCZ _res_constr;
13099         _res_constr.datalen = _res->arr_len;
13100         if (_res_constr.datalen > 0)
13101                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
13102         else
13103                 _res_constr.data = NULL;
13104         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13105         for (size_t t = 0; t < _res_constr.datalen; t++) {
13106                 uint32_t _res_conv_19 = _res_vals[t];
13107                 LDKUpdateFulfillHTLC _res_conv_19_conv;
13108                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
13109                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
13110                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
13111                 _res_constr.data[t] = _res_conv_19_conv;
13112         }
13113         CVec_UpdateFulfillHTLCZ_free(_res_constr);
13114 }
13115
13116 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
13117         LDKCVec_UpdateFailHTLCZ _res_constr;
13118         _res_constr.datalen = _res->arr_len;
13119         if (_res_constr.datalen > 0)
13120                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
13121         else
13122                 _res_constr.data = NULL;
13123         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13124         for (size_t q = 0; q < _res_constr.datalen; q++) {
13125                 uint32_t _res_conv_16 = _res_vals[q];
13126                 LDKUpdateFailHTLC _res_conv_16_conv;
13127                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
13128                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
13129                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
13130                 _res_constr.data[q] = _res_conv_16_conv;
13131         }
13132         CVec_UpdateFailHTLCZ_free(_res_constr);
13133 }
13134
13135 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
13136         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
13137         _res_constr.datalen = _res->arr_len;
13138         if (_res_constr.datalen > 0)
13139                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
13140         else
13141                 _res_constr.data = NULL;
13142         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13143         for (size_t z = 0; z < _res_constr.datalen; z++) {
13144                 uint32_t _res_conv_25 = _res_vals[z];
13145                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
13146                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
13147                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
13148                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
13149                 _res_constr.data[z] = _res_conv_25_conv;
13150         }
13151         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
13152 }
13153
13154 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
13155         LDKAcceptChannel o_conv;
13156         o_conv.inner = (void*)(o & (~1));
13157         o_conv.is_owned = (o & 1) || (o == 0);
13158         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13159         o_conv = AcceptChannel_clone(&o_conv);
13160         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13161         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
13162         return (uintptr_t)ret_conv;
13163 }
13164
13165 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
13166         LDKDecodeError e_conv;
13167         e_conv.inner = (void*)(e & (~1));
13168         e_conv.is_owned = (e & 1) || (e == 0);
13169         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13170         e_conv = DecodeError_clone(&e_conv);
13171         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13172         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
13173         return (uintptr_t)ret_conv;
13174 }
13175
13176 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
13177         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
13178         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
13179         return ret_val;
13180 }
13181
13182 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
13183         if ((_res & 1) != 0) return;
13184         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13185         CHECK_ACCESS(_res_ptr);
13186         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
13187         FREE((void*)_res);
13188         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
13189 }
13190
13191 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
13192         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13193         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
13194         return (uintptr_t)ret_conv;
13195 }
13196 intptr_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
13197         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
13198         intptr_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
13199         return ret_val;
13200 }
13201
13202 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
13203         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
13204         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
13205         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
13206         return (uintptr_t)ret_conv;
13207 }
13208
13209 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
13210         LDKAnnouncementSignatures o_conv;
13211         o_conv.inner = (void*)(o & (~1));
13212         o_conv.is_owned = (o & 1) || (o == 0);
13213         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13214         o_conv = AnnouncementSignatures_clone(&o_conv);
13215         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13216         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
13217         return (uintptr_t)ret_conv;
13218 }
13219
13220 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
13221         LDKDecodeError e_conv;
13222         e_conv.inner = (void*)(e & (~1));
13223         e_conv.is_owned = (e & 1) || (e == 0);
13224         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13225         e_conv = DecodeError_clone(&e_conv);
13226         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13227         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
13228         return (uintptr_t)ret_conv;
13229 }
13230
13231 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
13232         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
13233         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
13234         return ret_val;
13235 }
13236
13237 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
13238         if ((_res & 1) != 0) return;
13239         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13240         CHECK_ACCESS(_res_ptr);
13241         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
13242         FREE((void*)_res);
13243         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
13244 }
13245
13246 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
13247         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13248         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
13249         return (uintptr_t)ret_conv;
13250 }
13251 intptr_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13252         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
13253         intptr_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
13254         return ret_val;
13255 }
13256
13257 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
13258         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
13259         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
13260         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
13261         return (uintptr_t)ret_conv;
13262 }
13263
13264 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
13265         LDKChannelReestablish o_conv;
13266         o_conv.inner = (void*)(o & (~1));
13267         o_conv.is_owned = (o & 1) || (o == 0);
13268         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13269         o_conv = ChannelReestablish_clone(&o_conv);
13270         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13271         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
13272         return (uintptr_t)ret_conv;
13273 }
13274
13275 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
13276         LDKDecodeError e_conv;
13277         e_conv.inner = (void*)(e & (~1));
13278         e_conv.is_owned = (e & 1) || (e == 0);
13279         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13280         e_conv = DecodeError_clone(&e_conv);
13281         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13282         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
13283         return (uintptr_t)ret_conv;
13284 }
13285
13286 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
13287         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
13288         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
13289         return ret_val;
13290 }
13291
13292 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
13293         if ((_res & 1) != 0) return;
13294         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13295         CHECK_ACCESS(_res_ptr);
13296         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
13297         FREE((void*)_res);
13298         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
13299 }
13300
13301 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
13302         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13303         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
13304         return (uintptr_t)ret_conv;
13305 }
13306 intptr_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
13307         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
13308         intptr_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
13309         return ret_val;
13310 }
13311
13312 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
13313         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
13314         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
13315         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
13316         return (uintptr_t)ret_conv;
13317 }
13318
13319 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
13320         LDKClosingSigned o_conv;
13321         o_conv.inner = (void*)(o & (~1));
13322         o_conv.is_owned = (o & 1) || (o == 0);
13323         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13324         o_conv = ClosingSigned_clone(&o_conv);
13325         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13326         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
13327         return (uintptr_t)ret_conv;
13328 }
13329
13330 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
13331         LDKDecodeError e_conv;
13332         e_conv.inner = (void*)(e & (~1));
13333         e_conv.is_owned = (e & 1) || (e == 0);
13334         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13335         e_conv = DecodeError_clone(&e_conv);
13336         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13337         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
13338         return (uintptr_t)ret_conv;
13339 }
13340
13341 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
13342         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
13343         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
13344         return ret_val;
13345 }
13346
13347 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
13348         if ((_res & 1) != 0) return;
13349         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13350         CHECK_ACCESS(_res_ptr);
13351         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
13352         FREE((void*)_res);
13353         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
13354 }
13355
13356 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
13357         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13358         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
13359         return (uintptr_t)ret_conv;
13360 }
13361 intptr_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
13362         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
13363         intptr_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
13364         return ret_val;
13365 }
13366
13367 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
13368         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
13369         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
13370         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
13371         return (uintptr_t)ret_conv;
13372 }
13373
13374 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
13375         LDKClosingSignedFeeRange o_conv;
13376         o_conv.inner = (void*)(o & (~1));
13377         o_conv.is_owned = (o & 1) || (o == 0);
13378         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13379         o_conv = ClosingSignedFeeRange_clone(&o_conv);
13380         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13381         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
13382         return (uintptr_t)ret_conv;
13383 }
13384
13385 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
13386         LDKDecodeError e_conv;
13387         e_conv.inner = (void*)(e & (~1));
13388         e_conv.is_owned = (e & 1) || (e == 0);
13389         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13390         e_conv = DecodeError_clone(&e_conv);
13391         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13392         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
13393         return (uintptr_t)ret_conv;
13394 }
13395
13396 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
13397         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
13398         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
13399         return ret_val;
13400 }
13401
13402 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
13403         if ((_res & 1) != 0) return;
13404         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13405         CHECK_ACCESS(_res_ptr);
13406         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
13407         FREE((void*)_res);
13408         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
13409 }
13410
13411 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
13412         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13413         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
13414         return (uintptr_t)ret_conv;
13415 }
13416 intptr_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
13417         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
13418         intptr_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
13419         return ret_val;
13420 }
13421
13422 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
13423         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
13424         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
13425         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
13426         return (uintptr_t)ret_conv;
13427 }
13428
13429 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
13430         LDKCommitmentSigned o_conv;
13431         o_conv.inner = (void*)(o & (~1));
13432         o_conv.is_owned = (o & 1) || (o == 0);
13433         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13434         o_conv = CommitmentSigned_clone(&o_conv);
13435         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13436         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
13437         return (uintptr_t)ret_conv;
13438 }
13439
13440 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
13441         LDKDecodeError e_conv;
13442         e_conv.inner = (void*)(e & (~1));
13443         e_conv.is_owned = (e & 1) || (e == 0);
13444         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13445         e_conv = DecodeError_clone(&e_conv);
13446         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13447         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
13448         return (uintptr_t)ret_conv;
13449 }
13450
13451 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
13452         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
13453         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
13454         return ret_val;
13455 }
13456
13457 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
13458         if ((_res & 1) != 0) return;
13459         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13460         CHECK_ACCESS(_res_ptr);
13461         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
13462         FREE((void*)_res);
13463         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
13464 }
13465
13466 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
13467         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13468         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
13469         return (uintptr_t)ret_conv;
13470 }
13471 intptr_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
13472         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
13473         intptr_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
13474         return ret_val;
13475 }
13476
13477 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
13478         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
13479         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
13480         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
13481         return (uintptr_t)ret_conv;
13482 }
13483
13484 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
13485         LDKFundingCreated o_conv;
13486         o_conv.inner = (void*)(o & (~1));
13487         o_conv.is_owned = (o & 1) || (o == 0);
13488         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13489         o_conv = FundingCreated_clone(&o_conv);
13490         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13491         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
13492         return (uintptr_t)ret_conv;
13493 }
13494
13495 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
13496         LDKDecodeError e_conv;
13497         e_conv.inner = (void*)(e & (~1));
13498         e_conv.is_owned = (e & 1) || (e == 0);
13499         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13500         e_conv = DecodeError_clone(&e_conv);
13501         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13502         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
13503         return (uintptr_t)ret_conv;
13504 }
13505
13506 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
13507         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
13508         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
13509         return ret_val;
13510 }
13511
13512 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
13513         if ((_res & 1) != 0) return;
13514         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13515         CHECK_ACCESS(_res_ptr);
13516         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
13517         FREE((void*)_res);
13518         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
13519 }
13520
13521 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
13522         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13523         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
13524         return (uintptr_t)ret_conv;
13525 }
13526 intptr_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
13527         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
13528         intptr_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
13529         return ret_val;
13530 }
13531
13532 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
13533         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
13534         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
13535         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
13536         return (uintptr_t)ret_conv;
13537 }
13538
13539 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
13540         LDKFundingSigned o_conv;
13541         o_conv.inner = (void*)(o & (~1));
13542         o_conv.is_owned = (o & 1) || (o == 0);
13543         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13544         o_conv = FundingSigned_clone(&o_conv);
13545         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13546         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
13547         return (uintptr_t)ret_conv;
13548 }
13549
13550 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
13551         LDKDecodeError e_conv;
13552         e_conv.inner = (void*)(e & (~1));
13553         e_conv.is_owned = (e & 1) || (e == 0);
13554         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13555         e_conv = DecodeError_clone(&e_conv);
13556         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13557         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
13558         return (uintptr_t)ret_conv;
13559 }
13560
13561 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
13562         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
13563         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
13564         return ret_val;
13565 }
13566
13567 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
13568         if ((_res & 1) != 0) return;
13569         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13570         CHECK_ACCESS(_res_ptr);
13571         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
13572         FREE((void*)_res);
13573         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
13574 }
13575
13576 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
13577         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13578         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
13579         return (uintptr_t)ret_conv;
13580 }
13581 intptr_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
13582         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
13583         intptr_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
13584         return ret_val;
13585 }
13586
13587 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
13588         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
13589         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
13590         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
13591         return (uintptr_t)ret_conv;
13592 }
13593
13594 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_ok"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
13595         LDKFundingLocked o_conv;
13596         o_conv.inner = (void*)(o & (~1));
13597         o_conv.is_owned = (o & 1) || (o == 0);
13598         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13599         o_conv = FundingLocked_clone(&o_conv);
13600         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13601         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
13602         return (uintptr_t)ret_conv;
13603 }
13604
13605 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_err"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
13606         LDKDecodeError e_conv;
13607         e_conv.inner = (void*)(e & (~1));
13608         e_conv.is_owned = (e & 1) || (e == 0);
13609         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13610         e_conv = DecodeError_clone(&e_conv);
13611         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13612         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
13613         return (uintptr_t)ret_conv;
13614 }
13615
13616 jboolean  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_is_ok"))) TS_CResult_FundingLockedDecodeErrorZ_is_ok(uint32_t o) {
13617         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
13618         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
13619         return ret_val;
13620 }
13621
13622 void  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_free"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
13623         if ((_res & 1) != 0) return;
13624         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13625         CHECK_ACCESS(_res_ptr);
13626         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
13627         FREE((void*)_res);
13628         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
13629 }
13630
13631 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
13632         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13633         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
13634         return (uintptr_t)ret_conv;
13635 }
13636 intptr_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingLockedDecodeErrorZ_clone_ptr(uint32_t arg) {
13637         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
13638         intptr_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
13639         return ret_val;
13640 }
13641
13642 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
13643         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
13644         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
13645         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
13646         return (uintptr_t)ret_conv;
13647 }
13648
13649 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
13650         LDKInit o_conv;
13651         o_conv.inner = (void*)(o & (~1));
13652         o_conv.is_owned = (o & 1) || (o == 0);
13653         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13654         o_conv = Init_clone(&o_conv);
13655         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
13656         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
13657         return (uintptr_t)ret_conv;
13658 }
13659
13660 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
13661         LDKDecodeError e_conv;
13662         e_conv.inner = (void*)(e & (~1));
13663         e_conv.is_owned = (e & 1) || (e == 0);
13664         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13665         e_conv = DecodeError_clone(&e_conv);
13666         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
13667         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
13668         return (uintptr_t)ret_conv;
13669 }
13670
13671 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
13672         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
13673         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
13674         return ret_val;
13675 }
13676
13677 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
13678         if ((_res & 1) != 0) return;
13679         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13680         CHECK_ACCESS(_res_ptr);
13681         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
13682         FREE((void*)_res);
13683         CResult_InitDecodeErrorZ_free(_res_conv);
13684 }
13685
13686 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
13687         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
13688         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
13689         return (uintptr_t)ret_conv;
13690 }
13691 intptr_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
13692         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
13693         intptr_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
13694         return ret_val;
13695 }
13696
13697 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
13698         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
13699         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
13700         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
13701         return (uintptr_t)ret_conv;
13702 }
13703
13704 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
13705         LDKOpenChannel o_conv;
13706         o_conv.inner = (void*)(o & (~1));
13707         o_conv.is_owned = (o & 1) || (o == 0);
13708         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13709         o_conv = OpenChannel_clone(&o_conv);
13710         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
13711         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
13712         return (uintptr_t)ret_conv;
13713 }
13714
13715 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
13716         LDKDecodeError e_conv;
13717         e_conv.inner = (void*)(e & (~1));
13718         e_conv.is_owned = (e & 1) || (e == 0);
13719         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13720         e_conv = DecodeError_clone(&e_conv);
13721         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
13722         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
13723         return (uintptr_t)ret_conv;
13724 }
13725
13726 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
13727         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
13728         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
13729         return ret_val;
13730 }
13731
13732 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
13733         if ((_res & 1) != 0) return;
13734         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13735         CHECK_ACCESS(_res_ptr);
13736         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
13737         FREE((void*)_res);
13738         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
13739 }
13740
13741 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
13742         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
13743         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
13744         return (uintptr_t)ret_conv;
13745 }
13746 intptr_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
13747         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
13748         intptr_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
13749         return ret_val;
13750 }
13751
13752 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
13753         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
13754         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
13755         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
13756         return (uintptr_t)ret_conv;
13757 }
13758
13759 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
13760         LDKRevokeAndACK o_conv;
13761         o_conv.inner = (void*)(o & (~1));
13762         o_conv.is_owned = (o & 1) || (o == 0);
13763         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13764         o_conv = RevokeAndACK_clone(&o_conv);
13765         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
13766         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
13767         return (uintptr_t)ret_conv;
13768 }
13769
13770 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
13771         LDKDecodeError e_conv;
13772         e_conv.inner = (void*)(e & (~1));
13773         e_conv.is_owned = (e & 1) || (e == 0);
13774         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13775         e_conv = DecodeError_clone(&e_conv);
13776         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
13777         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
13778         return (uintptr_t)ret_conv;
13779 }
13780
13781 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
13782         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
13783         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
13784         return ret_val;
13785 }
13786
13787 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
13788         if ((_res & 1) != 0) return;
13789         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13790         CHECK_ACCESS(_res_ptr);
13791         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
13792         FREE((void*)_res);
13793         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
13794 }
13795
13796 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
13797         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
13798         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
13799         return (uintptr_t)ret_conv;
13800 }
13801 intptr_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
13802         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
13803         intptr_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
13804         return ret_val;
13805 }
13806
13807 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
13808         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
13809         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
13810         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
13811         return (uintptr_t)ret_conv;
13812 }
13813
13814 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
13815         LDKShutdown o_conv;
13816         o_conv.inner = (void*)(o & (~1));
13817         o_conv.is_owned = (o & 1) || (o == 0);
13818         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13819         o_conv = Shutdown_clone(&o_conv);
13820         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13821         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
13822         return (uintptr_t)ret_conv;
13823 }
13824
13825 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
13826         LDKDecodeError e_conv;
13827         e_conv.inner = (void*)(e & (~1));
13828         e_conv.is_owned = (e & 1) || (e == 0);
13829         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13830         e_conv = DecodeError_clone(&e_conv);
13831         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13832         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
13833         return (uintptr_t)ret_conv;
13834 }
13835
13836 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
13837         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
13838         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
13839         return ret_val;
13840 }
13841
13842 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
13843         if ((_res & 1) != 0) return;
13844         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13845         CHECK_ACCESS(_res_ptr);
13846         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
13847         FREE((void*)_res);
13848         CResult_ShutdownDecodeErrorZ_free(_res_conv);
13849 }
13850
13851 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
13852         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13853         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
13854         return (uintptr_t)ret_conv;
13855 }
13856 intptr_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
13857         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
13858         intptr_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
13859         return ret_val;
13860 }
13861
13862 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
13863         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
13864         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
13865         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
13866         return (uintptr_t)ret_conv;
13867 }
13868
13869 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
13870         LDKUpdateFailHTLC o_conv;
13871         o_conv.inner = (void*)(o & (~1));
13872         o_conv.is_owned = (o & 1) || (o == 0);
13873         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13874         o_conv = UpdateFailHTLC_clone(&o_conv);
13875         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13876         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
13877         return (uintptr_t)ret_conv;
13878 }
13879
13880 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
13881         LDKDecodeError e_conv;
13882         e_conv.inner = (void*)(e & (~1));
13883         e_conv.is_owned = (e & 1) || (e == 0);
13884         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13885         e_conv = DecodeError_clone(&e_conv);
13886         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13887         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
13888         return (uintptr_t)ret_conv;
13889 }
13890
13891 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
13892         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
13893         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
13894         return ret_val;
13895 }
13896
13897 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
13898         if ((_res & 1) != 0) return;
13899         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13900         CHECK_ACCESS(_res_ptr);
13901         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
13902         FREE((void*)_res);
13903         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
13904 }
13905
13906 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
13907         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13908         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
13909         return (uintptr_t)ret_conv;
13910 }
13911 intptr_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
13912         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
13913         intptr_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
13914         return ret_val;
13915 }
13916
13917 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
13918         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
13919         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
13920         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
13921         return (uintptr_t)ret_conv;
13922 }
13923
13924 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
13925         LDKUpdateFailMalformedHTLC o_conv;
13926         o_conv.inner = (void*)(o & (~1));
13927         o_conv.is_owned = (o & 1) || (o == 0);
13928         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13929         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
13930         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13931         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
13932         return (uintptr_t)ret_conv;
13933 }
13934
13935 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
13936         LDKDecodeError e_conv;
13937         e_conv.inner = (void*)(e & (~1));
13938         e_conv.is_owned = (e & 1) || (e == 0);
13939         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13940         e_conv = DecodeError_clone(&e_conv);
13941         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13942         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
13943         return (uintptr_t)ret_conv;
13944 }
13945
13946 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
13947         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
13948         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
13949         return ret_val;
13950 }
13951
13952 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
13953         if ((_res & 1) != 0) return;
13954         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13955         CHECK_ACCESS(_res_ptr);
13956         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
13957         FREE((void*)_res);
13958         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
13959 }
13960
13961 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
13962         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13963         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
13964         return (uintptr_t)ret_conv;
13965 }
13966 intptr_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
13967         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
13968         intptr_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
13969         return ret_val;
13970 }
13971
13972 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
13973         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
13974         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
13975         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
13976         return (uintptr_t)ret_conv;
13977 }
13978
13979 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
13980         LDKUpdateFee o_conv;
13981         o_conv.inner = (void*)(o & (~1));
13982         o_conv.is_owned = (o & 1) || (o == 0);
13983         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13984         o_conv = UpdateFee_clone(&o_conv);
13985         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
13986         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
13987         return (uintptr_t)ret_conv;
13988 }
13989
13990 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
13991         LDKDecodeError e_conv;
13992         e_conv.inner = (void*)(e & (~1));
13993         e_conv.is_owned = (e & 1) || (e == 0);
13994         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13995         e_conv = DecodeError_clone(&e_conv);
13996         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
13997         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
13998         return (uintptr_t)ret_conv;
13999 }
14000
14001 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
14002         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
14003         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
14004         return ret_val;
14005 }
14006
14007 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
14008         if ((_res & 1) != 0) return;
14009         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14010         CHECK_ACCESS(_res_ptr);
14011         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
14012         FREE((void*)_res);
14013         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
14014 }
14015
14016 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
14017         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14018         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
14019         return (uintptr_t)ret_conv;
14020 }
14021 intptr_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
14022         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
14023         intptr_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
14024         return ret_val;
14025 }
14026
14027 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
14028         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
14029         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
14030         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
14031         return (uintptr_t)ret_conv;
14032 }
14033
14034 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
14035         LDKUpdateFulfillHTLC o_conv;
14036         o_conv.inner = (void*)(o & (~1));
14037         o_conv.is_owned = (o & 1) || (o == 0);
14038         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14039         o_conv = UpdateFulfillHTLC_clone(&o_conv);
14040         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14041         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
14042         return (uintptr_t)ret_conv;
14043 }
14044
14045 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
14046         LDKDecodeError e_conv;
14047         e_conv.inner = (void*)(e & (~1));
14048         e_conv.is_owned = (e & 1) || (e == 0);
14049         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14050         e_conv = DecodeError_clone(&e_conv);
14051         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14052         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
14053         return (uintptr_t)ret_conv;
14054 }
14055
14056 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
14057         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
14058         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
14059         return ret_val;
14060 }
14061
14062 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
14063         if ((_res & 1) != 0) return;
14064         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14065         CHECK_ACCESS(_res_ptr);
14066         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
14067         FREE((void*)_res);
14068         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
14069 }
14070
14071 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
14072         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14073         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
14074         return (uintptr_t)ret_conv;
14075 }
14076 intptr_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
14077         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
14078         intptr_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
14079         return ret_val;
14080 }
14081
14082 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
14083         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
14084         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
14085         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
14086         return (uintptr_t)ret_conv;
14087 }
14088
14089 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
14090         LDKUpdateAddHTLC o_conv;
14091         o_conv.inner = (void*)(o & (~1));
14092         o_conv.is_owned = (o & 1) || (o == 0);
14093         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14094         o_conv = UpdateAddHTLC_clone(&o_conv);
14095         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14096         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
14097         return (uintptr_t)ret_conv;
14098 }
14099
14100 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
14101         LDKDecodeError e_conv;
14102         e_conv.inner = (void*)(e & (~1));
14103         e_conv.is_owned = (e & 1) || (e == 0);
14104         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14105         e_conv = DecodeError_clone(&e_conv);
14106         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14107         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
14108         return (uintptr_t)ret_conv;
14109 }
14110
14111 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
14112         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
14113         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
14114         return ret_val;
14115 }
14116
14117 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
14118         if ((_res & 1) != 0) return;
14119         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14120         CHECK_ACCESS(_res_ptr);
14121         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
14122         FREE((void*)_res);
14123         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
14124 }
14125
14126 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
14127         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14128         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
14129         return (uintptr_t)ret_conv;
14130 }
14131 intptr_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
14132         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
14133         intptr_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
14134         return ret_val;
14135 }
14136
14137 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
14138         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
14139         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
14140         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
14141         return (uintptr_t)ret_conv;
14142 }
14143
14144 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
14145         LDKPing o_conv;
14146         o_conv.inner = (void*)(o & (~1));
14147         o_conv.is_owned = (o & 1) || (o == 0);
14148         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14149         o_conv = Ping_clone(&o_conv);
14150         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14151         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
14152         return (uintptr_t)ret_conv;
14153 }
14154
14155 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
14156         LDKDecodeError e_conv;
14157         e_conv.inner = (void*)(e & (~1));
14158         e_conv.is_owned = (e & 1) || (e == 0);
14159         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14160         e_conv = DecodeError_clone(&e_conv);
14161         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14162         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
14163         return (uintptr_t)ret_conv;
14164 }
14165
14166 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
14167         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
14168         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
14169         return ret_val;
14170 }
14171
14172 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
14173         if ((_res & 1) != 0) return;
14174         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14175         CHECK_ACCESS(_res_ptr);
14176         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
14177         FREE((void*)_res);
14178         CResult_PingDecodeErrorZ_free(_res_conv);
14179 }
14180
14181 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
14182         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14183         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
14184         return (uintptr_t)ret_conv;
14185 }
14186 intptr_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
14187         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
14188         intptr_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
14189         return ret_val;
14190 }
14191
14192 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
14193         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
14194         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
14195         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
14196         return (uintptr_t)ret_conv;
14197 }
14198
14199 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
14200         LDKPong o_conv;
14201         o_conv.inner = (void*)(o & (~1));
14202         o_conv.is_owned = (o & 1) || (o == 0);
14203         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14204         o_conv = Pong_clone(&o_conv);
14205         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14206         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
14207         return (uintptr_t)ret_conv;
14208 }
14209
14210 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
14211         LDKDecodeError e_conv;
14212         e_conv.inner = (void*)(e & (~1));
14213         e_conv.is_owned = (e & 1) || (e == 0);
14214         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14215         e_conv = DecodeError_clone(&e_conv);
14216         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14217         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
14218         return (uintptr_t)ret_conv;
14219 }
14220
14221 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
14222         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
14223         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
14224         return ret_val;
14225 }
14226
14227 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
14228         if ((_res & 1) != 0) return;
14229         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14230         CHECK_ACCESS(_res_ptr);
14231         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
14232         FREE((void*)_res);
14233         CResult_PongDecodeErrorZ_free(_res_conv);
14234 }
14235
14236 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
14237         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14238         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
14239         return (uintptr_t)ret_conv;
14240 }
14241 intptr_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
14242         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
14243         intptr_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
14244         return ret_val;
14245 }
14246
14247 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
14248         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
14249         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
14250         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
14251         return (uintptr_t)ret_conv;
14252 }
14253
14254 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
14255         LDKUnsignedChannelAnnouncement o_conv;
14256         o_conv.inner = (void*)(o & (~1));
14257         o_conv.is_owned = (o & 1) || (o == 0);
14258         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14259         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
14260         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14261         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
14262         return (uintptr_t)ret_conv;
14263 }
14264
14265 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
14266         LDKDecodeError e_conv;
14267         e_conv.inner = (void*)(e & (~1));
14268         e_conv.is_owned = (e & 1) || (e == 0);
14269         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14270         e_conv = DecodeError_clone(&e_conv);
14271         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14272         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
14273         return (uintptr_t)ret_conv;
14274 }
14275
14276 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
14277         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
14278         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
14279         return ret_val;
14280 }
14281
14282 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
14283         if ((_res & 1) != 0) return;
14284         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14285         CHECK_ACCESS(_res_ptr);
14286         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
14287         FREE((void*)_res);
14288         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
14289 }
14290
14291 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
14292         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14293         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
14294         return (uintptr_t)ret_conv;
14295 }
14296 intptr_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
14297         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
14298         intptr_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
14299         return ret_val;
14300 }
14301
14302 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
14303         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
14304         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
14305         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
14306         return (uintptr_t)ret_conv;
14307 }
14308
14309 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
14310         LDKChannelAnnouncement o_conv;
14311         o_conv.inner = (void*)(o & (~1));
14312         o_conv.is_owned = (o & 1) || (o == 0);
14313         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14314         o_conv = ChannelAnnouncement_clone(&o_conv);
14315         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14316         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
14317         return (uintptr_t)ret_conv;
14318 }
14319
14320 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
14321         LDKDecodeError e_conv;
14322         e_conv.inner = (void*)(e & (~1));
14323         e_conv.is_owned = (e & 1) || (e == 0);
14324         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14325         e_conv = DecodeError_clone(&e_conv);
14326         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14327         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
14328         return (uintptr_t)ret_conv;
14329 }
14330
14331 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
14332         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
14333         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
14334         return ret_val;
14335 }
14336
14337 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
14338         if ((_res & 1) != 0) return;
14339         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14340         CHECK_ACCESS(_res_ptr);
14341         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
14342         FREE((void*)_res);
14343         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
14344 }
14345
14346 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
14347         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14348         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
14349         return (uintptr_t)ret_conv;
14350 }
14351 intptr_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
14352         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
14353         intptr_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
14354         return ret_val;
14355 }
14356
14357 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
14358         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
14359         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
14360         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
14361         return (uintptr_t)ret_conv;
14362 }
14363
14364 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
14365         LDKUnsignedChannelUpdate o_conv;
14366         o_conv.inner = (void*)(o & (~1));
14367         o_conv.is_owned = (o & 1) || (o == 0);
14368         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14369         o_conv = UnsignedChannelUpdate_clone(&o_conv);
14370         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14371         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
14372         return (uintptr_t)ret_conv;
14373 }
14374
14375 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
14376         LDKDecodeError e_conv;
14377         e_conv.inner = (void*)(e & (~1));
14378         e_conv.is_owned = (e & 1) || (e == 0);
14379         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14380         e_conv = DecodeError_clone(&e_conv);
14381         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14382         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
14383         return (uintptr_t)ret_conv;
14384 }
14385
14386 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
14387         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
14388         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
14389         return ret_val;
14390 }
14391
14392 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
14393         if ((_res & 1) != 0) return;
14394         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14395         CHECK_ACCESS(_res_ptr);
14396         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
14397         FREE((void*)_res);
14398         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
14399 }
14400
14401 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
14402         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14403         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
14404         return (uintptr_t)ret_conv;
14405 }
14406 intptr_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
14407         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
14408         intptr_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
14409         return ret_val;
14410 }
14411
14412 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
14413         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
14414         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
14415         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
14416         return (uintptr_t)ret_conv;
14417 }
14418
14419 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
14420         LDKChannelUpdate o_conv;
14421         o_conv.inner = (void*)(o & (~1));
14422         o_conv.is_owned = (o & 1) || (o == 0);
14423         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14424         o_conv = ChannelUpdate_clone(&o_conv);
14425         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14426         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
14427         return (uintptr_t)ret_conv;
14428 }
14429
14430 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
14431         LDKDecodeError e_conv;
14432         e_conv.inner = (void*)(e & (~1));
14433         e_conv.is_owned = (e & 1) || (e == 0);
14434         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14435         e_conv = DecodeError_clone(&e_conv);
14436         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14437         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
14438         return (uintptr_t)ret_conv;
14439 }
14440
14441 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
14442         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
14443         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
14444         return ret_val;
14445 }
14446
14447 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
14448         if ((_res & 1) != 0) return;
14449         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14450         CHECK_ACCESS(_res_ptr);
14451         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
14452         FREE((void*)_res);
14453         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
14454 }
14455
14456 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
14457         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14458         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
14459         return (uintptr_t)ret_conv;
14460 }
14461 intptr_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
14462         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
14463         intptr_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
14464         return ret_val;
14465 }
14466
14467 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
14468         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
14469         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
14470         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
14471         return (uintptr_t)ret_conv;
14472 }
14473
14474 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
14475         LDKErrorMessage o_conv;
14476         o_conv.inner = (void*)(o & (~1));
14477         o_conv.is_owned = (o & 1) || (o == 0);
14478         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14479         o_conv = ErrorMessage_clone(&o_conv);
14480         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14481         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
14482         return (uintptr_t)ret_conv;
14483 }
14484
14485 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
14486         LDKDecodeError e_conv;
14487         e_conv.inner = (void*)(e & (~1));
14488         e_conv.is_owned = (e & 1) || (e == 0);
14489         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14490         e_conv = DecodeError_clone(&e_conv);
14491         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14492         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
14493         return (uintptr_t)ret_conv;
14494 }
14495
14496 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
14497         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
14498         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
14499         return ret_val;
14500 }
14501
14502 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
14503         if ((_res & 1) != 0) return;
14504         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14505         CHECK_ACCESS(_res_ptr);
14506         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
14507         FREE((void*)_res);
14508         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
14509 }
14510
14511 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
14512         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14513         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
14514         return (uintptr_t)ret_conv;
14515 }
14516 intptr_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
14517         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
14518         intptr_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
14519         return ret_val;
14520 }
14521
14522 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
14523         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
14524         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
14525         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
14526         return (uintptr_t)ret_conv;
14527 }
14528
14529 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
14530         LDKUnsignedNodeAnnouncement o_conv;
14531         o_conv.inner = (void*)(o & (~1));
14532         o_conv.is_owned = (o & 1) || (o == 0);
14533         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14534         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
14535         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14536         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
14537         return (uintptr_t)ret_conv;
14538 }
14539
14540 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
14541         LDKDecodeError e_conv;
14542         e_conv.inner = (void*)(e & (~1));
14543         e_conv.is_owned = (e & 1) || (e == 0);
14544         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14545         e_conv = DecodeError_clone(&e_conv);
14546         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14547         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
14548         return (uintptr_t)ret_conv;
14549 }
14550
14551 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
14552         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
14553         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
14554         return ret_val;
14555 }
14556
14557 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
14558         if ((_res & 1) != 0) return;
14559         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14560         CHECK_ACCESS(_res_ptr);
14561         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
14562         FREE((void*)_res);
14563         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
14564 }
14565
14566 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
14567         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14568         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
14569         return (uintptr_t)ret_conv;
14570 }
14571 intptr_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
14572         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
14573         intptr_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
14574         return ret_val;
14575 }
14576
14577 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
14578         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
14579         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
14580         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
14581         return (uintptr_t)ret_conv;
14582 }
14583
14584 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
14585         LDKNodeAnnouncement o_conv;
14586         o_conv.inner = (void*)(o & (~1));
14587         o_conv.is_owned = (o & 1) || (o == 0);
14588         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14589         o_conv = NodeAnnouncement_clone(&o_conv);
14590         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14591         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
14592         return (uintptr_t)ret_conv;
14593 }
14594
14595 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
14596         LDKDecodeError e_conv;
14597         e_conv.inner = (void*)(e & (~1));
14598         e_conv.is_owned = (e & 1) || (e == 0);
14599         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14600         e_conv = DecodeError_clone(&e_conv);
14601         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14602         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
14603         return (uintptr_t)ret_conv;
14604 }
14605
14606 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
14607         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
14608         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
14609         return ret_val;
14610 }
14611
14612 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
14613         if ((_res & 1) != 0) return;
14614         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14615         CHECK_ACCESS(_res_ptr);
14616         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
14617         FREE((void*)_res);
14618         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
14619 }
14620
14621 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
14622         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14623         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
14624         return (uintptr_t)ret_conv;
14625 }
14626 intptr_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
14627         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
14628         intptr_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
14629         return ret_val;
14630 }
14631
14632 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
14633         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
14634         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
14635         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
14636         return (uintptr_t)ret_conv;
14637 }
14638
14639 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
14640         LDKQueryShortChannelIds o_conv;
14641         o_conv.inner = (void*)(o & (~1));
14642         o_conv.is_owned = (o & 1) || (o == 0);
14643         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14644         o_conv = QueryShortChannelIds_clone(&o_conv);
14645         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14646         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
14647         return (uintptr_t)ret_conv;
14648 }
14649
14650 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
14651         LDKDecodeError e_conv;
14652         e_conv.inner = (void*)(e & (~1));
14653         e_conv.is_owned = (e & 1) || (e == 0);
14654         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14655         e_conv = DecodeError_clone(&e_conv);
14656         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14657         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
14658         return (uintptr_t)ret_conv;
14659 }
14660
14661 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
14662         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
14663         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
14664         return ret_val;
14665 }
14666
14667 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
14668         if ((_res & 1) != 0) return;
14669         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14670         CHECK_ACCESS(_res_ptr);
14671         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
14672         FREE((void*)_res);
14673         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
14674 }
14675
14676 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
14677         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14678         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
14679         return (uintptr_t)ret_conv;
14680 }
14681 intptr_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
14682         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
14683         intptr_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
14684         return ret_val;
14685 }
14686
14687 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
14688         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
14689         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
14690         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
14691         return (uintptr_t)ret_conv;
14692 }
14693
14694 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
14695         LDKReplyShortChannelIdsEnd o_conv;
14696         o_conv.inner = (void*)(o & (~1));
14697         o_conv.is_owned = (o & 1) || (o == 0);
14698         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14699         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
14700         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14701         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
14702         return (uintptr_t)ret_conv;
14703 }
14704
14705 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
14706         LDKDecodeError e_conv;
14707         e_conv.inner = (void*)(e & (~1));
14708         e_conv.is_owned = (e & 1) || (e == 0);
14709         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14710         e_conv = DecodeError_clone(&e_conv);
14711         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14712         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
14713         return (uintptr_t)ret_conv;
14714 }
14715
14716 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
14717         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
14718         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
14719         return ret_val;
14720 }
14721
14722 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
14723         if ((_res & 1) != 0) return;
14724         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14725         CHECK_ACCESS(_res_ptr);
14726         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
14727         FREE((void*)_res);
14728         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
14729 }
14730
14731 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
14732         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14733         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
14734         return (uintptr_t)ret_conv;
14735 }
14736 intptr_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
14737         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
14738         intptr_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
14739         return ret_val;
14740 }
14741
14742 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
14743         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
14744         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
14745         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
14746         return (uintptr_t)ret_conv;
14747 }
14748
14749 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
14750         LDKQueryChannelRange o_conv;
14751         o_conv.inner = (void*)(o & (~1));
14752         o_conv.is_owned = (o & 1) || (o == 0);
14753         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14754         o_conv = QueryChannelRange_clone(&o_conv);
14755         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14756         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
14757         return (uintptr_t)ret_conv;
14758 }
14759
14760 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
14761         LDKDecodeError e_conv;
14762         e_conv.inner = (void*)(e & (~1));
14763         e_conv.is_owned = (e & 1) || (e == 0);
14764         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14765         e_conv = DecodeError_clone(&e_conv);
14766         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14767         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
14768         return (uintptr_t)ret_conv;
14769 }
14770
14771 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
14772         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
14773         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
14774         return ret_val;
14775 }
14776
14777 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
14778         if ((_res & 1) != 0) return;
14779         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14780         CHECK_ACCESS(_res_ptr);
14781         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
14782         FREE((void*)_res);
14783         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
14784 }
14785
14786 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
14787         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14788         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
14789         return (uintptr_t)ret_conv;
14790 }
14791 intptr_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
14792         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
14793         intptr_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
14794         return ret_val;
14795 }
14796
14797 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
14798         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
14799         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
14800         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
14801         return (uintptr_t)ret_conv;
14802 }
14803
14804 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
14805         LDKReplyChannelRange o_conv;
14806         o_conv.inner = (void*)(o & (~1));
14807         o_conv.is_owned = (o & 1) || (o == 0);
14808         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14809         o_conv = ReplyChannelRange_clone(&o_conv);
14810         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14811         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
14812         return (uintptr_t)ret_conv;
14813 }
14814
14815 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
14816         LDKDecodeError e_conv;
14817         e_conv.inner = (void*)(e & (~1));
14818         e_conv.is_owned = (e & 1) || (e == 0);
14819         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14820         e_conv = DecodeError_clone(&e_conv);
14821         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14822         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
14823         return (uintptr_t)ret_conv;
14824 }
14825
14826 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
14827         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
14828         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
14829         return ret_val;
14830 }
14831
14832 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
14833         if ((_res & 1) != 0) return;
14834         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14835         CHECK_ACCESS(_res_ptr);
14836         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
14837         FREE((void*)_res);
14838         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
14839 }
14840
14841 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
14842         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14843         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
14844         return (uintptr_t)ret_conv;
14845 }
14846 intptr_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
14847         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
14848         intptr_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
14849         return ret_val;
14850 }
14851
14852 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
14853         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
14854         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
14855         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
14856         return (uintptr_t)ret_conv;
14857 }
14858
14859 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
14860         LDKGossipTimestampFilter o_conv;
14861         o_conv.inner = (void*)(o & (~1));
14862         o_conv.is_owned = (o & 1) || (o == 0);
14863         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14864         o_conv = GossipTimestampFilter_clone(&o_conv);
14865         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14866         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
14867         return (uintptr_t)ret_conv;
14868 }
14869
14870 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
14871         LDKDecodeError e_conv;
14872         e_conv.inner = (void*)(e & (~1));
14873         e_conv.is_owned = (e & 1) || (e == 0);
14874         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14875         e_conv = DecodeError_clone(&e_conv);
14876         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14877         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
14878         return (uintptr_t)ret_conv;
14879 }
14880
14881 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
14882         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
14883         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
14884         return ret_val;
14885 }
14886
14887 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
14888         if ((_res & 1) != 0) return;
14889         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14890         CHECK_ACCESS(_res_ptr);
14891         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
14892         FREE((void*)_res);
14893         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
14894 }
14895
14896 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
14897         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14898         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
14899         return (uintptr_t)ret_conv;
14900 }
14901 intptr_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
14902         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
14903         intptr_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
14904         return ret_val;
14905 }
14906
14907 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
14908         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
14909         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
14910         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
14911         return (uintptr_t)ret_conv;
14912 }
14913
14914 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14915         LDKDelayedPaymentOutputDescriptor o_conv;
14916         o_conv.inner = (void*)(o & (~1));
14917         o_conv.is_owned = (o & 1) || (o == 0);
14918         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14919         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
14920         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14921         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14922         return (uintptr_t)ret_conv;
14923 }
14924
14925 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14926         LDKDecodeError e_conv;
14927         e_conv.inner = (void*)(e & (~1));
14928         e_conv.is_owned = (e & 1) || (e == 0);
14929         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14930         e_conv = DecodeError_clone(&e_conv);
14931         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14932         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14933         return (uintptr_t)ret_conv;
14934 }
14935
14936 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14937         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14938         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14939         return ret_val;
14940 }
14941
14942 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14943         if ((_res & 1) != 0) return;
14944         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14945         CHECK_ACCESS(_res_ptr);
14946         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14947         FREE((void*)_res);
14948         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14949 }
14950
14951 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14952         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14953         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14954         return (uintptr_t)ret_conv;
14955 }
14956 intptr_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14957         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
14958         intptr_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14959         return ret_val;
14960 }
14961
14962 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
14963         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
14964         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14965         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
14966         return (uintptr_t)ret_conv;
14967 }
14968
14969 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14970         LDKStaticPaymentOutputDescriptor o_conv;
14971         o_conv.inner = (void*)(o & (~1));
14972         o_conv.is_owned = (o & 1) || (o == 0);
14973         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14974         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
14975         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14976         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14977         return (uintptr_t)ret_conv;
14978 }
14979
14980 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14981         LDKDecodeError e_conv;
14982         e_conv.inner = (void*)(e & (~1));
14983         e_conv.is_owned = (e & 1) || (e == 0);
14984         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14985         e_conv = DecodeError_clone(&e_conv);
14986         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14987         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14988         return (uintptr_t)ret_conv;
14989 }
14990
14991 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14992         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14993         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14994         return ret_val;
14995 }
14996
14997 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14998         if ((_res & 1) != 0) return;
14999         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15000         CHECK_ACCESS(_res_ptr);
15001         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
15002         FREE((void*)_res);
15003         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
15004 }
15005
15006 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15007         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15008         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
15009         return (uintptr_t)ret_conv;
15010 }
15011 intptr_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
15012         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
15013         intptr_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15014         return ret_val;
15015 }
15016
15017 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15018         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
15019         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
15020         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
15021         return (uintptr_t)ret_conv;
15022 }
15023
15024 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
15025         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15026         CHECK_ACCESS(o_ptr);
15027         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
15028         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
15029         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15030         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
15031         return (uintptr_t)ret_conv;
15032 }
15033
15034 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
15035         LDKDecodeError e_conv;
15036         e_conv.inner = (void*)(e & (~1));
15037         e_conv.is_owned = (e & 1) || (e == 0);
15038         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15039         e_conv = DecodeError_clone(&e_conv);
15040         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15041         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
15042         return (uintptr_t)ret_conv;
15043 }
15044
15045 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
15046         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
15047         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
15048         return ret_val;
15049 }
15050
15051 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
15052         if ((_res & 1) != 0) return;
15053         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15054         CHECK_ACCESS(_res_ptr);
15055         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
15056         FREE((void*)_res);
15057         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
15058 }
15059
15060 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
15061         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15062         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
15063         return (uintptr_t)ret_conv;
15064 }
15065 intptr_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
15066         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
15067         intptr_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
15068         return ret_val;
15069 }
15070
15071 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
15072         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
15073         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
15074         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
15075         return (uintptr_t)ret_conv;
15076 }
15077
15078 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
15079         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15080         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
15081         return ((uintptr_t)ret_conv);
15082 }
15083 intptr_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
15084         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
15085         intptr_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
15086         return ret_val;
15087 }
15088
15089 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
15090         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
15091         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15092         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
15093         return ((uintptr_t)ret_conv);
15094 }
15095
15096 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
15097         LDKSignature a_ref;
15098         CHECK(a->arr_len == 64);
15099         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
15100         LDKCVec_SignatureZ b_constr;
15101         b_constr.datalen = b->arr_len;
15102         if (b_constr.datalen > 0)
15103                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15104         else
15105                 b_constr.data = NULL;
15106         int8_tArray* b_vals = (void*) b->elems /* XXX b leaks */;
15107         for (size_t m = 0; m < b_constr.datalen; m++) {
15108                 int8_tArray b_conv_12 = b_vals[m];
15109                 LDKSignature b_conv_12_ref;
15110                 CHECK(b_conv_12->arr_len == 64);
15111                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
15112                 b_constr.data[m] = b_conv_12_ref;
15113         }
15114         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
15115         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
15116         return ((uintptr_t)ret_conv);
15117 }
15118
15119 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
15120         if ((_res & 1) != 0) return;
15121         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15122         CHECK_ACCESS(_res_ptr);
15123         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
15124         FREE((void*)_res);
15125         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
15126 }
15127
15128 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
15129         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15130         CHECK_ACCESS(o_ptr);
15131         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
15132         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
15133         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15134         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
15135         return (uintptr_t)ret_conv;
15136 }
15137
15138 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
15139         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15140         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
15141         return (uintptr_t)ret_conv;
15142 }
15143
15144 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
15145         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
15146         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
15147         return ret_val;
15148 }
15149
15150 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
15151         if ((_res & 1) != 0) return;
15152         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15153         CHECK_ACCESS(_res_ptr);
15154         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
15155         FREE((void*)_res);
15156         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
15157 }
15158
15159 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
15160         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15161         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
15162         return (uintptr_t)ret_conv;
15163 }
15164 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
15165         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
15166         intptr_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
15167         return ret_val;
15168 }
15169
15170 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
15171         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
15172         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
15173         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
15174         return (uintptr_t)ret_conv;
15175 }
15176
15177 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
15178         LDKSignature o_ref;
15179         CHECK(o->arr_len == 64);
15180         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
15181         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15182         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
15183         return (uintptr_t)ret_conv;
15184 }
15185
15186 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
15187         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15188         *ret_conv = CResult_SignatureNoneZ_err();
15189         return (uintptr_t)ret_conv;
15190 }
15191
15192 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
15193         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
15194         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
15195         return ret_val;
15196 }
15197
15198 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
15199         if ((_res & 1) != 0) return;
15200         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15201         CHECK_ACCESS(_res_ptr);
15202         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
15203         FREE((void*)_res);
15204         CResult_SignatureNoneZ_free(_res_conv);
15205 }
15206
15207 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
15208         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15209         *ret_conv = CResult_SignatureNoneZ_clone(arg);
15210         return (uintptr_t)ret_conv;
15211 }
15212 intptr_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
15213         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
15214         intptr_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
15215         return ret_val;
15216 }
15217
15218 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
15219         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
15220         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
15221         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
15222         return (uintptr_t)ret_conv;
15223 }
15224
15225 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
15226         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15227         CHECK_ACCESS(o_ptr);
15228         LDKSign o_conv = *(LDKSign*)(o_ptr);
15229         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15230         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
15231         return (uintptr_t)ret_conv;
15232 }
15233
15234 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
15235         LDKDecodeError e_conv;
15236         e_conv.inner = (void*)(e & (~1));
15237         e_conv.is_owned = (e & 1) || (e == 0);
15238         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15239         e_conv = DecodeError_clone(&e_conv);
15240         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15241         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
15242         return (uintptr_t)ret_conv;
15243 }
15244
15245 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
15246         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
15247         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
15248         return ret_val;
15249 }
15250
15251 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
15252         if ((_res & 1) != 0) return;
15253         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15254         CHECK_ACCESS(_res_ptr);
15255         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
15256         FREE((void*)_res);
15257         CResult_SignDecodeErrorZ_free(_res_conv);
15258 }
15259
15260 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
15261         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15262         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
15263         return (uintptr_t)ret_conv;
15264 }
15265 intptr_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
15266         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
15267         intptr_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
15268         return ret_val;
15269 }
15270
15271 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
15272         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
15273         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
15274         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
15275         return (uintptr_t)ret_conv;
15276 }
15277
15278 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
15279         LDKRecoverableSignature o_ref;
15280         CHECK(o->arr_len == 68);
15281         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
15282         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15283         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
15284         return (uintptr_t)ret_conv;
15285 }
15286
15287 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
15288         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15289         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
15290         return (uintptr_t)ret_conv;
15291 }
15292
15293 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
15294         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
15295         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
15296         return ret_val;
15297 }
15298
15299 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
15300         if ((_res & 1) != 0) return;
15301         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15302         CHECK_ACCESS(_res_ptr);
15303         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
15304         FREE((void*)_res);
15305         CResult_RecoverableSignatureNoneZ_free(_res_conv);
15306 }
15307
15308 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
15309         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15310         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
15311         return (uintptr_t)ret_conv;
15312 }
15313 intptr_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
15314         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
15315         intptr_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
15316         return ret_val;
15317 }
15318
15319 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
15320         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
15321         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
15322         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
15323         return (uintptr_t)ret_conv;
15324 }
15325
15326 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
15327         LDKCVec_CVec_u8ZZ _res_constr;
15328         _res_constr.datalen = _res->arr_len;
15329         if (_res_constr.datalen > 0)
15330                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15331         else
15332                 _res_constr.data = NULL;
15333         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
15334         for (size_t m = 0; m < _res_constr.datalen; m++) {
15335                 int8_tArray _res_conv_12 = _res_vals[m];
15336                 LDKCVec_u8Z _res_conv_12_ref;
15337                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
15338                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15339                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
15340                 _res_constr.data[m] = _res_conv_12_ref;
15341         }
15342         CVec_CVec_u8ZZ_free(_res_constr);
15343 }
15344
15345 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
15346         LDKCVec_CVec_u8ZZ o_constr;
15347         o_constr.datalen = o->arr_len;
15348         if (o_constr.datalen > 0)
15349                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
15350         else
15351                 o_constr.data = NULL;
15352         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
15353         for (size_t m = 0; m < o_constr.datalen; m++) {
15354                 int8_tArray o_conv_12 = o_vals[m];
15355                 LDKCVec_u8Z o_conv_12_ref;
15356                 o_conv_12_ref.datalen = o_conv_12->arr_len;
15357                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
15358                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
15359                 o_constr.data[m] = o_conv_12_ref;
15360         }
15361         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15362         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
15363         return (uintptr_t)ret_conv;
15364 }
15365
15366 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
15367         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15368         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
15369         return (uintptr_t)ret_conv;
15370 }
15371
15372 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
15373         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
15374         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
15375         return ret_val;
15376 }
15377
15378 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
15379         if ((_res & 1) != 0) return;
15380         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15381         CHECK_ACCESS(_res_ptr);
15382         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
15383         FREE((void*)_res);
15384         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
15385 }
15386
15387 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
15388         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15389         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
15390         return (uintptr_t)ret_conv;
15391 }
15392 intptr_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
15393         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
15394         intptr_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
15395         return ret_val;
15396 }
15397
15398 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
15399         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
15400         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
15401         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
15402         return (uintptr_t)ret_conv;
15403 }
15404
15405 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
15406         LDKInMemorySigner o_conv;
15407         o_conv.inner = (void*)(o & (~1));
15408         o_conv.is_owned = (o & 1) || (o == 0);
15409         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15410         o_conv = InMemorySigner_clone(&o_conv);
15411         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15412         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
15413         return (uintptr_t)ret_conv;
15414 }
15415
15416 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
15417         LDKDecodeError e_conv;
15418         e_conv.inner = (void*)(e & (~1));
15419         e_conv.is_owned = (e & 1) || (e == 0);
15420         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15421         e_conv = DecodeError_clone(&e_conv);
15422         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15423         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
15424         return (uintptr_t)ret_conv;
15425 }
15426
15427 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
15428         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
15429         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
15430         return ret_val;
15431 }
15432
15433 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
15434         if ((_res & 1) != 0) return;
15435         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15436         CHECK_ACCESS(_res_ptr);
15437         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
15438         FREE((void*)_res);
15439         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
15440 }
15441
15442 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
15443         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15444         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
15445         return (uintptr_t)ret_conv;
15446 }
15447 intptr_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
15448         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
15449         intptr_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
15450         return ret_val;
15451 }
15452
15453 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
15454         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
15455         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
15456         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
15457         return (uintptr_t)ret_conv;
15458 }
15459
15460 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
15461         LDKCVec_TxOutZ _res_constr;
15462         _res_constr.datalen = _res->arr_len;
15463         if (_res_constr.datalen > 0)
15464                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15465         else
15466                 _res_constr.data = NULL;
15467         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15468         for (size_t h = 0; h < _res_constr.datalen; h++) {
15469                 uint32_t _res_conv_7 = _res_vals[h];
15470                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
15471                 CHECK_ACCESS(_res_conv_7_ptr);
15472                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
15473                 FREE((void*)_res_conv_7);
15474                 _res_constr.data[h] = _res_conv_7_conv;
15475         }
15476         CVec_TxOutZ_free(_res_constr);
15477 }
15478
15479 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
15480         LDKTransaction o_ref;
15481         o_ref.datalen = o->arr_len;
15482         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
15483         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
15484         o_ref.data_is_owned = true;
15485         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15486         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
15487         return (uintptr_t)ret_conv;
15488 }
15489
15490 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
15491         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15492         *ret_conv = CResult_TransactionNoneZ_err();
15493         return (uintptr_t)ret_conv;
15494 }
15495
15496 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
15497         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
15498         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
15499         return ret_val;
15500 }
15501
15502 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
15503         if ((_res & 1) != 0) return;
15504         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15505         CHECK_ACCESS(_res_ptr);
15506         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
15507         FREE((void*)_res);
15508         CResult_TransactionNoneZ_free(_res_conv);
15509 }
15510
15511 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
15512         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15513         *ret_conv = CResult_TransactionNoneZ_clone(arg);
15514         return (uintptr_t)ret_conv;
15515 }
15516 intptr_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
15517         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
15518         intptr_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
15519         return ret_val;
15520 }
15521
15522 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
15523         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
15524         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15525         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
15526         return (uintptr_t)ret_conv;
15527 }
15528
15529 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
15530         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15531         CHECK_ACCESS(o_ptr);
15532         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
15533         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
15534         *ret_copy = COption_FilterZ_some(o_conv);
15535         uintptr_t ret_ref = (uintptr_t)ret_copy;
15536         return ret_ref;
15537 }
15538
15539 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
15540         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
15541         *ret_copy = COption_FilterZ_none();
15542         uintptr_t ret_ref = (uintptr_t)ret_copy;
15543         return ret_ref;
15544 }
15545
15546 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
15547         if ((_res & 1) != 0) return;
15548         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15549         CHECK_ACCESS(_res_ptr);
15550         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
15551         FREE((void*)_res);
15552         COption_FilterZ_free(_res_conv);
15553 }
15554
15555 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
15556         LDKLockedChannelMonitor o_conv;
15557         o_conv.inner = (void*)(o & (~1));
15558         o_conv.is_owned = (o & 1) || (o == 0);
15559         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15560         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
15561         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
15562         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
15563         return (uintptr_t)ret_conv;
15564 }
15565
15566 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
15567         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
15568         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
15569         return (uintptr_t)ret_conv;
15570 }
15571
15572 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
15573         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
15574         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
15575         return ret_val;
15576 }
15577
15578 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
15579         if ((_res & 1) != 0) return;
15580         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15581         CHECK_ACCESS(_res_ptr);
15582         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
15583         FREE((void*)_res);
15584         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
15585 }
15586
15587 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
15588         LDKCVec_OutPointZ _res_constr;
15589         _res_constr.datalen = _res->arr_len;
15590         if (_res_constr.datalen > 0)
15591                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
15592         else
15593                 _res_constr.data = NULL;
15594         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15595         for (size_t k = 0; k < _res_constr.datalen; k++) {
15596                 uint32_t _res_conv_10 = _res_vals[k];
15597                 LDKOutPoint _res_conv_10_conv;
15598                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
15599                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
15600                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
15601                 _res_constr.data[k] = _res_conv_10_conv;
15602         }
15603         CVec_OutPointZ_free(_res_constr);
15604 }
15605
15606 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
15607         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15608         *ret_conv = CResult_NoneAPIErrorZ_ok();
15609         return (uintptr_t)ret_conv;
15610 }
15611
15612 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
15613         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15614         CHECK_ACCESS(e_ptr);
15615         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15616         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15617         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15618         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
15619         return (uintptr_t)ret_conv;
15620 }
15621
15622 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
15623         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
15624         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
15625         return ret_val;
15626 }
15627
15628 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
15629         if ((_res & 1) != 0) return;
15630         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15631         CHECK_ACCESS(_res_ptr);
15632         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
15633         FREE((void*)_res);
15634         CResult_NoneAPIErrorZ_free(_res_conv);
15635 }
15636
15637 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
15638         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15639         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
15640         return (uintptr_t)ret_conv;
15641 }
15642 intptr_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
15643         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
15644         intptr_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
15645         return ret_val;
15646 }
15647
15648 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
15649         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
15650         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15651         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
15652         return (uintptr_t)ret_conv;
15653 }
15654
15655 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
15656         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15657         *ret_copy = COption_u16Z_some(o);
15658         uintptr_t ret_ref = (uintptr_t)ret_copy;
15659         return ret_ref;
15660 }
15661
15662 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
15663         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15664         *ret_copy = COption_u16Z_none();
15665         uintptr_t ret_ref = (uintptr_t)ret_copy;
15666         return ret_ref;
15667 }
15668
15669 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
15670         if ((_res & 1) != 0) return;
15671         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15672         CHECK_ACCESS(_res_ptr);
15673         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
15674         FREE((void*)_res);
15675         COption_u16Z_free(_res_conv);
15676 }
15677
15678 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
15679         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15680         *ret_copy = COption_u16Z_clone(arg);
15681 uintptr_t ret_ref = (uintptr_t)ret_copy;
15682         return ret_ref;
15683 }
15684 intptr_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
15685         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
15686         intptr_t ret_val = COption_u16Z_clone_ptr(arg_conv);
15687         return ret_val;
15688 }
15689
15690 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
15691         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
15692         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15693         *ret_copy = COption_u16Z_clone(orig_conv);
15694         uintptr_t ret_ref = (uintptr_t)ret_copy;
15695         return ret_ref;
15696 }
15697
15698 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
15699         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
15700         _res_constr.datalen = _res->arr_len;
15701         if (_res_constr.datalen > 0)
15702                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15703         else
15704                 _res_constr.data = NULL;
15705         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15706         for (size_t w = 0; w < _res_constr.datalen; w++) {
15707                 uint32_t _res_conv_22 = _res_vals[w];
15708                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
15709                 CHECK_ACCESS(_res_conv_22_ptr);
15710                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
15711                 FREE((void*)_res_conv_22);
15712                 _res_constr.data[w] = _res_conv_22_conv;
15713         }
15714         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
15715 }
15716
15717 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
15718         LDKCVec_APIErrorZ _res_constr;
15719         _res_constr.datalen = _res->arr_len;
15720         if (_res_constr.datalen > 0)
15721                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15722         else
15723                 _res_constr.data = NULL;
15724         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15725         for (size_t k = 0; k < _res_constr.datalen; k++) {
15726                 uint32_t _res_conv_10 = _res_vals[k];
15727                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
15728                 CHECK_ACCESS(_res_conv_10_ptr);
15729                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
15730                 FREE((void*)_res_conv_10);
15731                 _res_constr.data[k] = _res_conv_10_conv;
15732         }
15733         CVec_APIErrorZ_free(_res_constr);
15734 }
15735
15736 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
15737         LDKThirtyTwoBytes o_ref;
15738         CHECK(o->arr_len == 32);
15739         memcpy(o_ref.data, o->elems, 32); FREE(o);
15740         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15741         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
15742         return (uintptr_t)ret_conv;
15743 }
15744
15745 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
15746         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15747         CHECK_ACCESS(e_ptr);
15748         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15749         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15750         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15751         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
15752         return (uintptr_t)ret_conv;
15753 }
15754
15755 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
15756         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
15757         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
15758         return ret_val;
15759 }
15760
15761 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
15762         if ((_res & 1) != 0) return;
15763         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15764         CHECK_ACCESS(_res_ptr);
15765         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
15766         FREE((void*)_res);
15767         CResult__u832APIErrorZ_free(_res_conv);
15768 }
15769
15770 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
15771         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15772         *ret_conv = CResult__u832APIErrorZ_clone(arg);
15773         return (uintptr_t)ret_conv;
15774 }
15775 intptr_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
15776         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
15777         intptr_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
15778         return ret_val;
15779 }
15780
15781 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
15782         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
15783         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15784         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
15785         return (uintptr_t)ret_conv;
15786 }
15787
15788 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
15789         LDKThirtyTwoBytes o_ref;
15790         CHECK(o->arr_len == 32);
15791         memcpy(o_ref.data, o->elems, 32); FREE(o);
15792         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15793         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
15794         return (uintptr_t)ret_conv;
15795 }
15796
15797 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
15798         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15799         CHECK_ACCESS(e_ptr);
15800         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15801         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15802         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15803         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
15804         return (uintptr_t)ret_conv;
15805 }
15806
15807 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
15808         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
15809         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
15810         return ret_val;
15811 }
15812
15813 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
15814         if ((_res & 1) != 0) return;
15815         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15816         CHECK_ACCESS(_res_ptr);
15817         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
15818         FREE((void*)_res);
15819         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
15820 }
15821
15822 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
15823         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15824         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
15825         return (uintptr_t)ret_conv;
15826 }
15827 intptr_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15828         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
15829         intptr_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
15830         return ret_val;
15831 }
15832
15833 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
15834         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
15835         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15836         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
15837         return (uintptr_t)ret_conv;
15838 }
15839
15840 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
15841         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15842         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
15843         return (uintptr_t)ret_conv;
15844 }
15845
15846 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
15847         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15848         CHECK_ACCESS(e_ptr);
15849         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15850         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15851         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15852         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
15853         return (uintptr_t)ret_conv;
15854 }
15855
15856 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
15857         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
15858         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
15859         return ret_val;
15860 }
15861
15862 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
15863         if ((_res & 1) != 0) return;
15864         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15865         CHECK_ACCESS(_res_ptr);
15866         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
15867         FREE((void*)_res);
15868         CResult_NonePaymentSendFailureZ_free(_res_conv);
15869 }
15870
15871 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
15872         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15873         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
15874         return (uintptr_t)ret_conv;
15875 }
15876 intptr_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
15877         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
15878         intptr_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
15879         return ret_val;
15880 }
15881
15882 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
15883         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
15884         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15885         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
15886         return (uintptr_t)ret_conv;
15887 }
15888
15889 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
15890         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15891         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
15892         return ((uintptr_t)ret_conv);
15893 }
15894 intptr_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
15895         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
15896         intptr_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
15897         return ret_val;
15898 }
15899
15900 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
15901         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
15902         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15903         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
15904         return ((uintptr_t)ret_conv);
15905 }
15906
15907 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
15908         LDKThirtyTwoBytes a_ref;
15909         CHECK(a->arr_len == 32);
15910         memcpy(a_ref.data, a->elems, 32); FREE(a);
15911         LDKThirtyTwoBytes b_ref;
15912         CHECK(b->arr_len == 32);
15913         memcpy(b_ref.data, b->elems, 32); FREE(b);
15914         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15915         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
15916         return ((uintptr_t)ret_conv);
15917 }
15918
15919 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
15920         if ((_res & 1) != 0) return;
15921         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15922         CHECK_ACCESS(_res_ptr);
15923         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
15924         FREE((void*)_res);
15925         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
15926 }
15927
15928 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
15929         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15930         CHECK_ACCESS(o_ptr);
15931         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
15932         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
15933         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15934         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
15935         return (uintptr_t)ret_conv;
15936 }
15937
15938 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
15939         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15940         CHECK_ACCESS(e_ptr);
15941         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15942         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15943         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15944         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
15945         return (uintptr_t)ret_conv;
15946 }
15947
15948 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
15949         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
15950         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
15951         return ret_val;
15952 }
15953
15954 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
15955         if ((_res & 1) != 0) return;
15956         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15957         CHECK_ACCESS(_res_ptr);
15958         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
15959         FREE((void*)_res);
15960         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
15961 }
15962
15963 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
15964         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15965         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
15966         return (uintptr_t)ret_conv;
15967 }
15968 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15969         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
15970         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
15971         return ret_val;
15972 }
15973
15974 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
15975         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
15976         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15977         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
15978         return (uintptr_t)ret_conv;
15979 }
15980
15981 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
15982         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15983         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
15984         return ((uintptr_t)ret_conv);
15985 }
15986 intptr_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
15987         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
15988         intptr_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
15989         return ret_val;
15990 }
15991
15992 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
15993         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
15994         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15995         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
15996         return ((uintptr_t)ret_conv);
15997 }
15998
15999 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
16000         LDKThirtyTwoBytes a_ref;
16001         CHECK(a->arr_len == 32);
16002         memcpy(a_ref.data, a->elems, 32); FREE(a);
16003         LDKThirtyTwoBytes b_ref;
16004         CHECK(b->arr_len == 32);
16005         memcpy(b_ref.data, b->elems, 32); FREE(b);
16006         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
16007         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
16008         return ((uintptr_t)ret_conv);
16009 }
16010
16011 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
16012         if ((_res & 1) != 0) return;
16013         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16014         CHECK_ACCESS(_res_ptr);
16015         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
16016         FREE((void*)_res);
16017         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
16018 }
16019
16020 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
16021         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16022         CHECK_ACCESS(o_ptr);
16023         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16024         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
16025         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16026         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
16027         return (uintptr_t)ret_conv;
16028 }
16029
16030 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
16031         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16032         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
16033         return (uintptr_t)ret_conv;
16034 }
16035
16036 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
16037         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
16038         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
16039         return ret_val;
16040 }
16041
16042 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
16043         if ((_res & 1) != 0) return;
16044         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16045         CHECK_ACCESS(_res_ptr);
16046         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
16047         FREE((void*)_res);
16048         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
16049 }
16050
16051 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
16052         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16053         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
16054         return (uintptr_t)ret_conv;
16055 }
16056 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
16057         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
16058         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
16059         return ret_val;
16060 }
16061
16062 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
16063         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
16064         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
16065         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
16066         return (uintptr_t)ret_conv;
16067 }
16068
16069 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
16070         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16071         CHECK_ACCESS(o_ptr);
16072         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
16073         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
16074         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16075         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
16076         return (uintptr_t)ret_conv;
16077 }
16078
16079 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
16080         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16081         CHECK_ACCESS(e_ptr);
16082         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16083         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16084         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16085         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
16086         return (uintptr_t)ret_conv;
16087 }
16088
16089 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
16090         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
16091         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
16092         return ret_val;
16093 }
16094
16095 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
16096         if ((_res & 1) != 0) return;
16097         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16098         CHECK_ACCESS(_res_ptr);
16099         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
16100         FREE((void*)_res);
16101         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
16102 }
16103
16104 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
16105         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16106         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
16107         return (uintptr_t)ret_conv;
16108 }
16109 intptr_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
16110         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
16111         intptr_t ret_val = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
16112         return ret_val;
16113 }
16114
16115 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
16116         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
16117         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
16118         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
16119         return (uintptr_t)ret_conv;
16120 }
16121
16122 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
16123         LDKThirtyTwoBytes o_ref;
16124         CHECK(o->arr_len == 32);
16125         memcpy(o_ref.data, o->elems, 32); FREE(o);
16126         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16127         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
16128         return (uintptr_t)ret_conv;
16129 }
16130
16131 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
16132         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16133         *ret_conv = CResult_PaymentSecretNoneZ_err();
16134         return (uintptr_t)ret_conv;
16135 }
16136
16137 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
16138         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
16139         jboolean ret_val = CResult_PaymentSecretNoneZ_is_ok(o_conv);
16140         return ret_val;
16141 }
16142
16143 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
16144         if ((_res & 1) != 0) return;
16145         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16146         CHECK_ACCESS(_res_ptr);
16147         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
16148         FREE((void*)_res);
16149         CResult_PaymentSecretNoneZ_free(_res_conv);
16150 }
16151
16152 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
16153         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16154         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
16155         return (uintptr_t)ret_conv;
16156 }
16157 intptr_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
16158         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
16159         intptr_t ret_val = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
16160         return ret_val;
16161 }
16162
16163 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
16164         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
16165         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
16166         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
16167         return (uintptr_t)ret_conv;
16168 }
16169
16170 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
16171         LDKThirtyTwoBytes o_ref;
16172         CHECK(o->arr_len == 32);
16173         memcpy(o_ref.data, o->elems, 32); FREE(o);
16174         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16175         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
16176         return (uintptr_t)ret_conv;
16177 }
16178
16179 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
16180         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16181         CHECK_ACCESS(e_ptr);
16182         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16183         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16184         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16185         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
16186         return (uintptr_t)ret_conv;
16187 }
16188
16189 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
16190         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
16191         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
16192         return ret_val;
16193 }
16194
16195 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
16196         if ((_res & 1) != 0) return;
16197         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16198         CHECK_ACCESS(_res_ptr);
16199         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
16200         FREE((void*)_res);
16201         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
16202 }
16203
16204 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
16205         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16206         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
16207         return (uintptr_t)ret_conv;
16208 }
16209 intptr_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
16210         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
16211         intptr_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
16212         return ret_val;
16213 }
16214
16215 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
16216         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
16217         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
16218         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
16219         return (uintptr_t)ret_conv;
16220 }
16221
16222 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
16223         LDKThirtyTwoBytes o_ref;
16224         CHECK(o->arr_len == 32);
16225         memcpy(o_ref.data, o->elems, 32); FREE(o);
16226         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16227         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
16228         return (uintptr_t)ret_conv;
16229 }
16230
16231 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
16232         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16233         CHECK_ACCESS(e_ptr);
16234         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
16235         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
16236         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16237         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
16238         return (uintptr_t)ret_conv;
16239 }
16240
16241 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
16242         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
16243         jboolean ret_val = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
16244         return ret_val;
16245 }
16246
16247 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
16248         if ((_res & 1) != 0) return;
16249         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16250         CHECK_ACCESS(_res_ptr);
16251         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
16252         FREE((void*)_res);
16253         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
16254 }
16255
16256 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
16257         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16258         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
16259         return (uintptr_t)ret_conv;
16260 }
16261 intptr_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
16262         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
16263         intptr_t ret_val = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
16264         return ret_val;
16265 }
16266
16267 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
16268         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
16269         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
16270         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
16271         return (uintptr_t)ret_conv;
16272 }
16273
16274 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
16275         LDKCVec_ChannelMonitorZ _res_constr;
16276         _res_constr.datalen = _res->arr_len;
16277         if (_res_constr.datalen > 0)
16278                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
16279         else
16280                 _res_constr.data = NULL;
16281         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16282         for (size_t q = 0; q < _res_constr.datalen; q++) {
16283                 uint32_t _res_conv_16 = _res_vals[q];
16284                 LDKChannelMonitor _res_conv_16_conv;
16285                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
16286                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
16287                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16288                 _res_constr.data[q] = _res_conv_16_conv;
16289         }
16290         CVec_ChannelMonitorZ_free(_res_constr);
16291 }
16292
16293 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
16294         LDKThirtyTwoBytes a_ref;
16295         CHECK(a->arr_len == 32);
16296         memcpy(a_ref.data, a->elems, 32); FREE(a);
16297         LDKChannelManager b_conv;
16298         b_conv.inner = (void*)(b & (~1));
16299         b_conv.is_owned = (b & 1) || (b == 0);
16300         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16301         // Warning: we need a move here but no clone is available for LDKChannelManager
16302         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
16303         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
16304         return ((uintptr_t)ret_conv);
16305 }
16306
16307 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
16308         if ((_res & 1) != 0) return;
16309         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16310         CHECK_ACCESS(_res_ptr);
16311         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
16312         FREE((void*)_res);
16313         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
16314 }
16315
16316 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
16317         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16318         CHECK_ACCESS(o_ptr);
16319         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
16320         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
16321         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16322         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
16323         return (uintptr_t)ret_conv;
16324 }
16325
16326 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
16327         LDKDecodeError e_conv;
16328         e_conv.inner = (void*)(e & (~1));
16329         e_conv.is_owned = (e & 1) || (e == 0);
16330         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16331         e_conv = DecodeError_clone(&e_conv);
16332         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16333         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
16334         return (uintptr_t)ret_conv;
16335 }
16336
16337 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
16338         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
16339         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
16340         return ret_val;
16341 }
16342
16343 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
16344         if ((_res & 1) != 0) return;
16345         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16346         CHECK_ACCESS(_res_ptr);
16347         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
16348         FREE((void*)_res);
16349         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
16350 }
16351
16352 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
16353         if ((this_ptr & 1) != 0) return;
16354         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
16355         CHECK_ACCESS(this_ptr_ptr);
16356         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
16357         FREE((void*)this_ptr);
16358         PaymentPurpose_free(this_ptr_conv);
16359 }
16360
16361 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
16362         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16363         *ret_copy = PaymentPurpose_clone(arg);
16364 uintptr_t ret_ref = (uintptr_t)ret_copy;
16365         return ret_ref;
16366 }
16367 intptr_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
16368         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
16369         intptr_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
16370         return ret_val;
16371 }
16372
16373 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
16374         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
16375         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16376         *ret_copy = PaymentPurpose_clone(orig_conv);
16377         uintptr_t ret_ref = (uintptr_t)ret_copy;
16378         return ret_ref;
16379 }
16380
16381 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
16382         LDKThirtyTwoBytes payment_preimage_ref;
16383         CHECK(payment_preimage->arr_len == 32);
16384         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
16385         LDKThirtyTwoBytes payment_secret_ref;
16386         CHECK(payment_secret->arr_len == 32);
16387         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
16388         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16389         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
16390         uintptr_t ret_ref = (uintptr_t)ret_copy;
16391         return ret_ref;
16392 }
16393
16394 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
16395         LDKThirtyTwoBytes a_ref;
16396         CHECK(a->arr_len == 32);
16397         memcpy(a_ref.data, a->elems, 32); FREE(a);
16398         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
16399         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
16400         uintptr_t ret_ref = (uintptr_t)ret_copy;
16401         return ret_ref;
16402 }
16403
16404 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
16405         if ((this_ptr & 1) != 0) return;
16406         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
16407         CHECK_ACCESS(this_ptr_ptr);
16408         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
16409         FREE((void*)this_ptr);
16410         ClosureReason_free(this_ptr_conv);
16411 }
16412
16413 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
16414         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16415         *ret_copy = ClosureReason_clone(arg);
16416 uintptr_t ret_ref = (uintptr_t)ret_copy;
16417         return ret_ref;
16418 }
16419 intptr_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
16420         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
16421         intptr_t ret_val = ClosureReason_clone_ptr(arg_conv);
16422         return ret_val;
16423 }
16424
16425 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
16426         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
16427         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16428         *ret_copy = ClosureReason_clone(orig_conv);
16429         uintptr_t ret_ref = (uintptr_t)ret_copy;
16430         return ret_ref;
16431 }
16432
16433 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
16434         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
16435         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16436         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
16437         uintptr_t ret_ref = (uintptr_t)ret_copy;
16438         return ret_ref;
16439 }
16440
16441 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
16442         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16443         *ret_copy = ClosureReason_holder_force_closed();
16444         uintptr_t ret_ref = (uintptr_t)ret_copy;
16445         return ret_ref;
16446 }
16447
16448 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
16449         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16450         *ret_copy = ClosureReason_cooperative_closure();
16451         uintptr_t ret_ref = (uintptr_t)ret_copy;
16452         return ret_ref;
16453 }
16454
16455 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
16456         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16457         *ret_copy = ClosureReason_commitment_tx_confirmed();
16458         uintptr_t ret_ref = (uintptr_t)ret_copy;
16459         return ret_ref;
16460 }
16461
16462 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
16463         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16464         *ret_copy = ClosureReason_funding_timed_out();
16465         uintptr_t ret_ref = (uintptr_t)ret_copy;
16466         return ret_ref;
16467 }
16468
16469 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
16470         LDKStr err_conv = str_ref_to_owned_c(err);
16471         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16472         *ret_copy = ClosureReason_processing_error(err_conv);
16473         uintptr_t ret_ref = (uintptr_t)ret_copy;
16474         return ret_ref;
16475 }
16476
16477 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
16478         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16479         *ret_copy = ClosureReason_disconnected_peer();
16480         uintptr_t ret_ref = (uintptr_t)ret_copy;
16481         return ret_ref;
16482 }
16483
16484 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
16485         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
16486         *ret_copy = ClosureReason_outdated_channel_manager();
16487         uintptr_t ret_ref = (uintptr_t)ret_copy;
16488         return ret_ref;
16489 }
16490
16491 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
16492         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
16493         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
16494         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
16495         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
16496         CVec_u8Z_free(ret_var);
16497         return ret_arr;
16498 }
16499
16500 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
16501         LDKu8slice ser_ref;
16502         ser_ref.datalen = ser->arr_len;
16503         ser_ref.data = ser->elems /* XXX ser leaks */;
16504         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16505         *ret_conv = ClosureReason_read(ser_ref);
16506         return (uintptr_t)ret_conv;
16507 }
16508
16509 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
16510         if ((this_ptr & 1) != 0) return;
16511         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
16512         CHECK_ACCESS(this_ptr_ptr);
16513         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
16514         FREE((void*)this_ptr);
16515         Event_free(this_ptr_conv);
16516 }
16517
16518 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
16519         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16520         *ret_copy = Event_clone(arg);
16521 uintptr_t ret_ref = (uintptr_t)ret_copy;
16522         return ret_ref;
16523 }
16524 intptr_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
16525         LDKEvent* arg_conv = (LDKEvent*)arg;
16526         intptr_t ret_val = Event_clone_ptr(arg_conv);
16527         return ret_val;
16528 }
16529
16530 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
16531         LDKEvent* orig_conv = (LDKEvent*)orig;
16532         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16533         *ret_copy = Event_clone(orig_conv);
16534         uintptr_t ret_ref = (uintptr_t)ret_copy;
16535         return ret_ref;
16536 }
16537
16538 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) {
16539         LDKThirtyTwoBytes temporary_channel_id_ref;
16540         CHECK(temporary_channel_id->arr_len == 32);
16541         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
16542         LDKCVec_u8Z output_script_ref;
16543         output_script_ref.datalen = output_script->arr_len;
16544         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
16545         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
16546         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16547         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
16548         uintptr_t ret_ref = (uintptr_t)ret_copy;
16549         return ret_ref;
16550 }
16551
16552 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
16553         LDKThirtyTwoBytes payment_hash_ref;
16554         CHECK(payment_hash->arr_len == 32);
16555         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
16556         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
16557         CHECK_ACCESS(purpose_ptr);
16558         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
16559         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
16560         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16561         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
16562         uintptr_t ret_ref = (uintptr_t)ret_copy;
16563         return ret_ref;
16564 }
16565
16566 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) {
16567         LDKThirtyTwoBytes payment_id_ref;
16568         CHECK(payment_id->arr_len == 32);
16569         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
16570         LDKThirtyTwoBytes payment_preimage_ref;
16571         CHECK(payment_preimage->arr_len == 32);
16572         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
16573         LDKThirtyTwoBytes payment_hash_ref;
16574         CHECK(payment_hash->arr_len == 32);
16575         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
16576         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
16577         CHECK_ACCESS(fee_paid_msat_ptr);
16578         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
16579         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
16580         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16581         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
16582         uintptr_t ret_ref = (uintptr_t)ret_copy;
16583         return ret_ref;
16584 }
16585
16586 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) {
16587         LDKThirtyTwoBytes payment_id_ref;
16588         CHECK(payment_id->arr_len == 32);
16589         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
16590         LDKThirtyTwoBytes payment_hash_ref;
16591         CHECK(payment_hash->arr_len == 32);
16592         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
16593         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
16594         CHECK_ACCESS(network_update_ptr);
16595         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
16596         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
16597         LDKCVec_RouteHopZ path_constr;
16598         path_constr.datalen = path->arr_len;
16599         if (path_constr.datalen > 0)
16600                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16601         else
16602                 path_constr.data = NULL;
16603         uint32_t* path_vals = path->elems /* XXX path leaks */;
16604         for (size_t k = 0; k < path_constr.datalen; k++) {
16605                 uint32_t path_conv_10 = path_vals[k];
16606                 LDKRouteHop path_conv_10_conv;
16607                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
16608                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
16609                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
16610                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
16611                 path_constr.data[k] = path_conv_10_conv;
16612         }
16613         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
16614         CHECK_ACCESS(short_channel_id_ptr);
16615         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
16616         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
16617         LDKRouteParameters retry_conv;
16618         retry_conv.inner = (void*)(retry & (~1));
16619         retry_conv.is_owned = (retry & 1) || (retry == 0);
16620         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
16621         retry_conv = RouteParameters_clone(&retry_conv);
16622         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16623         *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);
16624         uintptr_t ret_ref = (uintptr_t)ret_copy;
16625         return ret_ref;
16626 }
16627
16628 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
16629         LDKThirtyTwoBytes payment_id_ref;
16630         CHECK(payment_id->arr_len == 32);
16631         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
16632         LDKThirtyTwoBytes payment_hash_ref;
16633         CHECK(payment_hash->arr_len == 32);
16634         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
16635         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16636         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
16637         uintptr_t ret_ref = (uintptr_t)ret_copy;
16638         return ret_ref;
16639 }
16640
16641 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
16642         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16643         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
16644         uintptr_t ret_ref = (uintptr_t)ret_copy;
16645         return ret_ref;
16646 }
16647
16648 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
16649         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
16650         outputs_constr.datalen = outputs->arr_len;
16651         if (outputs_constr.datalen > 0)
16652                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
16653         else
16654                 outputs_constr.data = NULL;
16655         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
16656         for (size_t b = 0; b < outputs_constr.datalen; b++) {
16657                 uint32_t outputs_conv_27 = outputs_vals[b];
16658                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
16659                 CHECK_ACCESS(outputs_conv_27_ptr);
16660                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
16661                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
16662                 outputs_constr.data[b] = outputs_conv_27_conv;
16663         }
16664         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16665         *ret_copy = Event_spendable_outputs(outputs_constr);
16666         uintptr_t ret_ref = (uintptr_t)ret_copy;
16667         return ret_ref;
16668 }
16669
16670 uint32_t  __attribute__((export_name("TS_Event_payment_forwarded"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
16671         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
16672         CHECK_ACCESS(fee_earned_msat_ptr);
16673         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
16674         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
16675         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16676         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
16677         uintptr_t ret_ref = (uintptr_t)ret_copy;
16678         return ret_ref;
16679 }
16680
16681 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) {
16682         LDKThirtyTwoBytes channel_id_ref;
16683         CHECK(channel_id->arr_len == 32);
16684         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
16685         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
16686         CHECK_ACCESS(reason_ptr);
16687         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
16688         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
16689         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16690         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
16691         uintptr_t ret_ref = (uintptr_t)ret_copy;
16692         return ret_ref;
16693 }
16694
16695 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
16696         LDKThirtyTwoBytes channel_id_ref;
16697         CHECK(channel_id->arr_len == 32);
16698         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
16699         LDKTransaction transaction_ref;
16700         transaction_ref.datalen = transaction->arr_len;
16701         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
16702         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
16703         transaction_ref.data_is_owned = true;
16704         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16705         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
16706         uintptr_t ret_ref = (uintptr_t)ret_copy;
16707         return ret_ref;
16708 }
16709
16710 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) {
16711         LDKThirtyTwoBytes payment_id_ref;
16712         CHECK(payment_id->arr_len == 32);
16713         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
16714         LDKThirtyTwoBytes payment_hash_ref;
16715         CHECK(payment_hash->arr_len == 32);
16716         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
16717         LDKCVec_RouteHopZ path_constr;
16718         path_constr.datalen = path->arr_len;
16719         if (path_constr.datalen > 0)
16720                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16721         else
16722                 path_constr.data = NULL;
16723         uint32_t* path_vals = path->elems /* XXX path leaks */;
16724         for (size_t k = 0; k < path_constr.datalen; k++) {
16725                 uint32_t path_conv_10 = path_vals[k];
16726                 LDKRouteHop path_conv_10_conv;
16727                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
16728                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
16729                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
16730                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
16731                 path_constr.data[k] = path_conv_10_conv;
16732         }
16733         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
16734         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
16735         uintptr_t ret_ref = (uintptr_t)ret_copy;
16736         return ret_ref;
16737 }
16738
16739 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
16740         LDKEvent* obj_conv = (LDKEvent*)obj;
16741         LDKCVec_u8Z ret_var = Event_write(obj_conv);
16742         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
16743         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
16744         CVec_u8Z_free(ret_var);
16745         return ret_arr;
16746 }
16747
16748 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
16749         LDKu8slice ser_ref;
16750         ser_ref.datalen = ser->arr_len;
16751         ser_ref.data = ser->elems /* XXX ser leaks */;
16752         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
16753         *ret_conv = Event_read(ser_ref);
16754         return (uintptr_t)ret_conv;
16755 }
16756
16757 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
16758         if ((this_ptr & 1) != 0) return;
16759         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
16760         CHECK_ACCESS(this_ptr_ptr);
16761         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
16762         FREE((void*)this_ptr);
16763         MessageSendEvent_free(this_ptr_conv);
16764 }
16765
16766 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
16767         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16768         *ret_copy = MessageSendEvent_clone(arg);
16769 uintptr_t ret_ref = (uintptr_t)ret_copy;
16770         return ret_ref;
16771 }
16772 intptr_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
16773         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
16774         intptr_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
16775         return ret_val;
16776 }
16777
16778 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
16779         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
16780         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16781         *ret_copy = MessageSendEvent_clone(orig_conv);
16782         uintptr_t ret_ref = (uintptr_t)ret_copy;
16783         return ret_ref;
16784 }
16785
16786 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
16787         LDKPublicKey node_id_ref;
16788         CHECK(node_id->arr_len == 33);
16789         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16790         LDKAcceptChannel msg_conv;
16791         msg_conv.inner = (void*)(msg & (~1));
16792         msg_conv.is_owned = (msg & 1) || (msg == 0);
16793         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16794         msg_conv = AcceptChannel_clone(&msg_conv);
16795         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16796         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
16797         uintptr_t ret_ref = (uintptr_t)ret_copy;
16798         return ret_ref;
16799 }
16800
16801 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
16802         LDKPublicKey node_id_ref;
16803         CHECK(node_id->arr_len == 33);
16804         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16805         LDKOpenChannel msg_conv;
16806         msg_conv.inner = (void*)(msg & (~1));
16807         msg_conv.is_owned = (msg & 1) || (msg == 0);
16808         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16809         msg_conv = OpenChannel_clone(&msg_conv);
16810         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16811         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
16812         uintptr_t ret_ref = (uintptr_t)ret_copy;
16813         return ret_ref;
16814 }
16815
16816 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
16817         LDKPublicKey node_id_ref;
16818         CHECK(node_id->arr_len == 33);
16819         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16820         LDKFundingCreated msg_conv;
16821         msg_conv.inner = (void*)(msg & (~1));
16822         msg_conv.is_owned = (msg & 1) || (msg == 0);
16823         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16824         msg_conv = FundingCreated_clone(&msg_conv);
16825         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16826         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
16827         uintptr_t ret_ref = (uintptr_t)ret_copy;
16828         return ret_ref;
16829 }
16830
16831 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
16832         LDKPublicKey node_id_ref;
16833         CHECK(node_id->arr_len == 33);
16834         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16835         LDKFundingSigned msg_conv;
16836         msg_conv.inner = (void*)(msg & (~1));
16837         msg_conv.is_owned = (msg & 1) || (msg == 0);
16838         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16839         msg_conv = FundingSigned_clone(&msg_conv);
16840         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16841         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
16842         uintptr_t ret_ref = (uintptr_t)ret_copy;
16843         return ret_ref;
16844 }
16845
16846 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_locked"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
16847         LDKPublicKey node_id_ref;
16848         CHECK(node_id->arr_len == 33);
16849         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16850         LDKFundingLocked msg_conv;
16851         msg_conv.inner = (void*)(msg & (~1));
16852         msg_conv.is_owned = (msg & 1) || (msg == 0);
16853         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16854         msg_conv = FundingLocked_clone(&msg_conv);
16855         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16856         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
16857         uintptr_t ret_ref = (uintptr_t)ret_copy;
16858         return ret_ref;
16859 }
16860
16861 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
16862         LDKPublicKey node_id_ref;
16863         CHECK(node_id->arr_len == 33);
16864         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16865         LDKAnnouncementSignatures msg_conv;
16866         msg_conv.inner = (void*)(msg & (~1));
16867         msg_conv.is_owned = (msg & 1) || (msg == 0);
16868         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16869         msg_conv = AnnouncementSignatures_clone(&msg_conv);
16870         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16871         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
16872         uintptr_t ret_ref = (uintptr_t)ret_copy;
16873         return ret_ref;
16874 }
16875
16876 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
16877         LDKPublicKey node_id_ref;
16878         CHECK(node_id->arr_len == 33);
16879         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16880         LDKCommitmentUpdate updates_conv;
16881         updates_conv.inner = (void*)(updates & (~1));
16882         updates_conv.is_owned = (updates & 1) || (updates == 0);
16883         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
16884         updates_conv = CommitmentUpdate_clone(&updates_conv);
16885         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16886         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
16887         uintptr_t ret_ref = (uintptr_t)ret_copy;
16888         return ret_ref;
16889 }
16890
16891 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
16892         LDKPublicKey node_id_ref;
16893         CHECK(node_id->arr_len == 33);
16894         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16895         LDKRevokeAndACK msg_conv;
16896         msg_conv.inner = (void*)(msg & (~1));
16897         msg_conv.is_owned = (msg & 1) || (msg == 0);
16898         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16899         msg_conv = RevokeAndACK_clone(&msg_conv);
16900         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16901         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
16902         uintptr_t ret_ref = (uintptr_t)ret_copy;
16903         return ret_ref;
16904 }
16905
16906 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
16907         LDKPublicKey node_id_ref;
16908         CHECK(node_id->arr_len == 33);
16909         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16910         LDKClosingSigned msg_conv;
16911         msg_conv.inner = (void*)(msg & (~1));
16912         msg_conv.is_owned = (msg & 1) || (msg == 0);
16913         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16914         msg_conv = ClosingSigned_clone(&msg_conv);
16915         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16916         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
16917         uintptr_t ret_ref = (uintptr_t)ret_copy;
16918         return ret_ref;
16919 }
16920
16921 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
16922         LDKPublicKey node_id_ref;
16923         CHECK(node_id->arr_len == 33);
16924         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16925         LDKShutdown msg_conv;
16926         msg_conv.inner = (void*)(msg & (~1));
16927         msg_conv.is_owned = (msg & 1) || (msg == 0);
16928         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16929         msg_conv = Shutdown_clone(&msg_conv);
16930         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16931         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
16932         uintptr_t ret_ref = (uintptr_t)ret_copy;
16933         return ret_ref;
16934 }
16935
16936 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
16937         LDKPublicKey node_id_ref;
16938         CHECK(node_id->arr_len == 33);
16939         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16940         LDKChannelReestablish msg_conv;
16941         msg_conv.inner = (void*)(msg & (~1));
16942         msg_conv.is_owned = (msg & 1) || (msg == 0);
16943         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16944         msg_conv = ChannelReestablish_clone(&msg_conv);
16945         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16946         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
16947         uintptr_t ret_ref = (uintptr_t)ret_copy;
16948         return ret_ref;
16949 }
16950
16951 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
16952         LDKChannelAnnouncement msg_conv;
16953         msg_conv.inner = (void*)(msg & (~1));
16954         msg_conv.is_owned = (msg & 1) || (msg == 0);
16955         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16956         msg_conv = ChannelAnnouncement_clone(&msg_conv);
16957         LDKChannelUpdate update_msg_conv;
16958         update_msg_conv.inner = (void*)(update_msg & (~1));
16959         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
16960         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
16961         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
16962         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16963         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
16964         uintptr_t ret_ref = (uintptr_t)ret_copy;
16965         return ret_ref;
16966 }
16967
16968 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
16969         LDKNodeAnnouncement msg_conv;
16970         msg_conv.inner = (void*)(msg & (~1));
16971         msg_conv.is_owned = (msg & 1) || (msg == 0);
16972         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16973         msg_conv = NodeAnnouncement_clone(&msg_conv);
16974         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16975         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
16976         uintptr_t ret_ref = (uintptr_t)ret_copy;
16977         return ret_ref;
16978 }
16979
16980 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
16981         LDKChannelUpdate msg_conv;
16982         msg_conv.inner = (void*)(msg & (~1));
16983         msg_conv.is_owned = (msg & 1) || (msg == 0);
16984         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
16985         msg_conv = ChannelUpdate_clone(&msg_conv);
16986         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
16987         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
16988         uintptr_t ret_ref = (uintptr_t)ret_copy;
16989         return ret_ref;
16990 }
16991
16992 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
16993         LDKPublicKey node_id_ref;
16994         CHECK(node_id->arr_len == 33);
16995         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
16996         LDKChannelUpdate msg_conv;
16997         msg_conv.inner = (void*)(msg & (~1));
16998         msg_conv.is_owned = (msg & 1) || (msg == 0);
16999         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17000         msg_conv = ChannelUpdate_clone(&msg_conv);
17001         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17002         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
17003         uintptr_t ret_ref = (uintptr_t)ret_copy;
17004         return ret_ref;
17005 }
17006
17007 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
17008         LDKPublicKey node_id_ref;
17009         CHECK(node_id->arr_len == 33);
17010         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
17011         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
17012         CHECK_ACCESS(action_ptr);
17013         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
17014         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
17015         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17016         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
17017         uintptr_t ret_ref = (uintptr_t)ret_copy;
17018         return ret_ref;
17019 }
17020
17021 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
17022         LDKPublicKey node_id_ref;
17023         CHECK(node_id->arr_len == 33);
17024         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
17025         LDKQueryChannelRange msg_conv;
17026         msg_conv.inner = (void*)(msg & (~1));
17027         msg_conv.is_owned = (msg & 1) || (msg == 0);
17028         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17029         msg_conv = QueryChannelRange_clone(&msg_conv);
17030         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17031         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
17032         uintptr_t ret_ref = (uintptr_t)ret_copy;
17033         return ret_ref;
17034 }
17035
17036 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
17037         LDKPublicKey node_id_ref;
17038         CHECK(node_id->arr_len == 33);
17039         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
17040         LDKQueryShortChannelIds msg_conv;
17041         msg_conv.inner = (void*)(msg & (~1));
17042         msg_conv.is_owned = (msg & 1) || (msg == 0);
17043         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17044         msg_conv = QueryShortChannelIds_clone(&msg_conv);
17045         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17046         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
17047         uintptr_t ret_ref = (uintptr_t)ret_copy;
17048         return ret_ref;
17049 }
17050
17051 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
17052         LDKPublicKey node_id_ref;
17053         CHECK(node_id->arr_len == 33);
17054         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
17055         LDKReplyChannelRange msg_conv;
17056         msg_conv.inner = (void*)(msg & (~1));
17057         msg_conv.is_owned = (msg & 1) || (msg == 0);
17058         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
17059         msg_conv = ReplyChannelRange_clone(&msg_conv);
17060         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
17061         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
17062         uintptr_t ret_ref = (uintptr_t)ret_copy;
17063         return ret_ref;
17064 }
17065
17066 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
17067         if ((this_ptr & 1) != 0) return;
17068         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
17069         CHECK_ACCESS(this_ptr_ptr);
17070         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
17071         FREE((void*)this_ptr);
17072         MessageSendEventsProvider_free(this_ptr_conv);
17073 }
17074
17075 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
17076         if ((this_ptr & 1) != 0) return;
17077         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
17078         CHECK_ACCESS(this_ptr_ptr);
17079         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
17080         FREE((void*)this_ptr);
17081         EventsProvider_free(this_ptr_conv);
17082 }
17083
17084 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
17085         if ((this_ptr & 1) != 0) return;
17086         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
17087         CHECK_ACCESS(this_ptr_ptr);
17088         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
17089         FREE((void*)this_ptr);
17090         EventHandler_free(this_ptr_conv);
17091 }
17092
17093 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
17094         if ((this_ptr & 1) != 0) return;
17095         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
17096         CHECK_ACCESS(this_ptr_ptr);
17097         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
17098         FREE((void*)this_ptr);
17099         APIError_free(this_ptr_conv);
17100 }
17101
17102 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
17103         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17104         *ret_copy = APIError_clone(arg);
17105 uintptr_t ret_ref = (uintptr_t)ret_copy;
17106         return ret_ref;
17107 }
17108 intptr_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
17109         LDKAPIError* arg_conv = (LDKAPIError*)arg;
17110         intptr_t ret_val = APIError_clone_ptr(arg_conv);
17111         return ret_val;
17112 }
17113
17114 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
17115         LDKAPIError* orig_conv = (LDKAPIError*)orig;
17116         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17117         *ret_copy = APIError_clone(orig_conv);
17118         uintptr_t ret_ref = (uintptr_t)ret_copy;
17119         return ret_ref;
17120 }
17121
17122 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
17123         LDKStr err_conv = str_ref_to_owned_c(err);
17124         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17125         *ret_copy = APIError_apimisuse_error(err_conv);
17126         uintptr_t ret_ref = (uintptr_t)ret_copy;
17127         return ret_ref;
17128 }
17129
17130 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
17131         LDKStr err_conv = str_ref_to_owned_c(err);
17132         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17133         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
17134         uintptr_t ret_ref = (uintptr_t)ret_copy;
17135         return ret_ref;
17136 }
17137
17138 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
17139         LDKStr err_conv = str_ref_to_owned_c(err);
17140         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17141         *ret_copy = APIError_route_error(err_conv);
17142         uintptr_t ret_ref = (uintptr_t)ret_copy;
17143         return ret_ref;
17144 }
17145
17146 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
17147         LDKStr err_conv = str_ref_to_owned_c(err);
17148         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17149         *ret_copy = APIError_channel_unavailable(err_conv);
17150         uintptr_t ret_ref = (uintptr_t)ret_copy;
17151         return ret_ref;
17152 }
17153
17154 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
17155         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17156         *ret_copy = APIError_monitor_update_failed();
17157         uintptr_t ret_ref = (uintptr_t)ret_copy;
17158         return ret_ref;
17159 }
17160
17161 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
17162         LDKShutdownScript script_conv;
17163         script_conv.inner = (void*)(script & (~1));
17164         script_conv.is_owned = (script & 1) || (script == 0);
17165         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
17166         script_conv = ShutdownScript_clone(&script_conv);
17167         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
17168         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
17169         uintptr_t ret_ref = (uintptr_t)ret_copy;
17170         return ret_ref;
17171 }
17172
17173 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
17174         LDKu8slice msg_ref;
17175         msg_ref.datalen = msg->arr_len;
17176         msg_ref.data = msg->elems /* XXX msg leaks */;
17177         unsigned char sk_arr[32];
17178         CHECK(sk->arr_len == 32);
17179         memcpy(sk_arr, sk->elems, 32); FREE(sk);
17180         unsigned char (*sk_ref)[32] = &sk_arr;
17181         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
17182         *ret_conv = sign(msg_ref, sk_ref);
17183         return (uintptr_t)ret_conv;
17184 }
17185
17186 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
17187         LDKu8slice msg_ref;
17188         msg_ref.datalen = msg->arr_len;
17189         msg_ref.data = msg->elems /* XXX msg leaks */;
17190         LDKStr sig_conv = str_ref_to_owned_c(sig);
17191         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
17192         *ret_conv = recover_pk(msg_ref, sig_conv);
17193         return (uintptr_t)ret_conv;
17194 }
17195
17196 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
17197         LDKu8slice msg_ref;
17198         msg_ref.datalen = msg->arr_len;
17199         msg_ref.data = msg->elems /* XXX msg leaks */;
17200         LDKStr sig_conv = str_ref_to_owned_c(sig);
17201         LDKPublicKey pk_ref;
17202         CHECK(pk->arr_len == 33);
17203         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
17204         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
17205         return ret_val;
17206 }
17207
17208 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
17209         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
17210         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
17211         return ret_conv;
17212 }
17213
17214 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
17215         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
17216         return ret_conv;
17217 }
17218
17219 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
17220         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
17221         return ret_conv;
17222 }
17223
17224 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
17225         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
17226         return ret_conv;
17227 }
17228
17229 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
17230         uint32_t ret_conv = LDKLevel_to_js(Level_info());
17231         return ret_conv;
17232 }
17233
17234 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
17235         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
17236         return ret_conv;
17237 }
17238
17239 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
17240         uint32_t ret_conv = LDKLevel_to_js(Level_error());
17241         return ret_conv;
17242 }
17243
17244 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
17245         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
17246         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
17247         jboolean ret_val = Level_eq(a_conv, b_conv);
17248         return ret_val;
17249 }
17250
17251 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
17252         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
17253         int64_t ret_val = Level_hash(o_conv);
17254         return ret_val;
17255 }
17256
17257 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
17258         uint32_t ret_conv = LDKLevel_to_js(Level_max());
17259         return ret_conv;
17260 }
17261
17262 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
17263         LDKRecord this_obj_conv;
17264         this_obj_conv.inner = (void*)(this_obj & (~1));
17265         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17267         Record_free(this_obj_conv);
17268 }
17269
17270 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
17271         LDKRecord this_ptr_conv;
17272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17273         this_ptr_conv.is_owned = false;
17274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17275         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
17276         return ret_conv;
17277 }
17278
17279 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
17280         LDKRecord this_ptr_conv;
17281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17282         this_ptr_conv.is_owned = false;
17283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17284         LDKLevel val_conv = LDKLevel_from_js(val);
17285         Record_set_level(&this_ptr_conv, val_conv);
17286 }
17287
17288 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
17289         LDKRecord this_ptr_conv;
17290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17291         this_ptr_conv.is_owned = false;
17292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17293         LDKStr ret_str = Record_get_args(&this_ptr_conv);
17294         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17295         Str_free(ret_str);
17296         return ret_conv;
17297 }
17298
17299 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
17300         LDKRecord this_ptr_conv;
17301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17302         this_ptr_conv.is_owned = false;
17303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17304         LDKStr val_conv = str_ref_to_owned_c(val);
17305         Record_set_args(&this_ptr_conv, val_conv);
17306 }
17307
17308 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
17309         LDKRecord this_ptr_conv;
17310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17311         this_ptr_conv.is_owned = false;
17312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17313         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
17314         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17315         Str_free(ret_str);
17316         return ret_conv;
17317 }
17318
17319 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
17320         LDKRecord this_ptr_conv;
17321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17322         this_ptr_conv.is_owned = false;
17323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17324         LDKStr val_conv = str_ref_to_owned_c(val);
17325         Record_set_module_path(&this_ptr_conv, val_conv);
17326 }
17327
17328 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
17329         LDKRecord this_ptr_conv;
17330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17331         this_ptr_conv.is_owned = false;
17332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17333         LDKStr ret_str = Record_get_file(&this_ptr_conv);
17334         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
17335         Str_free(ret_str);
17336         return ret_conv;
17337 }
17338
17339 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
17340         LDKRecord this_ptr_conv;
17341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17342         this_ptr_conv.is_owned = false;
17343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17344         LDKStr val_conv = str_ref_to_owned_c(val);
17345         Record_set_file(&this_ptr_conv, val_conv);
17346 }
17347
17348 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
17349         LDKRecord this_ptr_conv;
17350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17351         this_ptr_conv.is_owned = false;
17352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17353         int32_t ret_val = Record_get_line(&this_ptr_conv);
17354         return ret_val;
17355 }
17356
17357 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
17358         LDKRecord this_ptr_conv;
17359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17360         this_ptr_conv.is_owned = false;
17361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17362         Record_set_line(&this_ptr_conv, val);
17363 }
17364
17365 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
17366         LDKRecord ret_var = Record_clone(arg);
17367 uintptr_t ret_ref = 0;
17368 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17369 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17370 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17371 ret_ref = (uintptr_t)ret_var.inner;
17372 if (ret_var.is_owned) {
17373         ret_ref |= 1;
17374 }
17375         return ret_ref;
17376 }
17377 intptr_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
17378         LDKRecord arg_conv;
17379         arg_conv.inner = (void*)(arg & (~1));
17380         arg_conv.is_owned = false;
17381         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17382         intptr_t ret_val = Record_clone_ptr(&arg_conv);
17383         return ret_val;
17384 }
17385
17386 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
17387         LDKRecord orig_conv;
17388         orig_conv.inner = (void*)(orig & (~1));
17389         orig_conv.is_owned = false;
17390         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17391         LDKRecord ret_var = Record_clone(&orig_conv);
17392         uintptr_t ret_ref = 0;
17393         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17394         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17396         ret_ref = (uintptr_t)ret_var.inner;
17397         if (ret_var.is_owned) {
17398                 ret_ref |= 1;
17399         }
17400         return ret_ref;
17401 }
17402
17403 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
17404         if ((this_ptr & 1) != 0) return;
17405         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
17406         CHECK_ACCESS(this_ptr_ptr);
17407         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
17408         FREE((void*)this_ptr);
17409         Logger_free(this_ptr_conv);
17410 }
17411
17412 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
17413         LDKChannelHandshakeConfig this_obj_conv;
17414         this_obj_conv.inner = (void*)(this_obj & (~1));
17415         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17417         ChannelHandshakeConfig_free(this_obj_conv);
17418 }
17419
17420 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
17421         LDKChannelHandshakeConfig this_ptr_conv;
17422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17423         this_ptr_conv.is_owned = false;
17424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17425         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
17426         return ret_val;
17427 }
17428
17429 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
17430         LDKChannelHandshakeConfig this_ptr_conv;
17431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17432         this_ptr_conv.is_owned = false;
17433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17434         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
17435 }
17436
17437 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
17438         LDKChannelHandshakeConfig this_ptr_conv;
17439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17440         this_ptr_conv.is_owned = false;
17441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17442         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
17443         return ret_val;
17444 }
17445
17446 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) {
17447         LDKChannelHandshakeConfig this_ptr_conv;
17448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17449         this_ptr_conv.is_owned = false;
17450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17451         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
17452 }
17453
17454 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
17455         LDKChannelHandshakeConfig this_ptr_conv;
17456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17457         this_ptr_conv.is_owned = false;
17458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17459         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
17460         return ret_val;
17461 }
17462
17463 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) {
17464         LDKChannelHandshakeConfig this_ptr_conv;
17465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17466         this_ptr_conv.is_owned = false;
17467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17468         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
17469 }
17470
17471 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) {
17472         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
17473         uintptr_t ret_ref = 0;
17474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17477         ret_ref = (uintptr_t)ret_var.inner;
17478         if (ret_var.is_owned) {
17479                 ret_ref |= 1;
17480         }
17481         return ret_ref;
17482 }
17483
17484 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
17485         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
17486 uintptr_t ret_ref = 0;
17487 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17488 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17489 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17490 ret_ref = (uintptr_t)ret_var.inner;
17491 if (ret_var.is_owned) {
17492         ret_ref |= 1;
17493 }
17494         return ret_ref;
17495 }
17496 intptr_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
17497         LDKChannelHandshakeConfig arg_conv;
17498         arg_conv.inner = (void*)(arg & (~1));
17499         arg_conv.is_owned = false;
17500         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17501         intptr_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
17502         return ret_val;
17503 }
17504
17505 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
17506         LDKChannelHandshakeConfig orig_conv;
17507         orig_conv.inner = (void*)(orig & (~1));
17508         orig_conv.is_owned = false;
17509         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17510         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
17511         uintptr_t ret_ref = 0;
17512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17515         ret_ref = (uintptr_t)ret_var.inner;
17516         if (ret_var.is_owned) {
17517                 ret_ref |= 1;
17518         }
17519         return ret_ref;
17520 }
17521
17522 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
17523         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
17524         uintptr_t ret_ref = 0;
17525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17528         ret_ref = (uintptr_t)ret_var.inner;
17529         if (ret_var.is_owned) {
17530                 ret_ref |= 1;
17531         }
17532         return ret_ref;
17533 }
17534
17535 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
17536         LDKChannelHandshakeLimits this_obj_conv;
17537         this_obj_conv.inner = (void*)(this_obj & (~1));
17538         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17540         ChannelHandshakeLimits_free(this_obj_conv);
17541 }
17542
17543 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
17544         LDKChannelHandshakeLimits this_ptr_conv;
17545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17546         this_ptr_conv.is_owned = false;
17547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17548         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
17549         return ret_val;
17550 }
17551
17552 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
17553         LDKChannelHandshakeLimits this_ptr_conv;
17554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17555         this_ptr_conv.is_owned = false;
17556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17557         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
17558 }
17559
17560 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
17561         LDKChannelHandshakeLimits this_ptr_conv;
17562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17563         this_ptr_conv.is_owned = false;
17564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17565         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
17566         return ret_val;
17567 }
17568
17569 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) {
17570         LDKChannelHandshakeLimits this_ptr_conv;
17571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17572         this_ptr_conv.is_owned = false;
17573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17574         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
17575 }
17576
17577 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) {
17578         LDKChannelHandshakeLimits this_ptr_conv;
17579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17580         this_ptr_conv.is_owned = false;
17581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17582         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
17583         return ret_val;
17584 }
17585
17586 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) {
17587         LDKChannelHandshakeLimits this_ptr_conv;
17588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17589         this_ptr_conv.is_owned = false;
17590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17591         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
17592 }
17593
17594 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
17595         LDKChannelHandshakeLimits this_ptr_conv;
17596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17597         this_ptr_conv.is_owned = false;
17598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17599         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
17600         return ret_val;
17601 }
17602
17603 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) {
17604         LDKChannelHandshakeLimits this_ptr_conv;
17605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17606         this_ptr_conv.is_owned = false;
17607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17608         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
17609 }
17610
17611 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
17612         LDKChannelHandshakeLimits this_ptr_conv;
17613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17614         this_ptr_conv.is_owned = false;
17615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17616         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
17617         return ret_val;
17618 }
17619
17620 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) {
17621         LDKChannelHandshakeLimits this_ptr_conv;
17622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17623         this_ptr_conv.is_owned = false;
17624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17625         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
17626 }
17627
17628 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
17629         LDKChannelHandshakeLimits this_ptr_conv;
17630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17631         this_ptr_conv.is_owned = false;
17632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17633         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
17634         return ret_val;
17635 }
17636
17637 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
17638         LDKChannelHandshakeLimits this_ptr_conv;
17639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17640         this_ptr_conv.is_owned = false;
17641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17642         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
17643 }
17644
17645 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
17646         LDKChannelHandshakeLimits this_ptr_conv;
17647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17648         this_ptr_conv.is_owned = false;
17649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17650         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
17651         return ret_val;
17652 }
17653
17654 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
17655         LDKChannelHandshakeLimits this_ptr_conv;
17656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17657         this_ptr_conv.is_owned = false;
17658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17659         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
17660 }
17661
17662 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
17663         LDKChannelHandshakeLimits this_ptr_conv;
17664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17665         this_ptr_conv.is_owned = false;
17666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17667         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
17668         return ret_val;
17669 }
17670
17671 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) {
17672         LDKChannelHandshakeLimits this_ptr_conv;
17673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17674         this_ptr_conv.is_owned = false;
17675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17676         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
17677 }
17678
17679 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) {
17680         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);
17681         uintptr_t ret_ref = 0;
17682         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17683         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17685         ret_ref = (uintptr_t)ret_var.inner;
17686         if (ret_var.is_owned) {
17687                 ret_ref |= 1;
17688         }
17689         return ret_ref;
17690 }
17691
17692 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
17693         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
17694 uintptr_t ret_ref = 0;
17695 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17696 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17697 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17698 ret_ref = (uintptr_t)ret_var.inner;
17699 if (ret_var.is_owned) {
17700         ret_ref |= 1;
17701 }
17702         return ret_ref;
17703 }
17704 intptr_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
17705         LDKChannelHandshakeLimits arg_conv;
17706         arg_conv.inner = (void*)(arg & (~1));
17707         arg_conv.is_owned = false;
17708         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17709         intptr_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
17710         return ret_val;
17711 }
17712
17713 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
17714         LDKChannelHandshakeLimits orig_conv;
17715         orig_conv.inner = (void*)(orig & (~1));
17716         orig_conv.is_owned = false;
17717         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17718         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
17719         uintptr_t ret_ref = 0;
17720         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17721         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17723         ret_ref = (uintptr_t)ret_var.inner;
17724         if (ret_var.is_owned) {
17725                 ret_ref |= 1;
17726         }
17727         return ret_ref;
17728 }
17729
17730 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
17731         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
17732         uintptr_t ret_ref = 0;
17733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17736         ret_ref = (uintptr_t)ret_var.inner;
17737         if (ret_var.is_owned) {
17738                 ret_ref |= 1;
17739         }
17740         return ret_ref;
17741 }
17742
17743 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
17744         LDKChannelConfig this_obj_conv;
17745         this_obj_conv.inner = (void*)(this_obj & (~1));
17746         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17748         ChannelConfig_free(this_obj_conv);
17749 }
17750
17751 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
17752         LDKChannelConfig this_ptr_conv;
17753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17754         this_ptr_conv.is_owned = false;
17755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17756         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
17757         return ret_val;
17758 }
17759
17760 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) {
17761         LDKChannelConfig this_ptr_conv;
17762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17763         this_ptr_conv.is_owned = false;
17764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17765         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
17766 }
17767
17768 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
17769         LDKChannelConfig this_ptr_conv;
17770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17771         this_ptr_conv.is_owned = false;
17772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17773         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
17774         return ret_val;
17775 }
17776
17777 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) {
17778         LDKChannelConfig this_ptr_conv;
17779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17780         this_ptr_conv.is_owned = false;
17781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17782         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
17783 }
17784
17785 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
17786         LDKChannelConfig this_ptr_conv;
17787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17788         this_ptr_conv.is_owned = false;
17789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17790         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
17791         return ret_val;
17792 }
17793
17794 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
17795         LDKChannelConfig this_ptr_conv;
17796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17797         this_ptr_conv.is_owned = false;
17798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17799         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
17800 }
17801
17802 jboolean  __attribute__((export_name("TS_ChannelConfig_get_announced_channel"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
17803         LDKChannelConfig this_ptr_conv;
17804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17805         this_ptr_conv.is_owned = false;
17806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17807         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
17808         return ret_val;
17809 }
17810
17811 void  __attribute__((export_name("TS_ChannelConfig_set_announced_channel"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
17812         LDKChannelConfig this_ptr_conv;
17813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17814         this_ptr_conv.is_owned = false;
17815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17816         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
17817 }
17818
17819 jboolean  __attribute__((export_name("TS_ChannelConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
17820         LDKChannelConfig this_ptr_conv;
17821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17822         this_ptr_conv.is_owned = false;
17823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17824         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
17825         return ret_val;
17826 }
17827
17828 void  __attribute__((export_name("TS_ChannelConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
17829         LDKChannelConfig this_ptr_conv;
17830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17831         this_ptr_conv.is_owned = false;
17832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17833         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
17834 }
17835
17836 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) {
17837         LDKChannelConfig this_ptr_conv;
17838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17839         this_ptr_conv.is_owned = false;
17840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17841         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
17842         return ret_val;
17843 }
17844
17845 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) {
17846         LDKChannelConfig this_ptr_conv;
17847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17848         this_ptr_conv.is_owned = false;
17849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17850         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
17851 }
17852
17853 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) {
17854         LDKChannelConfig this_ptr_conv;
17855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17856         this_ptr_conv.is_owned = false;
17857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17858         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
17859         return ret_val;
17860 }
17861
17862 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) {
17863         LDKChannelConfig this_ptr_conv;
17864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17865         this_ptr_conv.is_owned = false;
17866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17867         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
17868 }
17869
17870 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) {
17871         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);
17872         uintptr_t ret_ref = 0;
17873         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17874         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17876         ret_ref = (uintptr_t)ret_var.inner;
17877         if (ret_var.is_owned) {
17878                 ret_ref |= 1;
17879         }
17880         return ret_ref;
17881 }
17882
17883 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
17884         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
17885 uintptr_t ret_ref = 0;
17886 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17887 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17888 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17889 ret_ref = (uintptr_t)ret_var.inner;
17890 if (ret_var.is_owned) {
17891         ret_ref |= 1;
17892 }
17893         return ret_ref;
17894 }
17895 intptr_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
17896         LDKChannelConfig arg_conv;
17897         arg_conv.inner = (void*)(arg & (~1));
17898         arg_conv.is_owned = false;
17899         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
17900         intptr_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
17901         return ret_val;
17902 }
17903
17904 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
17905         LDKChannelConfig orig_conv;
17906         orig_conv.inner = (void*)(orig & (~1));
17907         orig_conv.is_owned = false;
17908         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
17909         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
17910         uintptr_t ret_ref = 0;
17911         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17912         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17914         ret_ref = (uintptr_t)ret_var.inner;
17915         if (ret_var.is_owned) {
17916                 ret_ref |= 1;
17917         }
17918         return ret_ref;
17919 }
17920
17921 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
17922         LDKChannelConfig ret_var = ChannelConfig_default();
17923         uintptr_t ret_ref = 0;
17924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17927         ret_ref = (uintptr_t)ret_var.inner;
17928         if (ret_var.is_owned) {
17929                 ret_ref |= 1;
17930         }
17931         return ret_ref;
17932 }
17933
17934 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
17935         LDKChannelConfig obj_conv;
17936         obj_conv.inner = (void*)(obj & (~1));
17937         obj_conv.is_owned = false;
17938         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
17939         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
17940         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
17941         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
17942         CVec_u8Z_free(ret_var);
17943         return ret_arr;
17944 }
17945
17946 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
17947         LDKu8slice ser_ref;
17948         ser_ref.datalen = ser->arr_len;
17949         ser_ref.data = ser->elems /* XXX ser leaks */;
17950         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
17951         *ret_conv = ChannelConfig_read(ser_ref);
17952         return (uintptr_t)ret_conv;
17953 }
17954
17955 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
17956         LDKUserConfig this_obj_conv;
17957         this_obj_conv.inner = (void*)(this_obj & (~1));
17958         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
17959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
17960         UserConfig_free(this_obj_conv);
17961 }
17962
17963 uint32_t  __attribute__((export_name("TS_UserConfig_get_own_channel_config"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
17964         LDKUserConfig this_ptr_conv;
17965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17966         this_ptr_conv.is_owned = false;
17967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17968         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
17969         uintptr_t ret_ref = 0;
17970         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
17971         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
17972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
17973         ret_ref = (uintptr_t)ret_var.inner;
17974         if (ret_var.is_owned) {
17975                 ret_ref |= 1;
17976         }
17977         return ret_ref;
17978 }
17979
17980 void  __attribute__((export_name("TS_UserConfig_set_own_channel_config"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
17981         LDKUserConfig this_ptr_conv;
17982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17983         this_ptr_conv.is_owned = false;
17984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17985         LDKChannelHandshakeConfig val_conv;
17986         val_conv.inner = (void*)(val & (~1));
17987         val_conv.is_owned = (val & 1) || (val == 0);
17988         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
17989         val_conv = ChannelHandshakeConfig_clone(&val_conv);
17990         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
17991 }
17992
17993 uint32_t  __attribute__((export_name("TS_UserConfig_get_peer_channel_config_limits"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
17994         LDKUserConfig this_ptr_conv;
17995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
17996         this_ptr_conv.is_owned = false;
17997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
17998         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
17999         uintptr_t ret_ref = 0;
18000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18003         ret_ref = (uintptr_t)ret_var.inner;
18004         if (ret_var.is_owned) {
18005                 ret_ref |= 1;
18006         }
18007         return ret_ref;
18008 }
18009
18010 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) {
18011         LDKUserConfig this_ptr_conv;
18012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18013         this_ptr_conv.is_owned = false;
18014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18015         LDKChannelHandshakeLimits val_conv;
18016         val_conv.inner = (void*)(val & (~1));
18017         val_conv.is_owned = (val & 1) || (val == 0);
18018         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
18019         val_conv = ChannelHandshakeLimits_clone(&val_conv);
18020         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
18021 }
18022
18023 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_options"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
18024         LDKUserConfig this_ptr_conv;
18025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18026         this_ptr_conv.is_owned = false;
18027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18028         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
18029         uintptr_t ret_ref = 0;
18030         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18031         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18033         ret_ref = (uintptr_t)ret_var.inner;
18034         if (ret_var.is_owned) {
18035                 ret_ref |= 1;
18036         }
18037         return ret_ref;
18038 }
18039
18040 void  __attribute__((export_name("TS_UserConfig_set_channel_options"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
18041         LDKUserConfig this_ptr_conv;
18042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18043         this_ptr_conv.is_owned = false;
18044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18045         LDKChannelConfig val_conv;
18046         val_conv.inner = (void*)(val & (~1));
18047         val_conv.is_owned = (val & 1) || (val == 0);
18048         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
18049         val_conv = ChannelConfig_clone(&val_conv);
18050         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
18051 }
18052
18053 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
18054         LDKUserConfig this_ptr_conv;
18055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18056         this_ptr_conv.is_owned = false;
18057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18058         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
18059         return ret_val;
18060 }
18061
18062 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) {
18063         LDKUserConfig this_ptr_conv;
18064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18065         this_ptr_conv.is_owned = false;
18066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18067         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
18068 }
18069
18070 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
18071         LDKUserConfig this_ptr_conv;
18072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18073         this_ptr_conv.is_owned = false;
18074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18075         jboolean ret_val = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
18076         return ret_val;
18077 }
18078
18079 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
18080         LDKUserConfig this_ptr_conv;
18081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18082         this_ptr_conv.is_owned = false;
18083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18084         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
18085 }
18086
18087 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) {
18088         LDKChannelHandshakeConfig own_channel_config_arg_conv;
18089         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
18090         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
18091         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
18092         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
18093         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
18094         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
18095         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
18096         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
18097         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
18098         LDKChannelConfig channel_options_arg_conv;
18099         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
18100         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
18101         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
18102         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
18103         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);
18104         uintptr_t ret_ref = 0;
18105         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18106         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18108         ret_ref = (uintptr_t)ret_var.inner;
18109         if (ret_var.is_owned) {
18110                 ret_ref |= 1;
18111         }
18112         return ret_ref;
18113 }
18114
18115 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
18116         LDKUserConfig ret_var = UserConfig_clone(arg);
18117 uintptr_t ret_ref = 0;
18118 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18119 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18120 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18121 ret_ref = (uintptr_t)ret_var.inner;
18122 if (ret_var.is_owned) {
18123         ret_ref |= 1;
18124 }
18125         return ret_ref;
18126 }
18127 intptr_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
18128         LDKUserConfig arg_conv;
18129         arg_conv.inner = (void*)(arg & (~1));
18130         arg_conv.is_owned = false;
18131         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18132         intptr_t ret_val = UserConfig_clone_ptr(&arg_conv);
18133         return ret_val;
18134 }
18135
18136 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
18137         LDKUserConfig orig_conv;
18138         orig_conv.inner = (void*)(orig & (~1));
18139         orig_conv.is_owned = false;
18140         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18141         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
18142         uintptr_t ret_ref = 0;
18143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18146         ret_ref = (uintptr_t)ret_var.inner;
18147         if (ret_var.is_owned) {
18148                 ret_ref |= 1;
18149         }
18150         return ret_ref;
18151 }
18152
18153 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
18154         LDKUserConfig ret_var = UserConfig_default();
18155         uintptr_t ret_ref = 0;
18156         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18157         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18159         ret_ref = (uintptr_t)ret_var.inner;
18160         if (ret_var.is_owned) {
18161                 ret_ref |= 1;
18162         }
18163         return ret_ref;
18164 }
18165
18166 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
18167         LDKBestBlock this_obj_conv;
18168         this_obj_conv.inner = (void*)(this_obj & (~1));
18169         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18171         BestBlock_free(this_obj_conv);
18172 }
18173
18174 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
18175         LDKBestBlock ret_var = BestBlock_clone(arg);
18176 uintptr_t ret_ref = 0;
18177 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18178 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18179 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18180 ret_ref = (uintptr_t)ret_var.inner;
18181 if (ret_var.is_owned) {
18182         ret_ref |= 1;
18183 }
18184         return ret_ref;
18185 }
18186 intptr_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
18187         LDKBestBlock arg_conv;
18188         arg_conv.inner = (void*)(arg & (~1));
18189         arg_conv.is_owned = false;
18190         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18191         intptr_t ret_val = BestBlock_clone_ptr(&arg_conv);
18192         return ret_val;
18193 }
18194
18195 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
18196         LDKBestBlock orig_conv;
18197         orig_conv.inner = (void*)(orig & (~1));
18198         orig_conv.is_owned = false;
18199         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18200         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
18201         uintptr_t ret_ref = 0;
18202         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18203         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18205         ret_ref = (uintptr_t)ret_var.inner;
18206         if (ret_var.is_owned) {
18207                 ret_ref |= 1;
18208         }
18209         return ret_ref;
18210 }
18211
18212 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
18213         LDKNetwork network_conv = LDKNetwork_from_js(network);
18214         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
18215         uintptr_t ret_ref = 0;
18216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18219         ret_ref = (uintptr_t)ret_var.inner;
18220         if (ret_var.is_owned) {
18221                 ret_ref |= 1;
18222         }
18223         return ret_ref;
18224 }
18225
18226 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
18227         LDKThirtyTwoBytes block_hash_ref;
18228         CHECK(block_hash->arr_len == 32);
18229         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
18230         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
18231         uintptr_t ret_ref = 0;
18232         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18233         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18235         ret_ref = (uintptr_t)ret_var.inner;
18236         if (ret_var.is_owned) {
18237                 ret_ref |= 1;
18238         }
18239         return ret_ref;
18240 }
18241
18242 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
18243         LDKBestBlock this_arg_conv;
18244         this_arg_conv.inner = (void*)(this_arg & (~1));
18245         this_arg_conv.is_owned = false;
18246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18247         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
18248         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
18249         return ret_arr;
18250 }
18251
18252 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
18253         LDKBestBlock this_arg_conv;
18254         this_arg_conv.inner = (void*)(this_arg & (~1));
18255         this_arg_conv.is_owned = false;
18256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18257         int32_t ret_val = BestBlock_height(&this_arg_conv);
18258         return ret_val;
18259 }
18260
18261 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
18262         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
18263         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
18264         return ret_conv;
18265 }
18266
18267 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
18268         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
18269         return ret_conv;
18270 }
18271
18272 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
18273         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
18274         return ret_conv;
18275 }
18276
18277 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
18278         if ((this_ptr & 1) != 0) return;
18279         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18280         CHECK_ACCESS(this_ptr_ptr);
18281         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
18282         FREE((void*)this_ptr);
18283         Access_free(this_ptr_conv);
18284 }
18285
18286 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
18287         if ((this_ptr & 1) != 0) return;
18288         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18289         CHECK_ACCESS(this_ptr_ptr);
18290         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
18291         FREE((void*)this_ptr);
18292         Listen_free(this_ptr_conv);
18293 }
18294
18295 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
18296         if ((this_ptr & 1) != 0) return;
18297         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18298         CHECK_ACCESS(this_ptr_ptr);
18299         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
18300         FREE((void*)this_ptr);
18301         Confirm_free(this_ptr_conv);
18302 }
18303
18304 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
18305         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
18306         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
18307         return ret_conv;
18308 }
18309
18310 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
18311         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
18312         return ret_conv;
18313 }
18314
18315 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
18316         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
18317         return ret_conv;
18318 }
18319
18320 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
18321         if ((this_ptr & 1) != 0) return;
18322         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18323         CHECK_ACCESS(this_ptr_ptr);
18324         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
18325         FREE((void*)this_ptr);
18326         Watch_free(this_ptr_conv);
18327 }
18328
18329 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
18330         if ((this_ptr & 1) != 0) return;
18331         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18332         CHECK_ACCESS(this_ptr_ptr);
18333         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
18334         FREE((void*)this_ptr);
18335         Filter_free(this_ptr_conv);
18336 }
18337
18338 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
18339         LDKWatchedOutput this_obj_conv;
18340         this_obj_conv.inner = (void*)(this_obj & (~1));
18341         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18343         WatchedOutput_free(this_obj_conv);
18344 }
18345
18346 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
18347         LDKWatchedOutput this_ptr_conv;
18348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18349         this_ptr_conv.is_owned = false;
18350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18351         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
18352         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
18353         return ret_arr;
18354 }
18355
18356 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
18357         LDKWatchedOutput this_ptr_conv;
18358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18359         this_ptr_conv.is_owned = false;
18360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18361         LDKThirtyTwoBytes val_ref;
18362         CHECK(val->arr_len == 32);
18363         memcpy(val_ref.data, val->elems, 32); FREE(val);
18364         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
18365 }
18366
18367 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
18368         LDKWatchedOutput this_ptr_conv;
18369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18370         this_ptr_conv.is_owned = false;
18371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18372         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
18373         uintptr_t ret_ref = 0;
18374         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18375         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18377         ret_ref = (uintptr_t)ret_var.inner;
18378         if (ret_var.is_owned) {
18379                 ret_ref |= 1;
18380         }
18381         return ret_ref;
18382 }
18383
18384 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
18385         LDKWatchedOutput this_ptr_conv;
18386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18387         this_ptr_conv.is_owned = false;
18388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18389         LDKOutPoint val_conv;
18390         val_conv.inner = (void*)(val & (~1));
18391         val_conv.is_owned = (val & 1) || (val == 0);
18392         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
18393         val_conv = OutPoint_clone(&val_conv);
18394         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
18395 }
18396
18397 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
18398         LDKWatchedOutput this_ptr_conv;
18399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18400         this_ptr_conv.is_owned = false;
18401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18402         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
18403         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
18404         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
18405         return ret_arr;
18406 }
18407
18408 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
18409         LDKWatchedOutput this_ptr_conv;
18410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18411         this_ptr_conv.is_owned = false;
18412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18413         LDKCVec_u8Z val_ref;
18414         val_ref.datalen = val->arr_len;
18415         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
18416         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
18417         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
18418 }
18419
18420 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) {
18421         LDKThirtyTwoBytes block_hash_arg_ref;
18422         CHECK(block_hash_arg->arr_len == 32);
18423         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
18424         LDKOutPoint outpoint_arg_conv;
18425         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
18426         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
18427         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
18428         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
18429         LDKCVec_u8Z script_pubkey_arg_ref;
18430         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
18431         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
18432         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
18433         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
18434         uintptr_t ret_ref = 0;
18435         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18436         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18438         ret_ref = (uintptr_t)ret_var.inner;
18439         if (ret_var.is_owned) {
18440                 ret_ref |= 1;
18441         }
18442         return ret_ref;
18443 }
18444
18445 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
18446         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
18447 uintptr_t ret_ref = 0;
18448 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18449 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18450 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18451 ret_ref = (uintptr_t)ret_var.inner;
18452 if (ret_var.is_owned) {
18453         ret_ref |= 1;
18454 }
18455         return ret_ref;
18456 }
18457 intptr_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
18458         LDKWatchedOutput arg_conv;
18459         arg_conv.inner = (void*)(arg & (~1));
18460         arg_conv.is_owned = false;
18461         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18462         intptr_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
18463         return ret_val;
18464 }
18465
18466 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
18467         LDKWatchedOutput orig_conv;
18468         orig_conv.inner = (void*)(orig & (~1));
18469         orig_conv.is_owned = false;
18470         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18471         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
18472         uintptr_t ret_ref = 0;
18473         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18474         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18476         ret_ref = (uintptr_t)ret_var.inner;
18477         if (ret_var.is_owned) {
18478                 ret_ref |= 1;
18479         }
18480         return ret_ref;
18481 }
18482
18483 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
18484         LDKWatchedOutput o_conv;
18485         o_conv.inner = (void*)(o & (~1));
18486         o_conv.is_owned = false;
18487         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18488         int64_t ret_val = WatchedOutput_hash(&o_conv);
18489         return ret_val;
18490 }
18491
18492 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
18493         if ((this_ptr & 1) != 0) return;
18494         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18495         CHECK_ACCESS(this_ptr_ptr);
18496         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
18497         FREE((void*)this_ptr);
18498         BroadcasterInterface_free(this_ptr_conv);
18499 }
18500
18501 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
18502         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
18503         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
18504         return ret_conv;
18505 }
18506
18507 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
18508         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
18509         return ret_conv;
18510 }
18511
18512 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
18513         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
18514         return ret_conv;
18515 }
18516
18517 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
18518         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
18519         return ret_conv;
18520 }
18521
18522 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
18523         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
18524         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
18525         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
18526         return ret_val;
18527 }
18528
18529 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
18530         if ((this_ptr & 1) != 0) return;
18531         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18532         CHECK_ACCESS(this_ptr_ptr);
18533         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
18534         FREE((void*)this_ptr);
18535         FeeEstimator_free(this_ptr_conv);
18536 }
18537
18538 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
18539         LDKMonitorUpdateId this_obj_conv;
18540         this_obj_conv.inner = (void*)(this_obj & (~1));
18541         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18543         MonitorUpdateId_free(this_obj_conv);
18544 }
18545
18546 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
18547         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
18548 uintptr_t ret_ref = 0;
18549 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18550 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18551 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18552 ret_ref = (uintptr_t)ret_var.inner;
18553 if (ret_var.is_owned) {
18554         ret_ref |= 1;
18555 }
18556         return ret_ref;
18557 }
18558 intptr_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
18559         LDKMonitorUpdateId arg_conv;
18560         arg_conv.inner = (void*)(arg & (~1));
18561         arg_conv.is_owned = false;
18562         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18563         intptr_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
18564         return ret_val;
18565 }
18566
18567 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
18568         LDKMonitorUpdateId orig_conv;
18569         orig_conv.inner = (void*)(orig & (~1));
18570         orig_conv.is_owned = false;
18571         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18572         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
18573         uintptr_t ret_ref = 0;
18574         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18575         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18577         ret_ref = (uintptr_t)ret_var.inner;
18578         if (ret_var.is_owned) {
18579                 ret_ref |= 1;
18580         }
18581         return ret_ref;
18582 }
18583
18584 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
18585         LDKMonitorUpdateId o_conv;
18586         o_conv.inner = (void*)(o & (~1));
18587         o_conv.is_owned = false;
18588         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18589         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
18590         return ret_val;
18591 }
18592
18593 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
18594         LDKMonitorUpdateId a_conv;
18595         a_conv.inner = (void*)(a & (~1));
18596         a_conv.is_owned = false;
18597         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18598         LDKMonitorUpdateId b_conv;
18599         b_conv.inner = (void*)(b & (~1));
18600         b_conv.is_owned = false;
18601         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18602         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
18603         return ret_val;
18604 }
18605
18606 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
18607         if ((this_ptr & 1) != 0) return;
18608         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18609         CHECK_ACCESS(this_ptr_ptr);
18610         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
18611         FREE((void*)this_ptr);
18612         Persist_free(this_ptr_conv);
18613 }
18614
18615 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
18616         LDKLockedChannelMonitor this_obj_conv;
18617         this_obj_conv.inner = (void*)(this_obj & (~1));
18618         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18620         LockedChannelMonitor_free(this_obj_conv);
18621 }
18622
18623 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
18624         LDKChainMonitor this_obj_conv;
18625         this_obj_conv.inner = (void*)(this_obj & (~1));
18626         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18628         ChainMonitor_free(this_obj_conv);
18629 }
18630
18631 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) {
18632         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
18633         CHECK_ACCESS(chain_source_ptr);
18634         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
18635         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
18636         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
18637                 // Manually implement clone for Java trait instances
18638         }
18639         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
18640         CHECK_ACCESS(broadcaster_ptr);
18641         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
18642         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
18643         CHECK_ACCESS(logger_ptr);
18644         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
18645         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
18646         CHECK_ACCESS(feeest_ptr);
18647         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
18648         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
18649         CHECK_ACCESS(persister_ptr);
18650         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
18651         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
18652         uintptr_t ret_ref = 0;
18653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18656         ret_ref = (uintptr_t)ret_var.inner;
18657         if (ret_var.is_owned) {
18658                 ret_ref |= 1;
18659         }
18660         return ret_ref;
18661 }
18662
18663 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
18664         LDKChainMonitor this_arg_conv;
18665         this_arg_conv.inner = (void*)(this_arg & (~1));
18666         this_arg_conv.is_owned = false;
18667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18668         LDKCVec_ChannelDetailsZ ignored_channels_constr;
18669         ignored_channels_constr.datalen = ignored_channels->arr_len;
18670         if (ignored_channels_constr.datalen > 0)
18671                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
18672         else
18673                 ignored_channels_constr.data = NULL;
18674         uint32_t* ignored_channels_vals = ignored_channels->elems /* XXX ignored_channels leaks */;
18675         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
18676                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
18677                 LDKChannelDetails ignored_channels_conv_16_conv;
18678                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
18679                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
18680                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
18681                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
18682                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
18683         }
18684         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
18685         uint32_tArray ret_arr = NULL;
18686         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
18687         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
18688         for (size_t j = 0; j < ret_var.datalen; j++) {
18689                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
18690                 *ret_conv_9_copy = ret_var.data[j];
18691                 uintptr_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
18692                 ret_arr_ptr[j] = ret_conv_9_ref;
18693         }
18694         
18695         FREE(ret_var.data);
18696         return ret_arr;
18697 }
18698
18699 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
18700         LDKChainMonitor this_arg_conv;
18701         this_arg_conv.inner = (void*)(this_arg & (~1));
18702         this_arg_conv.is_owned = false;
18703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18704         LDKOutPoint funding_txo_conv;
18705         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18706         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18707         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18708         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18709         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
18710         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
18711         return (uintptr_t)ret_conv;
18712 }
18713
18714 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
18715         LDKChainMonitor this_arg_conv;
18716         this_arg_conv.inner = (void*)(this_arg & (~1));
18717         this_arg_conv.is_owned = false;
18718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18719         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
18720         uint32_tArray ret_arr = NULL;
18721         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
18722         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
18723         for (size_t k = 0; k < ret_var.datalen; k++) {
18724                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
18725                 uintptr_t ret_conv_10_ref = 0;
18726                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18727                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18728                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
18729                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
18730                 if (ret_conv_10_var.is_owned) {
18731                         ret_conv_10_ref |= 1;
18732                 }
18733                 ret_arr_ptr[k] = ret_conv_10_ref;
18734         }
18735         
18736         FREE(ret_var.data);
18737         return ret_arr;
18738 }
18739
18740 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) {
18741         LDKChainMonitor this_arg_conv;
18742         this_arg_conv.inner = (void*)(this_arg & (~1));
18743         this_arg_conv.is_owned = false;
18744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18745         LDKOutPoint funding_txo_conv;
18746         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18747         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18748         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18749         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18750         LDKMonitorUpdateId completed_update_id_conv;
18751         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
18752         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
18753         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
18754         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
18755         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
18756         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
18757         return (uintptr_t)ret_conv;
18758 }
18759
18760 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
18761         LDKChainMonitor this_arg_conv;
18762         this_arg_conv.inner = (void*)(this_arg & (~1));
18763         this_arg_conv.is_owned = false;
18764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18765         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
18766         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
18767         return (uintptr_t)ret_ret;
18768 }
18769
18770 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
18771         LDKChainMonitor this_arg_conv;
18772         this_arg_conv.inner = (void*)(this_arg & (~1));
18773         this_arg_conv.is_owned = false;
18774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18775         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
18776         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
18777         return (uintptr_t)ret_ret;
18778 }
18779
18780 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
18781         LDKChainMonitor this_arg_conv;
18782         this_arg_conv.inner = (void*)(this_arg & (~1));
18783         this_arg_conv.is_owned = false;
18784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18785         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
18786         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
18787         return (uintptr_t)ret_ret;
18788 }
18789
18790 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
18791         LDKChainMonitor this_arg_conv;
18792         this_arg_conv.inner = (void*)(this_arg & (~1));
18793         this_arg_conv.is_owned = false;
18794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
18795         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
18796         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
18797         return (uintptr_t)ret_ret;
18798 }
18799
18800 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
18801         LDKChannelMonitorUpdate this_obj_conv;
18802         this_obj_conv.inner = (void*)(this_obj & (~1));
18803         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18805         ChannelMonitorUpdate_free(this_obj_conv);
18806 }
18807
18808 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
18809         LDKChannelMonitorUpdate this_ptr_conv;
18810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18811         this_ptr_conv.is_owned = false;
18812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18813         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
18814         return ret_val;
18815 }
18816
18817 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
18818         LDKChannelMonitorUpdate this_ptr_conv;
18819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
18820         this_ptr_conv.is_owned = false;
18821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
18822         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
18823 }
18824
18825 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
18826         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
18827 uintptr_t ret_ref = 0;
18828 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18829 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18830 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18831 ret_ref = (uintptr_t)ret_var.inner;
18832 if (ret_var.is_owned) {
18833         ret_ref |= 1;
18834 }
18835         return ret_ref;
18836 }
18837 intptr_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
18838         LDKChannelMonitorUpdate arg_conv;
18839         arg_conv.inner = (void*)(arg & (~1));
18840         arg_conv.is_owned = false;
18841         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
18842         intptr_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
18843         return ret_val;
18844 }
18845
18846 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
18847         LDKChannelMonitorUpdate orig_conv;
18848         orig_conv.inner = (void*)(orig & (~1));
18849         orig_conv.is_owned = false;
18850         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
18851         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
18852         uintptr_t ret_ref = 0;
18853         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18854         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18856         ret_ref = (uintptr_t)ret_var.inner;
18857         if (ret_var.is_owned) {
18858                 ret_ref |= 1;
18859         }
18860         return ret_ref;
18861 }
18862
18863 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
18864         LDKChannelMonitorUpdate obj_conv;
18865         obj_conv.inner = (void*)(obj & (~1));
18866         obj_conv.is_owned = false;
18867         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
18868         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
18869         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
18870         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
18871         CVec_u8Z_free(ret_var);
18872         return ret_arr;
18873 }
18874
18875 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
18876         LDKu8slice ser_ref;
18877         ser_ref.datalen = ser->arr_len;
18878         ser_ref.data = ser->elems /* XXX ser leaks */;
18879         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
18880         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
18881         return (uintptr_t)ret_conv;
18882 }
18883
18884 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
18885         if ((this_ptr & 1) != 0) return;
18886         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
18887         CHECK_ACCESS(this_ptr_ptr);
18888         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
18889         FREE((void*)this_ptr);
18890         MonitorEvent_free(this_ptr_conv);
18891 }
18892
18893 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
18894         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18895         *ret_copy = MonitorEvent_clone(arg);
18896 uintptr_t ret_ref = (uintptr_t)ret_copy;
18897         return ret_ref;
18898 }
18899 intptr_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
18900         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
18901         intptr_t ret_val = MonitorEvent_clone_ptr(arg_conv);
18902         return ret_val;
18903 }
18904
18905 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
18906         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
18907         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18908         *ret_copy = MonitorEvent_clone(orig_conv);
18909         uintptr_t ret_ref = (uintptr_t)ret_copy;
18910         return ret_ref;
18911 }
18912
18913 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
18914         LDKHTLCUpdate a_conv;
18915         a_conv.inner = (void*)(a & (~1));
18916         a_conv.is_owned = (a & 1) || (a == 0);
18917         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18918         a_conv = HTLCUpdate_clone(&a_conv);
18919         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18920         *ret_copy = MonitorEvent_htlcevent(a_conv);
18921         uintptr_t ret_ref = (uintptr_t)ret_copy;
18922         return ret_ref;
18923 }
18924
18925 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
18926         LDKOutPoint a_conv;
18927         a_conv.inner = (void*)(a & (~1));
18928         a_conv.is_owned = (a & 1) || (a == 0);
18929         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18930         a_conv = OutPoint_clone(&a_conv);
18931         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18932         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
18933         uintptr_t ret_ref = (uintptr_t)ret_copy;
18934         return ret_ref;
18935 }
18936
18937 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
18938         LDKOutPoint funding_txo_conv;
18939         funding_txo_conv.inner = (void*)(funding_txo & (~1));
18940         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
18941         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
18942         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
18943         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18944         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
18945         uintptr_t ret_ref = (uintptr_t)ret_copy;
18946         return ret_ref;
18947 }
18948
18949 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
18950         LDKOutPoint a_conv;
18951         a_conv.inner = (void*)(a & (~1));
18952         a_conv.is_owned = (a & 1) || (a == 0);
18953         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18954         a_conv = OutPoint_clone(&a_conv);
18955         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
18956         *ret_copy = MonitorEvent_update_failed(a_conv);
18957         uintptr_t ret_ref = (uintptr_t)ret_copy;
18958         return ret_ref;
18959 }
18960
18961 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
18962         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
18963         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
18964         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
18965         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
18966         CVec_u8Z_free(ret_var);
18967         return ret_arr;
18968 }
18969
18970 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
18971         LDKu8slice ser_ref;
18972         ser_ref.datalen = ser->arr_len;
18973         ser_ref.data = ser->elems /* XXX ser leaks */;
18974         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
18975         *ret_conv = MonitorEvent_read(ser_ref);
18976         return (uintptr_t)ret_conv;
18977 }
18978
18979 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
18980         LDKHTLCUpdate this_obj_conv;
18981         this_obj_conv.inner = (void*)(this_obj & (~1));
18982         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
18983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
18984         HTLCUpdate_free(this_obj_conv);
18985 }
18986
18987 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
18988         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
18989 uintptr_t ret_ref = 0;
18990 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
18991 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
18992 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
18993 ret_ref = (uintptr_t)ret_var.inner;
18994 if (ret_var.is_owned) {
18995         ret_ref |= 1;
18996 }
18997         return ret_ref;
18998 }
18999 intptr_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
19000         LDKHTLCUpdate arg_conv;
19001         arg_conv.inner = (void*)(arg & (~1));
19002         arg_conv.is_owned = false;
19003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19004         intptr_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
19005         return ret_val;
19006 }
19007
19008 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
19009         LDKHTLCUpdate orig_conv;
19010         orig_conv.inner = (void*)(orig & (~1));
19011         orig_conv.is_owned = false;
19012         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19013         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
19014         uintptr_t ret_ref = 0;
19015         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19016         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19018         ret_ref = (uintptr_t)ret_var.inner;
19019         if (ret_var.is_owned) {
19020                 ret_ref |= 1;
19021         }
19022         return ret_ref;
19023 }
19024
19025 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
19026         LDKHTLCUpdate obj_conv;
19027         obj_conv.inner = (void*)(obj & (~1));
19028         obj_conv.is_owned = false;
19029         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19030         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
19031         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19032         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19033         CVec_u8Z_free(ret_var);
19034         return ret_arr;
19035 }
19036
19037 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
19038         LDKu8slice ser_ref;
19039         ser_ref.datalen = ser->arr_len;
19040         ser_ref.data = ser->elems /* XXX ser leaks */;
19041         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
19042         *ret_conv = HTLCUpdate_read(ser_ref);
19043         return (uintptr_t)ret_conv;
19044 }
19045
19046 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
19047         if ((this_ptr & 1) != 0) return;
19048         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19049         CHECK_ACCESS(this_ptr_ptr);
19050         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
19051         FREE((void*)this_ptr);
19052         Balance_free(this_ptr_conv);
19053 }
19054
19055 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
19056         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19057         *ret_copy = Balance_clone(arg);
19058 uintptr_t ret_ref = (uintptr_t)ret_copy;
19059         return ret_ref;
19060 }
19061 intptr_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
19062         LDKBalance* arg_conv = (LDKBalance*)arg;
19063         intptr_t ret_val = Balance_clone_ptr(arg_conv);
19064         return ret_val;
19065 }
19066
19067 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
19068         LDKBalance* orig_conv = (LDKBalance*)orig;
19069         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19070         *ret_copy = Balance_clone(orig_conv);
19071         uintptr_t ret_ref = (uintptr_t)ret_copy;
19072         return ret_ref;
19073 }
19074
19075 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
19076         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19077         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
19078         uintptr_t ret_ref = (uintptr_t)ret_copy;
19079         return ret_ref;
19080 }
19081
19082 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
19083         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19084         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
19085         uintptr_t ret_ref = (uintptr_t)ret_copy;
19086         return ret_ref;
19087 }
19088
19089 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
19090         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19091         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
19092         uintptr_t ret_ref = (uintptr_t)ret_copy;
19093         return ret_ref;
19094 }
19095
19096 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) {
19097         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19098         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
19099         uintptr_t ret_ref = (uintptr_t)ret_copy;
19100         return ret_ref;
19101 }
19102
19103 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
19104         LDKBalance* a_conv = (LDKBalance*)a;
19105         LDKBalance* b_conv = (LDKBalance*)b;
19106         jboolean ret_val = Balance_eq(a_conv, b_conv);
19107         return ret_val;
19108 }
19109
19110 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
19111         LDKChannelMonitor this_obj_conv;
19112         this_obj_conv.inner = (void*)(this_obj & (~1));
19113         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19115         ChannelMonitor_free(this_obj_conv);
19116 }
19117
19118 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
19119         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
19120 uintptr_t ret_ref = 0;
19121 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19122 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19123 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19124 ret_ref = (uintptr_t)ret_var.inner;
19125 if (ret_var.is_owned) {
19126         ret_ref |= 1;
19127 }
19128         return ret_ref;
19129 }
19130 intptr_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
19131         LDKChannelMonitor arg_conv;
19132         arg_conv.inner = (void*)(arg & (~1));
19133         arg_conv.is_owned = false;
19134         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19135         intptr_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
19136         return ret_val;
19137 }
19138
19139 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
19140         LDKChannelMonitor orig_conv;
19141         orig_conv.inner = (void*)(orig & (~1));
19142         orig_conv.is_owned = false;
19143         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19144         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
19145         uintptr_t ret_ref = 0;
19146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19149         ret_ref = (uintptr_t)ret_var.inner;
19150         if (ret_var.is_owned) {
19151                 ret_ref |= 1;
19152         }
19153         return ret_ref;
19154 }
19155
19156 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
19157         LDKChannelMonitor obj_conv;
19158         obj_conv.inner = (void*)(obj & (~1));
19159         obj_conv.is_owned = false;
19160         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19161         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
19162         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19163         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19164         CVec_u8Z_free(ret_var);
19165         return ret_arr;
19166 }
19167
19168 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) {
19169         LDKChannelMonitor this_arg_conv;
19170         this_arg_conv.inner = (void*)(this_arg & (~1));
19171         this_arg_conv.is_owned = false;
19172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19173         LDKChannelMonitorUpdate updates_conv;
19174         updates_conv.inner = (void*)(updates & (~1));
19175         updates_conv.is_owned = false;
19176         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
19177         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
19178         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
19179         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
19180         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
19181         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
19182         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
19183         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19184         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
19185         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
19186         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
19187         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
19188         return (uintptr_t)ret_conv;
19189 }
19190
19191 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
19192         LDKChannelMonitor this_arg_conv;
19193         this_arg_conv.inner = (void*)(this_arg & (~1));
19194         this_arg_conv.is_owned = false;
19195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19196         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
19197         return ret_val;
19198 }
19199
19200 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
19201         LDKChannelMonitor this_arg_conv;
19202         this_arg_conv.inner = (void*)(this_arg & (~1));
19203         this_arg_conv.is_owned = false;
19204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19205         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
19206         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
19207         return ((uintptr_t)ret_conv);
19208 }
19209
19210 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
19211         LDKChannelMonitor this_arg_conv;
19212         this_arg_conv.inner = (void*)(this_arg & (~1));
19213         this_arg_conv.is_owned = false;
19214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19215         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
19216         uint32_tArray ret_arr = NULL;
19217         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19218         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19219         for (size_t o = 0; o < ret_var.datalen; o++) {
19220                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
19221                 *ret_conv_40_conv = ret_var.data[o];
19222                 ret_arr_ptr[o] = ((uintptr_t)ret_conv_40_conv);
19223         }
19224         
19225         FREE(ret_var.data);
19226         return ret_arr;
19227 }
19228
19229 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
19230         LDKChannelMonitor this_arg_conv;
19231         this_arg_conv.inner = (void*)(this_arg & (~1));
19232         this_arg_conv.is_owned = false;
19233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19234         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
19235         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
19236         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
19237         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
19238 }
19239
19240 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) {
19241         LDKChannelMonitor this_arg_conv;
19242         this_arg_conv.inner = (void*)(this_arg & (~1));
19243         this_arg_conv.is_owned = false;
19244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19245         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
19246         uint32_tArray ret_arr = NULL;
19247         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19248         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19249         for (size_t o = 0; o < ret_var.datalen; o++) {
19250                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
19251                 *ret_conv_14_copy = ret_var.data[o];
19252                 uintptr_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
19253                 ret_arr_ptr[o] = ret_conv_14_ref;
19254         }
19255         
19256         FREE(ret_var.data);
19257         return ret_arr;
19258 }
19259
19260 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
19261         LDKChannelMonitor this_arg_conv;
19262         this_arg_conv.inner = (void*)(this_arg & (~1));
19263         this_arg_conv.is_owned = false;
19264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19265         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
19266         uint32_tArray ret_arr = NULL;
19267         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19268         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19269         for (size_t h = 0; h < ret_var.datalen; h++) {
19270                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19271                 *ret_conv_7_copy = ret_var.data[h];
19272                 uintptr_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
19273                 ret_arr_ptr[h] = ret_conv_7_ref;
19274         }
19275         
19276         FREE(ret_var.data);
19277         return ret_arr;
19278 }
19279
19280 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) {
19281         LDKChannelMonitor this_arg_conv;
19282         this_arg_conv.inner = (void*)(this_arg & (~1));
19283         this_arg_conv.is_owned = false;
19284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19285         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19286         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
19287         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
19288         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
19289         ptrArray ret_arr = NULL;
19290         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
19291         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
19292         for (size_t m = 0; m < ret_var.datalen; m++) {
19293                 LDKTransaction ret_conv_12_var = ret_var.data[m];
19294                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
19295                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
19296                 Transaction_free(ret_conv_12_var);
19297                 ret_arr_ptr[m] = ret_conv_12_arr;
19298         }
19299         
19300         FREE(ret_var.data);
19301         return ret_arr;
19302 }
19303
19304 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) {
19305         LDKChannelMonitor this_arg_conv;
19306         this_arg_conv.inner = (void*)(this_arg & (~1));
19307         this_arg_conv.is_owned = false;
19308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19309         unsigned char header_arr[80];
19310         CHECK(header->arr_len == 80);
19311         memcpy(header_arr, header->elems, 80); FREE(header);
19312         unsigned char (*header_ref)[80] = &header_arr;
19313         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
19314         txdata_constr.datalen = txdata->arr_len;
19315         if (txdata_constr.datalen > 0)
19316                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
19317         else
19318                 txdata_constr.data = NULL;
19319         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
19320         for (size_t c = 0; c < txdata_constr.datalen; c++) {
19321                 uint32_t txdata_conv_28 = txdata_vals[c];
19322                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
19323                 CHECK_ACCESS(txdata_conv_28_ptr);
19324                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
19325                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
19326                 txdata_constr.data[c] = txdata_conv_28_conv;
19327         }
19328         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
19329         CHECK_ACCESS(broadcaster_ptr);
19330         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19331         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
19332         CHECK_ACCESS(fee_estimator_ptr);
19333         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19334         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19335         CHECK_ACCESS(logger_ptr);
19336         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19337         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);
19338         uint32_tArray ret_arr = NULL;
19339         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19340         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19341         for (size_t n = 0; n < ret_var.datalen; n++) {
19342                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19343                 *ret_conv_39_conv = ret_var.data[n];
19344                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
19345         }
19346         
19347         FREE(ret_var.data);
19348         return ret_arr;
19349 }
19350
19351 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) {
19352         LDKChannelMonitor this_arg_conv;
19353         this_arg_conv.inner = (void*)(this_arg & (~1));
19354         this_arg_conv.is_owned = false;
19355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19356         unsigned char header_arr[80];
19357         CHECK(header->arr_len == 80);
19358         memcpy(header_arr, header->elems, 80); FREE(header);
19359         unsigned char (*header_ref)[80] = &header_arr;
19360         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
19361         CHECK_ACCESS(broadcaster_ptr);
19362         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19363         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
19364         CHECK_ACCESS(fee_estimator_ptr);
19365         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19366         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19367         CHECK_ACCESS(logger_ptr);
19368         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19369         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
19370 }
19371
19372 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) {
19373         LDKChannelMonitor this_arg_conv;
19374         this_arg_conv.inner = (void*)(this_arg & (~1));
19375         this_arg_conv.is_owned = false;
19376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19377         unsigned char header_arr[80];
19378         CHECK(header->arr_len == 80);
19379         memcpy(header_arr, header->elems, 80); FREE(header);
19380         unsigned char (*header_ref)[80] = &header_arr;
19381         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
19382         txdata_constr.datalen = txdata->arr_len;
19383         if (txdata_constr.datalen > 0)
19384                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
19385         else
19386                 txdata_constr.data = NULL;
19387         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
19388         for (size_t c = 0; c < txdata_constr.datalen; c++) {
19389                 uint32_t txdata_conv_28 = txdata_vals[c];
19390                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
19391                 CHECK_ACCESS(txdata_conv_28_ptr);
19392                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
19393                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
19394                 txdata_constr.data[c] = txdata_conv_28_conv;
19395         }
19396         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
19397         CHECK_ACCESS(broadcaster_ptr);
19398         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19399         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
19400         CHECK_ACCESS(fee_estimator_ptr);
19401         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19402         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19403         CHECK_ACCESS(logger_ptr);
19404         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19405         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);
19406         uint32_tArray ret_arr = NULL;
19407         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19408         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19409         for (size_t n = 0; n < ret_var.datalen; n++) {
19410                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19411                 *ret_conv_39_conv = ret_var.data[n];
19412                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
19413         }
19414         
19415         FREE(ret_var.data);
19416         return ret_arr;
19417 }
19418
19419 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) {
19420         LDKChannelMonitor this_arg_conv;
19421         this_arg_conv.inner = (void*)(this_arg & (~1));
19422         this_arg_conv.is_owned = false;
19423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19424         unsigned char txid_arr[32];
19425         CHECK(txid->arr_len == 32);
19426         memcpy(txid_arr, txid->elems, 32); FREE(txid);
19427         unsigned char (*txid_ref)[32] = &txid_arr;
19428         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
19429         CHECK_ACCESS(broadcaster_ptr);
19430         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19431         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
19432         CHECK_ACCESS(fee_estimator_ptr);
19433         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19434         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19435         CHECK_ACCESS(logger_ptr);
19436         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19437         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
19438 }
19439
19440 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) {
19441         LDKChannelMonitor this_arg_conv;
19442         this_arg_conv.inner = (void*)(this_arg & (~1));
19443         this_arg_conv.is_owned = false;
19444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19445         unsigned char header_arr[80];
19446         CHECK(header->arr_len == 80);
19447         memcpy(header_arr, header->elems, 80); FREE(header);
19448         unsigned char (*header_ref)[80] = &header_arr;
19449         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
19450         CHECK_ACCESS(broadcaster_ptr);
19451         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
19452         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
19453         CHECK_ACCESS(fee_estimator_ptr);
19454         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
19455         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
19456         CHECK_ACCESS(logger_ptr);
19457         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
19458         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
19459         uint32_tArray ret_arr = NULL;
19460         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19461         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19462         for (size_t n = 0; n < ret_var.datalen; n++) {
19463                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
19464                 *ret_conv_39_conv = ret_var.data[n];
19465                 ret_arr_ptr[n] = ((uintptr_t)ret_conv_39_conv);
19466         }
19467         
19468         FREE(ret_var.data);
19469         return ret_arr;
19470 }
19471
19472 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
19473         LDKChannelMonitor this_arg_conv;
19474         this_arg_conv.inner = (void*)(this_arg & (~1));
19475         this_arg_conv.is_owned = false;
19476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19477         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
19478         ptrArray ret_arr = NULL;
19479         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
19480         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
19481         for (size_t m = 0; m < ret_var.datalen; m++) {
19482                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
19483                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
19484                 ret_arr_ptr[m] = ret_conv_12_arr;
19485         }
19486         
19487         FREE(ret_var.data);
19488         return ret_arr;
19489 }
19490
19491 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
19492         LDKChannelMonitor this_arg_conv;
19493         this_arg_conv.inner = (void*)(this_arg & (~1));
19494         this_arg_conv.is_owned = false;
19495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19496         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
19497         uintptr_t ret_ref = 0;
19498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19501         ret_ref = (uintptr_t)ret_var.inner;
19502         if (ret_var.is_owned) {
19503                 ret_ref |= 1;
19504         }
19505         return ret_ref;
19506 }
19507
19508 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
19509         LDKChannelMonitor this_arg_conv;
19510         this_arg_conv.inner = (void*)(this_arg & (~1));
19511         this_arg_conv.is_owned = false;
19512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19513         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
19514         uint32_tArray ret_arr = NULL;
19515         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
19516         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
19517         for (size_t j = 0; j < ret_var.datalen; j++) {
19518                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
19519                 *ret_conv_9_copy = ret_var.data[j];
19520                 uintptr_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
19521                 ret_arr_ptr[j] = ret_conv_9_ref;
19522         }
19523         
19524         FREE(ret_var.data);
19525         return ret_arr;
19526 }
19527
19528 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
19529         LDKu8slice ser_ref;
19530         ser_ref.datalen = ser->arr_len;
19531         ser_ref.data = ser->elems /* XXX ser leaks */;
19532         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
19533         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
19534         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
19535         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
19536         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
19537         return (uintptr_t)ret_conv;
19538 }
19539
19540 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
19541         LDKOutPoint this_obj_conv;
19542         this_obj_conv.inner = (void*)(this_obj & (~1));
19543         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19545         OutPoint_free(this_obj_conv);
19546 }
19547
19548 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
19549         LDKOutPoint this_ptr_conv;
19550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19551         this_ptr_conv.is_owned = false;
19552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19553         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
19554         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
19555         return ret_arr;
19556 }
19557
19558 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
19559         LDKOutPoint this_ptr_conv;
19560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19561         this_ptr_conv.is_owned = false;
19562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19563         LDKThirtyTwoBytes val_ref;
19564         CHECK(val->arr_len == 32);
19565         memcpy(val_ref.data, val->elems, 32); FREE(val);
19566         OutPoint_set_txid(&this_ptr_conv, val_ref);
19567 }
19568
19569 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
19570         LDKOutPoint this_ptr_conv;
19571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19572         this_ptr_conv.is_owned = false;
19573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19574         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
19575         return ret_val;
19576 }
19577
19578 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
19579         LDKOutPoint this_ptr_conv;
19580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19581         this_ptr_conv.is_owned = false;
19582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19583         OutPoint_set_index(&this_ptr_conv, val);
19584 }
19585
19586 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
19587         LDKThirtyTwoBytes txid_arg_ref;
19588         CHECK(txid_arg->arr_len == 32);
19589         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
19590         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
19591         uintptr_t ret_ref = 0;
19592         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19593         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19595         ret_ref = (uintptr_t)ret_var.inner;
19596         if (ret_var.is_owned) {
19597                 ret_ref |= 1;
19598         }
19599         return ret_ref;
19600 }
19601
19602 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
19603         LDKOutPoint ret_var = OutPoint_clone(arg);
19604 uintptr_t ret_ref = 0;
19605 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19606 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19607 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19608 ret_ref = (uintptr_t)ret_var.inner;
19609 if (ret_var.is_owned) {
19610         ret_ref |= 1;
19611 }
19612         return ret_ref;
19613 }
19614 intptr_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
19615         LDKOutPoint arg_conv;
19616         arg_conv.inner = (void*)(arg & (~1));
19617         arg_conv.is_owned = false;
19618         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19619         intptr_t ret_val = OutPoint_clone_ptr(&arg_conv);
19620         return ret_val;
19621 }
19622
19623 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
19624         LDKOutPoint orig_conv;
19625         orig_conv.inner = (void*)(orig & (~1));
19626         orig_conv.is_owned = false;
19627         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19628         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
19629         uintptr_t ret_ref = 0;
19630         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19631         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19633         ret_ref = (uintptr_t)ret_var.inner;
19634         if (ret_var.is_owned) {
19635                 ret_ref |= 1;
19636         }
19637         return ret_ref;
19638 }
19639
19640 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
19641         LDKOutPoint a_conv;
19642         a_conv.inner = (void*)(a & (~1));
19643         a_conv.is_owned = false;
19644         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19645         LDKOutPoint b_conv;
19646         b_conv.inner = (void*)(b & (~1));
19647         b_conv.is_owned = false;
19648         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19649         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
19650         return ret_val;
19651 }
19652
19653 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
19654         LDKOutPoint o_conv;
19655         o_conv.inner = (void*)(o & (~1));
19656         o_conv.is_owned = false;
19657         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19658         int64_t ret_val = OutPoint_hash(&o_conv);
19659         return ret_val;
19660 }
19661
19662 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
19663         LDKOutPoint this_arg_conv;
19664         this_arg_conv.inner = (void*)(this_arg & (~1));
19665         this_arg_conv.is_owned = false;
19666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
19667         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
19668         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
19669         return ret_arr;
19670 }
19671
19672 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
19673         LDKOutPoint obj_conv;
19674         obj_conv.inner = (void*)(obj & (~1));
19675         obj_conv.is_owned = false;
19676         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19677         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
19678         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19679         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19680         CVec_u8Z_free(ret_var);
19681         return ret_arr;
19682 }
19683
19684 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
19685         LDKu8slice ser_ref;
19686         ser_ref.datalen = ser->arr_len;
19687         ser_ref.data = ser->elems /* XXX ser leaks */;
19688         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
19689         *ret_conv = OutPoint_read(ser_ref);
19690         return (uintptr_t)ret_conv;
19691 }
19692
19693 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
19694         LDKDelayedPaymentOutputDescriptor this_obj_conv;
19695         this_obj_conv.inner = (void*)(this_obj & (~1));
19696         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19698         DelayedPaymentOutputDescriptor_free(this_obj_conv);
19699 }
19700
19701 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
19702         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19704         this_ptr_conv.is_owned = false;
19705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19706         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
19707         uintptr_t ret_ref = 0;
19708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19711         ret_ref = (uintptr_t)ret_var.inner;
19712         if (ret_var.is_owned) {
19713                 ret_ref |= 1;
19714         }
19715         return ret_ref;
19716 }
19717
19718 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
19719         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19721         this_ptr_conv.is_owned = false;
19722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19723         LDKOutPoint val_conv;
19724         val_conv.inner = (void*)(val & (~1));
19725         val_conv.is_owned = (val & 1) || (val == 0);
19726         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
19727         val_conv = OutPoint_clone(&val_conv);
19728         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
19729 }
19730
19731 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
19732         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19734         this_ptr_conv.is_owned = false;
19735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19736         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
19737         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
19738         return ret_arr;
19739 }
19740
19741 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
19742         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19744         this_ptr_conv.is_owned = false;
19745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19746         LDKPublicKey val_ref;
19747         CHECK(val->arr_len == 33);
19748         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
19749         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
19750 }
19751
19752 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
19753         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19755         this_ptr_conv.is_owned = false;
19756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19757         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
19758         return ret_val;
19759 }
19760
19761 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
19762         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19764         this_ptr_conv.is_owned = false;
19765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19766         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
19767 }
19768
19769 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
19770         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19772         this_ptr_conv.is_owned = false;
19773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19774         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
19775         CHECK_ACCESS(val_ptr);
19776         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
19777         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
19778         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
19779 }
19780
19781 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
19782         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19784         this_ptr_conv.is_owned = false;
19785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19786         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
19787         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
19788         return ret_arr;
19789 }
19790
19791 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
19792         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19794         this_ptr_conv.is_owned = false;
19795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19796         LDKPublicKey val_ref;
19797         CHECK(val->arr_len == 33);
19798         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
19799         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
19800 }
19801
19802 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
19803         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19805         this_ptr_conv.is_owned = false;
19806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19807         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
19808         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
19809         return ret_arr;
19810 }
19811
19812 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
19813         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19815         this_ptr_conv.is_owned = false;
19816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19817         LDKThirtyTwoBytes val_ref;
19818         CHECK(val->arr_len == 32);
19819         memcpy(val_ref.data, val->elems, 32); FREE(val);
19820         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
19821 }
19822
19823 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
19824         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19826         this_ptr_conv.is_owned = false;
19827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19828         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
19829         return ret_val;
19830 }
19831
19832 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
19833         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
19834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19835         this_ptr_conv.is_owned = false;
19836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19837         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
19838 }
19839
19840 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) {
19841         LDKOutPoint outpoint_arg_conv;
19842         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
19843         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
19844         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
19845         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
19846         LDKPublicKey per_commitment_point_arg_ref;
19847         CHECK(per_commitment_point_arg->arr_len == 33);
19848         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
19849         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
19850         CHECK_ACCESS(output_arg_ptr);
19851         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
19852         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
19853         LDKPublicKey revocation_pubkey_arg_ref;
19854         CHECK(revocation_pubkey_arg->arr_len == 33);
19855         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
19856         LDKThirtyTwoBytes channel_keys_id_arg_ref;
19857         CHECK(channel_keys_id_arg->arr_len == 32);
19858         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
19859         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);
19860         uintptr_t ret_ref = 0;
19861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19864         ret_ref = (uintptr_t)ret_var.inner;
19865         if (ret_var.is_owned) {
19866                 ret_ref |= 1;
19867         }
19868         return ret_ref;
19869 }
19870
19871 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
19872         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
19873 uintptr_t ret_ref = 0;
19874 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19875 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19876 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19877 ret_ref = (uintptr_t)ret_var.inner;
19878 if (ret_var.is_owned) {
19879         ret_ref |= 1;
19880 }
19881         return ret_ref;
19882 }
19883 intptr_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
19884         LDKDelayedPaymentOutputDescriptor arg_conv;
19885         arg_conv.inner = (void*)(arg & (~1));
19886         arg_conv.is_owned = false;
19887         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
19888         intptr_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
19889         return ret_val;
19890 }
19891
19892 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
19893         LDKDelayedPaymentOutputDescriptor orig_conv;
19894         orig_conv.inner = (void*)(orig & (~1));
19895         orig_conv.is_owned = false;
19896         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
19897         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
19898         uintptr_t ret_ref = 0;
19899         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19900         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19902         ret_ref = (uintptr_t)ret_var.inner;
19903         if (ret_var.is_owned) {
19904                 ret_ref |= 1;
19905         }
19906         return ret_ref;
19907 }
19908
19909 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
19910         LDKDelayedPaymentOutputDescriptor obj_conv;
19911         obj_conv.inner = (void*)(obj & (~1));
19912         obj_conv.is_owned = false;
19913         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
19914         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
19915         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19916         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19917         CVec_u8Z_free(ret_var);
19918         return ret_arr;
19919 }
19920
19921 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
19922         LDKu8slice ser_ref;
19923         ser_ref.datalen = ser->arr_len;
19924         ser_ref.data = ser->elems /* XXX ser leaks */;
19925         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19926         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
19927         return (uintptr_t)ret_conv;
19928 }
19929
19930 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
19931         LDKStaticPaymentOutputDescriptor this_obj_conv;
19932         this_obj_conv.inner = (void*)(this_obj & (~1));
19933         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
19934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
19935         StaticPaymentOutputDescriptor_free(this_obj_conv);
19936 }
19937
19938 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
19939         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19941         this_ptr_conv.is_owned = false;
19942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19943         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
19944         uintptr_t ret_ref = 0;
19945         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
19946         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
19947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
19948         ret_ref = (uintptr_t)ret_var.inner;
19949         if (ret_var.is_owned) {
19950                 ret_ref |= 1;
19951         }
19952         return ret_ref;
19953 }
19954
19955 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
19956         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19958         this_ptr_conv.is_owned = false;
19959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19960         LDKOutPoint val_conv;
19961         val_conv.inner = (void*)(val & (~1));
19962         val_conv.is_owned = (val & 1) || (val == 0);
19963         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
19964         val_conv = OutPoint_clone(&val_conv);
19965         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
19966 }
19967
19968 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
19969         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19971         this_ptr_conv.is_owned = false;
19972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19973         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
19974         CHECK_ACCESS(val_ptr);
19975         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
19976         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
19977         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
19978 }
19979
19980 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
19981         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19983         this_ptr_conv.is_owned = false;
19984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19985         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
19986         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
19987         return ret_arr;
19988 }
19989
19990 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
19991         LDKStaticPaymentOutputDescriptor this_ptr_conv;
19992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
19993         this_ptr_conv.is_owned = false;
19994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
19995         LDKThirtyTwoBytes val_ref;
19996         CHECK(val->arr_len == 32);
19997         memcpy(val_ref.data, val->elems, 32); FREE(val);
19998         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
19999 }
20000
20001 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
20002         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20004         this_ptr_conv.is_owned = false;
20005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20006         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
20007         return ret_val;
20008 }
20009
20010 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
20011         LDKStaticPaymentOutputDescriptor this_ptr_conv;
20012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20013         this_ptr_conv.is_owned = false;
20014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20015         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
20016 }
20017
20018 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) {
20019         LDKOutPoint outpoint_arg_conv;
20020         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
20021         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
20022         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
20023         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
20024         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
20025         CHECK_ACCESS(output_arg_ptr);
20026         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
20027         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
20028         LDKThirtyTwoBytes channel_keys_id_arg_ref;
20029         CHECK(channel_keys_id_arg->arr_len == 32);
20030         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
20031         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
20032         uintptr_t ret_ref = 0;
20033         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20034         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20036         ret_ref = (uintptr_t)ret_var.inner;
20037         if (ret_var.is_owned) {
20038                 ret_ref |= 1;
20039         }
20040         return ret_ref;
20041 }
20042
20043 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
20044         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
20045 uintptr_t ret_ref = 0;
20046 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20047 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20048 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20049 ret_ref = (uintptr_t)ret_var.inner;
20050 if (ret_var.is_owned) {
20051         ret_ref |= 1;
20052 }
20053         return ret_ref;
20054 }
20055 intptr_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
20056         LDKStaticPaymentOutputDescriptor arg_conv;
20057         arg_conv.inner = (void*)(arg & (~1));
20058         arg_conv.is_owned = false;
20059         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20060         intptr_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
20061         return ret_val;
20062 }
20063
20064 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
20065         LDKStaticPaymentOutputDescriptor orig_conv;
20066         orig_conv.inner = (void*)(orig & (~1));
20067         orig_conv.is_owned = false;
20068         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20069         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
20070         uintptr_t ret_ref = 0;
20071         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20072         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20074         ret_ref = (uintptr_t)ret_var.inner;
20075         if (ret_var.is_owned) {
20076                 ret_ref |= 1;
20077         }
20078         return ret_ref;
20079 }
20080
20081 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
20082         LDKStaticPaymentOutputDescriptor obj_conv;
20083         obj_conv.inner = (void*)(obj & (~1));
20084         obj_conv.is_owned = false;
20085         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20086         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
20087         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20088         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20089         CVec_u8Z_free(ret_var);
20090         return ret_arr;
20091 }
20092
20093 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
20094         LDKu8slice ser_ref;
20095         ser_ref.datalen = ser->arr_len;
20096         ser_ref.data = ser->elems /* XXX ser leaks */;
20097         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
20098         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
20099         return (uintptr_t)ret_conv;
20100 }
20101
20102 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
20103         if ((this_ptr & 1) != 0) return;
20104         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20105         CHECK_ACCESS(this_ptr_ptr);
20106         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
20107         FREE((void*)this_ptr);
20108         SpendableOutputDescriptor_free(this_ptr_conv);
20109 }
20110
20111 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
20112         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20113         *ret_copy = SpendableOutputDescriptor_clone(arg);
20114 uintptr_t ret_ref = (uintptr_t)ret_copy;
20115         return ret_ref;
20116 }
20117 intptr_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
20118         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
20119         intptr_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
20120         return ret_val;
20121 }
20122
20123 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
20124         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
20125         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20126         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
20127         uintptr_t ret_ref = (uintptr_t)ret_copy;
20128         return ret_ref;
20129 }
20130
20131 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
20132         LDKOutPoint outpoint_conv;
20133         outpoint_conv.inner = (void*)(outpoint & (~1));
20134         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
20135         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
20136         outpoint_conv = OutPoint_clone(&outpoint_conv);
20137         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
20138         CHECK_ACCESS(output_ptr);
20139         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
20140         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
20141         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20142         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
20143         uintptr_t ret_ref = (uintptr_t)ret_copy;
20144         return ret_ref;
20145 }
20146
20147 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
20148         LDKDelayedPaymentOutputDescriptor a_conv;
20149         a_conv.inner = (void*)(a & (~1));
20150         a_conv.is_owned = (a & 1) || (a == 0);
20151         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20152         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
20153         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20154         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
20155         uintptr_t ret_ref = (uintptr_t)ret_copy;
20156         return ret_ref;
20157 }
20158
20159 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
20160         LDKStaticPaymentOutputDescriptor a_conv;
20161         a_conv.inner = (void*)(a & (~1));
20162         a_conv.is_owned = (a & 1) || (a == 0);
20163         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
20164         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
20165         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
20166         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
20167         uintptr_t ret_ref = (uintptr_t)ret_copy;
20168         return ret_ref;
20169 }
20170
20171 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
20172         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
20173         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
20174         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20175         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20176         CVec_u8Z_free(ret_var);
20177         return ret_arr;
20178 }
20179
20180 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
20181         LDKu8slice ser_ref;
20182         ser_ref.datalen = ser->arr_len;
20183         ser_ref.data = ser->elems /* XXX ser leaks */;
20184         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
20185         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
20186         return (uintptr_t)ret_conv;
20187 }
20188
20189 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
20190         if ((this_ptr & 1) != 0) return;
20191         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20192         CHECK_ACCESS(this_ptr_ptr);
20193         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
20194         FREE((void*)this_ptr);
20195         BaseSign_free(this_ptr_conv);
20196 }
20197
20198 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
20199         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20200         *ret_ret = Sign_clone(arg);
20201         return (uintptr_t)ret_ret;
20202 }
20203 intptr_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
20204         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
20205         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
20206         LDKSign* arg_conv = (LDKSign*)arg_ptr;
20207         intptr_t ret_val = Sign_clone_ptr(arg_conv);
20208         return ret_val;
20209 }
20210
20211 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
20212         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
20213         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
20214         LDKSign* orig_conv = (LDKSign*)orig_ptr;
20215         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20216         *ret_ret = Sign_clone(orig_conv);
20217         return (uintptr_t)ret_ret;
20218 }
20219
20220 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
20221         if ((this_ptr & 1) != 0) return;
20222         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20223         CHECK_ACCESS(this_ptr_ptr);
20224         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
20225         FREE((void*)this_ptr);
20226         Sign_free(this_ptr_conv);
20227 }
20228
20229 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
20230         if ((this_ptr & 1) != 0) return;
20231         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20232         CHECK_ACCESS(this_ptr_ptr);
20233         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
20234         FREE((void*)this_ptr);
20235         KeysInterface_free(this_ptr_conv);
20236 }
20237
20238 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
20239         LDKInMemorySigner this_obj_conv;
20240         this_obj_conv.inner = (void*)(this_obj & (~1));
20241         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20243         InMemorySigner_free(this_obj_conv);
20244 }
20245
20246 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
20247         LDKInMemorySigner this_ptr_conv;
20248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20249         this_ptr_conv.is_owned = false;
20250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20251         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
20252         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
20253         return ret_arr;
20254 }
20255
20256 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
20257         LDKInMemorySigner this_ptr_conv;
20258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20259         this_ptr_conv.is_owned = false;
20260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20261         LDKSecretKey val_ref;
20262         CHECK(val->arr_len == 32);
20263         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
20264         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
20265 }
20266
20267 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
20268         LDKInMemorySigner this_ptr_conv;
20269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20270         this_ptr_conv.is_owned = false;
20271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20272         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
20273         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
20274         return ret_arr;
20275 }
20276
20277 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
20278         LDKInMemorySigner this_ptr_conv;
20279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20280         this_ptr_conv.is_owned = false;
20281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20282         LDKSecretKey val_ref;
20283         CHECK(val->arr_len == 32);
20284         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
20285         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
20286 }
20287
20288 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
20289         LDKInMemorySigner this_ptr_conv;
20290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20291         this_ptr_conv.is_owned = false;
20292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20293         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
20294         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
20295         return ret_arr;
20296 }
20297
20298 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
20299         LDKInMemorySigner this_ptr_conv;
20300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20301         this_ptr_conv.is_owned = false;
20302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20303         LDKSecretKey val_ref;
20304         CHECK(val->arr_len == 32);
20305         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
20306         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
20307 }
20308
20309 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
20310         LDKInMemorySigner this_ptr_conv;
20311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20312         this_ptr_conv.is_owned = false;
20313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20314         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
20315         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
20316         return ret_arr;
20317 }
20318
20319 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) {
20320         LDKInMemorySigner this_ptr_conv;
20321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20322         this_ptr_conv.is_owned = false;
20323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20324         LDKSecretKey val_ref;
20325         CHECK(val->arr_len == 32);
20326         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
20327         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
20328 }
20329
20330 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
20331         LDKInMemorySigner this_ptr_conv;
20332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20333         this_ptr_conv.is_owned = false;
20334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20335         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
20336         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
20337         return ret_arr;
20338 }
20339
20340 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
20341         LDKInMemorySigner this_ptr_conv;
20342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20343         this_ptr_conv.is_owned = false;
20344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20345         LDKSecretKey val_ref;
20346         CHECK(val->arr_len == 32);
20347         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
20348         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
20349 }
20350
20351 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
20352         LDKInMemorySigner this_ptr_conv;
20353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20354         this_ptr_conv.is_owned = false;
20355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20356         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
20357         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
20358         return ret_arr;
20359 }
20360
20361 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
20362         LDKInMemorySigner this_ptr_conv;
20363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20364         this_ptr_conv.is_owned = false;
20365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20366         LDKThirtyTwoBytes val_ref;
20367         CHECK(val->arr_len == 32);
20368         memcpy(val_ref.data, val->elems, 32); FREE(val);
20369         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
20370 }
20371
20372 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
20373         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
20374 uintptr_t ret_ref = 0;
20375 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20376 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20377 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20378 ret_ref = (uintptr_t)ret_var.inner;
20379 if (ret_var.is_owned) {
20380         ret_ref |= 1;
20381 }
20382         return ret_ref;
20383 }
20384 intptr_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
20385         LDKInMemorySigner arg_conv;
20386         arg_conv.inner = (void*)(arg & (~1));
20387         arg_conv.is_owned = false;
20388         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20389         intptr_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
20390         return ret_val;
20391 }
20392
20393 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
20394         LDKInMemorySigner orig_conv;
20395         orig_conv.inner = (void*)(orig & (~1));
20396         orig_conv.is_owned = false;
20397         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20398         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
20399         uintptr_t ret_ref = 0;
20400         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20401         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20403         ret_ref = (uintptr_t)ret_var.inner;
20404         if (ret_var.is_owned) {
20405                 ret_ref |= 1;
20406         }
20407         return ret_ref;
20408 }
20409
20410 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) {
20411         LDKSecretKey funding_key_ref;
20412         CHECK(funding_key->arr_len == 32);
20413         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
20414         LDKSecretKey revocation_base_key_ref;
20415         CHECK(revocation_base_key->arr_len == 32);
20416         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
20417         LDKSecretKey payment_key_ref;
20418         CHECK(payment_key->arr_len == 32);
20419         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
20420         LDKSecretKey delayed_payment_base_key_ref;
20421         CHECK(delayed_payment_base_key->arr_len == 32);
20422         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
20423         LDKSecretKey htlc_base_key_ref;
20424         CHECK(htlc_base_key->arr_len == 32);
20425         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
20426         LDKThirtyTwoBytes commitment_seed_ref;
20427         CHECK(commitment_seed->arr_len == 32);
20428         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
20429         LDKThirtyTwoBytes channel_keys_id_ref;
20430         CHECK(channel_keys_id->arr_len == 32);
20431         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
20432         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);
20433         uintptr_t ret_ref = 0;
20434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20437         ret_ref = (uintptr_t)ret_var.inner;
20438         if (ret_var.is_owned) {
20439                 ret_ref |= 1;
20440         }
20441         return ret_ref;
20442 }
20443
20444 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
20445         LDKInMemorySigner this_arg_conv;
20446         this_arg_conv.inner = (void*)(this_arg & (~1));
20447         this_arg_conv.is_owned = false;
20448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20449         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
20450         uintptr_t ret_ref = 0;
20451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20454         ret_ref = (uintptr_t)ret_var.inner;
20455         if (ret_var.is_owned) {
20456                 ret_ref |= 1;
20457         }
20458         return ret_ref;
20459 }
20460
20461 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
20462         LDKInMemorySigner this_arg_conv;
20463         this_arg_conv.inner = (void*)(this_arg & (~1));
20464         this_arg_conv.is_owned = false;
20465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20466         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
20467         return ret_val;
20468 }
20469
20470 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
20471         LDKInMemorySigner this_arg_conv;
20472         this_arg_conv.inner = (void*)(this_arg & (~1));
20473         this_arg_conv.is_owned = false;
20474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20475         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
20476         return ret_val;
20477 }
20478
20479 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
20480         LDKInMemorySigner this_arg_conv;
20481         this_arg_conv.inner = (void*)(this_arg & (~1));
20482         this_arg_conv.is_owned = false;
20483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20484         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
20485         return ret_val;
20486 }
20487
20488 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
20489         LDKInMemorySigner this_arg_conv;
20490         this_arg_conv.inner = (void*)(this_arg & (~1));
20491         this_arg_conv.is_owned = false;
20492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20493         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
20494         uintptr_t ret_ref = 0;
20495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20498         ret_ref = (uintptr_t)ret_var.inner;
20499         if (ret_var.is_owned) {
20500                 ret_ref |= 1;
20501         }
20502         return ret_ref;
20503 }
20504
20505 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
20506         LDKInMemorySigner this_arg_conv;
20507         this_arg_conv.inner = (void*)(this_arg & (~1));
20508         this_arg_conv.is_owned = false;
20509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20510         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
20511         uintptr_t ret_ref = 0;
20512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20515         ret_ref = (uintptr_t)ret_var.inner;
20516         if (ret_var.is_owned) {
20517                 ret_ref |= 1;
20518         }
20519         return ret_ref;
20520 }
20521
20522 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
20523         LDKInMemorySigner this_arg_conv;
20524         this_arg_conv.inner = (void*)(this_arg & (~1));
20525         this_arg_conv.is_owned = false;
20526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20527         jboolean ret_val = InMemorySigner_opt_anchors(&this_arg_conv);
20528         return ret_val;
20529 }
20530
20531 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) {
20532         LDKInMemorySigner this_arg_conv;
20533         this_arg_conv.inner = (void*)(this_arg & (~1));
20534         this_arg_conv.is_owned = false;
20535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20536         LDKTransaction spend_tx_ref;
20537         spend_tx_ref.datalen = spend_tx->arr_len;
20538         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
20539         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
20540         spend_tx_ref.data_is_owned = true;
20541         LDKStaticPaymentOutputDescriptor descriptor_conv;
20542         descriptor_conv.inner = (void*)(descriptor & (~1));
20543         descriptor_conv.is_owned = false;
20544         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
20545         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20546         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
20547         return (uintptr_t)ret_conv;
20548 }
20549
20550 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) {
20551         LDKInMemorySigner this_arg_conv;
20552         this_arg_conv.inner = (void*)(this_arg & (~1));
20553         this_arg_conv.is_owned = false;
20554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20555         LDKTransaction spend_tx_ref;
20556         spend_tx_ref.datalen = spend_tx->arr_len;
20557         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
20558         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
20559         spend_tx_ref.data_is_owned = true;
20560         LDKDelayedPaymentOutputDescriptor descriptor_conv;
20561         descriptor_conv.inner = (void*)(descriptor & (~1));
20562         descriptor_conv.is_owned = false;
20563         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
20564         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20565         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
20566         return (uintptr_t)ret_conv;
20567 }
20568
20569 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
20570         LDKInMemorySigner this_arg_conv;
20571         this_arg_conv.inner = (void*)(this_arg & (~1));
20572         this_arg_conv.is_owned = false;
20573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20574         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
20575         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
20576         return (uintptr_t)ret_ret;
20577 }
20578
20579 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
20580         LDKInMemorySigner this_arg_conv;
20581         this_arg_conv.inner = (void*)(this_arg & (~1));
20582         this_arg_conv.is_owned = false;
20583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20584         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
20585         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
20586         return (uintptr_t)ret_ret;
20587 }
20588
20589 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
20590         LDKInMemorySigner obj_conv;
20591         obj_conv.inner = (void*)(obj & (~1));
20592         obj_conv.is_owned = false;
20593         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20594         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
20595         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20596         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20597         CVec_u8Z_free(ret_var);
20598         return ret_arr;
20599 }
20600
20601 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser) {
20602         LDKu8slice ser_ref;
20603         ser_ref.datalen = ser->arr_len;
20604         ser_ref.data = ser->elems /* XXX ser leaks */;
20605         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20606         *ret_conv = InMemorySigner_read(ser_ref);
20607         return (uintptr_t)ret_conv;
20608 }
20609
20610 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
20611         LDKKeysManager this_obj_conv;
20612         this_obj_conv.inner = (void*)(this_obj & (~1));
20613         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20615         KeysManager_free(this_obj_conv);
20616 }
20617
20618 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
20619         unsigned char seed_arr[32];
20620         CHECK(seed->arr_len == 32);
20621         memcpy(seed_arr, seed->elems, 32); FREE(seed);
20622         unsigned char (*seed_ref)[32] = &seed_arr;
20623         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
20624         uintptr_t ret_ref = 0;
20625         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20626         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20628         ret_ref = (uintptr_t)ret_var.inner;
20629         if (ret_var.is_owned) {
20630                 ret_ref |= 1;
20631         }
20632         return ret_ref;
20633 }
20634
20635 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) {
20636         LDKKeysManager this_arg_conv;
20637         this_arg_conv.inner = (void*)(this_arg & (~1));
20638         this_arg_conv.is_owned = false;
20639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20640         unsigned char params_arr[32];
20641         CHECK(params->arr_len == 32);
20642         memcpy(params_arr, params->elems, 32); FREE(params);
20643         unsigned char (*params_ref)[32] = &params_arr;
20644         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
20645         uintptr_t ret_ref = 0;
20646         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20647         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20649         ret_ref = (uintptr_t)ret_var.inner;
20650         if (ret_var.is_owned) {
20651                 ret_ref |= 1;
20652         }
20653         return ret_ref;
20654 }
20655
20656 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) {
20657         LDKKeysManager this_arg_conv;
20658         this_arg_conv.inner = (void*)(this_arg & (~1));
20659         this_arg_conv.is_owned = false;
20660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20661         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
20662         descriptors_constr.datalen = descriptors->arr_len;
20663         if (descriptors_constr.datalen > 0)
20664                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
20665         else
20666                 descriptors_constr.data = NULL;
20667         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
20668         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
20669                 uint32_t descriptors_conv_27 = descriptors_vals[b];
20670                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
20671                 CHECK_ACCESS(descriptors_conv_27_ptr);
20672                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
20673                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
20674                 descriptors_constr.data[b] = descriptors_conv_27_conv;
20675         }
20676         LDKCVec_TxOutZ outputs_constr;
20677         outputs_constr.datalen = outputs->arr_len;
20678         if (outputs_constr.datalen > 0)
20679                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
20680         else
20681                 outputs_constr.data = NULL;
20682         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
20683         for (size_t h = 0; h < outputs_constr.datalen; h++) {
20684                 uint32_t outputs_conv_7 = outputs_vals[h];
20685                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
20686                 CHECK_ACCESS(outputs_conv_7_ptr);
20687                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
20688                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
20689                 outputs_constr.data[h] = outputs_conv_7_conv;
20690         }
20691         LDKCVec_u8Z change_destination_script_ref;
20692         change_destination_script_ref.datalen = change_destination_script->arr_len;
20693         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
20694         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
20695         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20696         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
20697         return (uintptr_t)ret_conv;
20698 }
20699
20700 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
20701         LDKKeysManager this_arg_conv;
20702         this_arg_conv.inner = (void*)(this_arg & (~1));
20703         this_arg_conv.is_owned = false;
20704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
20705         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
20706         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
20707         return (uintptr_t)ret_ret;
20708 }
20709
20710 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
20711         LDKChannelManager this_obj_conv;
20712         this_obj_conv.inner = (void*)(this_obj & (~1));
20713         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20715         ChannelManager_free(this_obj_conv);
20716 }
20717
20718 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
20719         LDKChainParameters this_obj_conv;
20720         this_obj_conv.inner = (void*)(this_obj & (~1));
20721         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20723         ChainParameters_free(this_obj_conv);
20724 }
20725
20726 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
20727         LDKChainParameters this_ptr_conv;
20728         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20729         this_ptr_conv.is_owned = false;
20730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20731         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
20732         return ret_conv;
20733 }
20734
20735 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
20736         LDKChainParameters this_ptr_conv;
20737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20738         this_ptr_conv.is_owned = false;
20739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20740         LDKNetwork val_conv = LDKNetwork_from_js(val);
20741         ChainParameters_set_network(&this_ptr_conv, val_conv);
20742 }
20743
20744 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
20745         LDKChainParameters this_ptr_conv;
20746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20747         this_ptr_conv.is_owned = false;
20748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20749         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
20750         uintptr_t ret_ref = 0;
20751         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20752         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20754         ret_ref = (uintptr_t)ret_var.inner;
20755         if (ret_var.is_owned) {
20756                 ret_ref |= 1;
20757         }
20758         return ret_ref;
20759 }
20760
20761 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
20762         LDKChainParameters this_ptr_conv;
20763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20764         this_ptr_conv.is_owned = false;
20765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20766         LDKBestBlock val_conv;
20767         val_conv.inner = (void*)(val & (~1));
20768         val_conv.is_owned = (val & 1) || (val == 0);
20769         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20770         val_conv = BestBlock_clone(&val_conv);
20771         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
20772 }
20773
20774 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
20775         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
20776         LDKBestBlock best_block_arg_conv;
20777         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
20778         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
20779         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
20780         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
20781         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
20782         uintptr_t ret_ref = 0;
20783         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20784         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20786         ret_ref = (uintptr_t)ret_var.inner;
20787         if (ret_var.is_owned) {
20788                 ret_ref |= 1;
20789         }
20790         return ret_ref;
20791 }
20792
20793 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
20794         LDKChainParameters ret_var = ChainParameters_clone(arg);
20795 uintptr_t ret_ref = 0;
20796 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20797 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20798 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20799 ret_ref = (uintptr_t)ret_var.inner;
20800 if (ret_var.is_owned) {
20801         ret_ref |= 1;
20802 }
20803         return ret_ref;
20804 }
20805 intptr_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
20806         LDKChainParameters arg_conv;
20807         arg_conv.inner = (void*)(arg & (~1));
20808         arg_conv.is_owned = false;
20809         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20810         intptr_t ret_val = ChainParameters_clone_ptr(&arg_conv);
20811         return ret_val;
20812 }
20813
20814 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
20815         LDKChainParameters orig_conv;
20816         orig_conv.inner = (void*)(orig & (~1));
20817         orig_conv.is_owned = false;
20818         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20819         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
20820         uintptr_t ret_ref = 0;
20821         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20822         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20823         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20824         ret_ref = (uintptr_t)ret_var.inner;
20825         if (ret_var.is_owned) {
20826                 ret_ref |= 1;
20827         }
20828         return ret_ref;
20829 }
20830
20831 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
20832         LDKCounterpartyForwardingInfo this_obj_conv;
20833         this_obj_conv.inner = (void*)(this_obj & (~1));
20834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20836         CounterpartyForwardingInfo_free(this_obj_conv);
20837 }
20838
20839 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
20840         LDKCounterpartyForwardingInfo this_ptr_conv;
20841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20842         this_ptr_conv.is_owned = false;
20843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20844         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
20845         return ret_val;
20846 }
20847
20848 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
20849         LDKCounterpartyForwardingInfo this_ptr_conv;
20850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20851         this_ptr_conv.is_owned = false;
20852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20853         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
20854 }
20855
20856 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
20857         LDKCounterpartyForwardingInfo this_ptr_conv;
20858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20859         this_ptr_conv.is_owned = false;
20860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20861         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
20862         return ret_val;
20863 }
20864
20865 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
20866         LDKCounterpartyForwardingInfo this_ptr_conv;
20867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20868         this_ptr_conv.is_owned = false;
20869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20870         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
20871 }
20872
20873 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
20874         LDKCounterpartyForwardingInfo this_ptr_conv;
20875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20876         this_ptr_conv.is_owned = false;
20877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20878         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
20879         return ret_val;
20880 }
20881
20882 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20883         LDKCounterpartyForwardingInfo this_ptr_conv;
20884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20885         this_ptr_conv.is_owned = false;
20886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20887         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
20888 }
20889
20890 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) {
20891         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
20892         uintptr_t ret_ref = 0;
20893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20896         ret_ref = (uintptr_t)ret_var.inner;
20897         if (ret_var.is_owned) {
20898                 ret_ref |= 1;
20899         }
20900         return ret_ref;
20901 }
20902
20903 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
20904         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
20905 uintptr_t ret_ref = 0;
20906 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20907 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20908 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20909 ret_ref = (uintptr_t)ret_var.inner;
20910 if (ret_var.is_owned) {
20911         ret_ref |= 1;
20912 }
20913         return ret_ref;
20914 }
20915 intptr_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
20916         LDKCounterpartyForwardingInfo arg_conv;
20917         arg_conv.inner = (void*)(arg & (~1));
20918         arg_conv.is_owned = false;
20919         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20920         intptr_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
20921         return ret_val;
20922 }
20923
20924 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
20925         LDKCounterpartyForwardingInfo orig_conv;
20926         orig_conv.inner = (void*)(orig & (~1));
20927         orig_conv.is_owned = false;
20928         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20929         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
20930         uintptr_t ret_ref = 0;
20931         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20932         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20934         ret_ref = (uintptr_t)ret_var.inner;
20935         if (ret_var.is_owned) {
20936                 ret_ref |= 1;
20937         }
20938         return ret_ref;
20939 }
20940
20941 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
20942         LDKChannelCounterparty this_obj_conv;
20943         this_obj_conv.inner = (void*)(this_obj & (~1));
20944         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20946         ChannelCounterparty_free(this_obj_conv);
20947 }
20948
20949 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
20950         LDKChannelCounterparty this_ptr_conv;
20951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20952         this_ptr_conv.is_owned = false;
20953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20954         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
20955         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
20956         return ret_arr;
20957 }
20958
20959 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
20960         LDKChannelCounterparty this_ptr_conv;
20961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20962         this_ptr_conv.is_owned = false;
20963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20964         LDKPublicKey val_ref;
20965         CHECK(val->arr_len == 33);
20966         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
20967         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
20968 }
20969
20970 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
20971         LDKChannelCounterparty this_ptr_conv;
20972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20973         this_ptr_conv.is_owned = false;
20974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20975         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
20976         uintptr_t ret_ref = 0;
20977         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20978         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20980         ret_ref = (uintptr_t)ret_var.inner;
20981         if (ret_var.is_owned) {
20982                 ret_ref |= 1;
20983         }
20984         return ret_ref;
20985 }
20986
20987 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
20988         LDKChannelCounterparty this_ptr_conv;
20989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20990         this_ptr_conv.is_owned = false;
20991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20992         LDKInitFeatures val_conv;
20993         val_conv.inner = (void*)(val & (~1));
20994         val_conv.is_owned = (val & 1) || (val == 0);
20995         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20996         val_conv = InitFeatures_clone(&val_conv);
20997         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
20998 }
20999
21000 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
21001         LDKChannelCounterparty this_ptr_conv;
21002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21003         this_ptr_conv.is_owned = false;
21004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21005         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
21006         return ret_val;
21007 }
21008
21009 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
21010         LDKChannelCounterparty this_ptr_conv;
21011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21012         this_ptr_conv.is_owned = false;
21013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21014         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
21015 }
21016
21017 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
21018         LDKChannelCounterparty this_ptr_conv;
21019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21020         this_ptr_conv.is_owned = false;
21021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21022         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
21023         uintptr_t ret_ref = 0;
21024         if ((uintptr_t)ret_var.inner > 4096) {
21025                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21026                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21028                 ret_ref = (uintptr_t)ret_var.inner;
21029                 if (ret_var.is_owned) {
21030                         ret_ref |= 1;
21031                 }
21032         }
21033         return ret_ref;
21034 }
21035
21036 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
21037         LDKChannelCounterparty this_ptr_conv;
21038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21039         this_ptr_conv.is_owned = false;
21040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21041         LDKCounterpartyForwardingInfo val_conv;
21042         val_conv.inner = (void*)(val & (~1));
21043         val_conv.is_owned = (val & 1) || (val == 0);
21044         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21045         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
21046         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
21047 }
21048
21049 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) {
21050         LDKPublicKey node_id_arg_ref;
21051         CHECK(node_id_arg->arr_len == 33);
21052         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
21053         LDKInitFeatures features_arg_conv;
21054         features_arg_conv.inner = (void*)(features_arg & (~1));
21055         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
21056         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
21057         features_arg_conv = InitFeatures_clone(&features_arg_conv);
21058         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
21059         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
21060         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
21061         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
21062         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
21063         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
21064         uintptr_t ret_ref = 0;
21065         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21066         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21068         ret_ref = (uintptr_t)ret_var.inner;
21069         if (ret_var.is_owned) {
21070                 ret_ref |= 1;
21071         }
21072         return ret_ref;
21073 }
21074
21075 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
21076         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
21077 uintptr_t ret_ref = 0;
21078 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21079 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21080 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21081 ret_ref = (uintptr_t)ret_var.inner;
21082 if (ret_var.is_owned) {
21083         ret_ref |= 1;
21084 }
21085         return ret_ref;
21086 }
21087 intptr_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
21088         LDKChannelCounterparty arg_conv;
21089         arg_conv.inner = (void*)(arg & (~1));
21090         arg_conv.is_owned = false;
21091         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21092         intptr_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
21093         return ret_val;
21094 }
21095
21096 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
21097         LDKChannelCounterparty orig_conv;
21098         orig_conv.inner = (void*)(orig & (~1));
21099         orig_conv.is_owned = false;
21100         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21101         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
21102         uintptr_t ret_ref = 0;
21103         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21104         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21106         ret_ref = (uintptr_t)ret_var.inner;
21107         if (ret_var.is_owned) {
21108                 ret_ref |= 1;
21109         }
21110         return ret_ref;
21111 }
21112
21113 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
21114         LDKChannelDetails this_obj_conv;
21115         this_obj_conv.inner = (void*)(this_obj & (~1));
21116         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21118         ChannelDetails_free(this_obj_conv);
21119 }
21120
21121 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
21122         LDKChannelDetails this_ptr_conv;
21123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21124         this_ptr_conv.is_owned = false;
21125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21126         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21127         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
21128         return ret_arr;
21129 }
21130
21131 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
21132         LDKChannelDetails this_ptr_conv;
21133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21134         this_ptr_conv.is_owned = false;
21135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21136         LDKThirtyTwoBytes val_ref;
21137         CHECK(val->arr_len == 32);
21138         memcpy(val_ref.data, val->elems, 32); FREE(val);
21139         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
21140 }
21141
21142 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
21143         LDKChannelDetails this_ptr_conv;
21144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21145         this_ptr_conv.is_owned = false;
21146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21147         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
21148         uintptr_t ret_ref = 0;
21149         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21150         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21152         ret_ref = (uintptr_t)ret_var.inner;
21153         if (ret_var.is_owned) {
21154                 ret_ref |= 1;
21155         }
21156         return ret_ref;
21157 }
21158
21159 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
21160         LDKChannelDetails this_ptr_conv;
21161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21162         this_ptr_conv.is_owned = false;
21163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21164         LDKChannelCounterparty val_conv;
21165         val_conv.inner = (void*)(val & (~1));
21166         val_conv.is_owned = (val & 1) || (val == 0);
21167         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21168         val_conv = ChannelCounterparty_clone(&val_conv);
21169         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
21170 }
21171
21172 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
21173         LDKChannelDetails this_ptr_conv;
21174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21175         this_ptr_conv.is_owned = false;
21176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21177         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
21178         uintptr_t ret_ref = 0;
21179         if ((uintptr_t)ret_var.inner > 4096) {
21180                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21181                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21183                 ret_ref = (uintptr_t)ret_var.inner;
21184                 if (ret_var.is_owned) {
21185                         ret_ref |= 1;
21186                 }
21187         }
21188         return ret_ref;
21189 }
21190
21191 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
21192         LDKChannelDetails this_ptr_conv;
21193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21194         this_ptr_conv.is_owned = false;
21195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21196         LDKOutPoint val_conv;
21197         val_conv.inner = (void*)(val & (~1));
21198         val_conv.is_owned = (val & 1) || (val == 0);
21199         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21200         val_conv = OutPoint_clone(&val_conv);
21201         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
21202 }
21203
21204 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
21205         LDKChannelDetails this_ptr_conv;
21206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21207         this_ptr_conv.is_owned = false;
21208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21209         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21210         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
21211         uintptr_t ret_ref = (uintptr_t)ret_copy;
21212         return ret_ref;
21213 }
21214
21215 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
21216         LDKChannelDetails this_ptr_conv;
21217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21218         this_ptr_conv.is_owned = false;
21219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21220         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
21221         CHECK_ACCESS(val_ptr);
21222         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
21223         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
21224         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
21225 }
21226
21227 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
21228         LDKChannelDetails this_ptr_conv;
21229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21230         this_ptr_conv.is_owned = false;
21231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21232         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
21233         return ret_val;
21234 }
21235
21236 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
21237         LDKChannelDetails this_ptr_conv;
21238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21239         this_ptr_conv.is_owned = false;
21240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21241         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
21242 }
21243
21244 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
21245         LDKChannelDetails this_ptr_conv;
21246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21247         this_ptr_conv.is_owned = false;
21248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21249         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
21250         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
21251         uintptr_t ret_ref = (uintptr_t)ret_copy;
21252         return ret_ref;
21253 }
21254
21255 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
21256         LDKChannelDetails this_ptr_conv;
21257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21258         this_ptr_conv.is_owned = false;
21259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21260         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
21261         CHECK_ACCESS(val_ptr);
21262         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
21263         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
21264         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
21265 }
21266
21267 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
21268         LDKChannelDetails this_ptr_conv;
21269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21270         this_ptr_conv.is_owned = false;
21271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21272         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
21273         return ret_val;
21274 }
21275
21276 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
21277         LDKChannelDetails this_ptr_conv;
21278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21279         this_ptr_conv.is_owned = false;
21280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21281         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
21282 }
21283
21284 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
21285         LDKChannelDetails this_ptr_conv;
21286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21287         this_ptr_conv.is_owned = false;
21288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21289         int64_t ret_val = ChannelDetails_get_balance_msat(&this_ptr_conv);
21290         return ret_val;
21291 }
21292
21293 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
21294         LDKChannelDetails this_ptr_conv;
21295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21296         this_ptr_conv.is_owned = false;
21297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21298         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
21299 }
21300
21301 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
21302         LDKChannelDetails this_ptr_conv;
21303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21304         this_ptr_conv.is_owned = false;
21305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21306         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
21307         return ret_val;
21308 }
21309
21310 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
21311         LDKChannelDetails this_ptr_conv;
21312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21313         this_ptr_conv.is_owned = false;
21314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21315         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
21316 }
21317
21318 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
21319         LDKChannelDetails this_ptr_conv;
21320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21321         this_ptr_conv.is_owned = false;
21322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21323         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
21324         return ret_val;
21325 }
21326
21327 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
21328         LDKChannelDetails this_ptr_conv;
21329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21330         this_ptr_conv.is_owned = false;
21331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21332         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
21333 }
21334
21335 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
21336         LDKChannelDetails this_ptr_conv;
21337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21338         this_ptr_conv.is_owned = false;
21339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21340         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
21341         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
21342         uintptr_t ret_ref = (uintptr_t)ret_copy;
21343         return ret_ref;
21344 }
21345
21346 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
21347         LDKChannelDetails this_ptr_conv;
21348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21349         this_ptr_conv.is_owned = false;
21350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21351         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
21352         CHECK_ACCESS(val_ptr);
21353         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
21354         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
21355         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
21356 }
21357
21358 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
21359         LDKChannelDetails this_ptr_conv;
21360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21361         this_ptr_conv.is_owned = false;
21362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21363         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
21364         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
21365         uintptr_t ret_ref = (uintptr_t)ret_copy;
21366         return ret_ref;
21367 }
21368
21369 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) {
21370         LDKChannelDetails this_ptr_conv;
21371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21372         this_ptr_conv.is_owned = false;
21373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21374         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
21375         CHECK_ACCESS(val_ptr);
21376         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
21377         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
21378         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
21379 }
21380
21381 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
21382         LDKChannelDetails this_ptr_conv;
21383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21384         this_ptr_conv.is_owned = false;
21385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21386         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
21387         return ret_val;
21388 }
21389
21390 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
21391         LDKChannelDetails this_ptr_conv;
21392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21393         this_ptr_conv.is_owned = false;
21394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21395         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
21396 }
21397
21398 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_funding_locked"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
21399         LDKChannelDetails this_ptr_conv;
21400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21401         this_ptr_conv.is_owned = false;
21402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21403         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
21404         return ret_val;
21405 }
21406
21407 void  __attribute__((export_name("TS_ChannelDetails_set_is_funding_locked"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
21408         LDKChannelDetails this_ptr_conv;
21409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21410         this_ptr_conv.is_owned = false;
21411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21412         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
21413 }
21414
21415 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
21416         LDKChannelDetails this_ptr_conv;
21417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21418         this_ptr_conv.is_owned = false;
21419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21420         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
21421         return ret_val;
21422 }
21423
21424 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
21425         LDKChannelDetails this_ptr_conv;
21426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21427         this_ptr_conv.is_owned = false;
21428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21429         ChannelDetails_set_is_usable(&this_ptr_conv, val);
21430 }
21431
21432 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
21433         LDKChannelDetails this_ptr_conv;
21434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21435         this_ptr_conv.is_owned = false;
21436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21437         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
21438         return ret_val;
21439 }
21440
21441 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
21442         LDKChannelDetails this_ptr_conv;
21443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21444         this_ptr_conv.is_owned = false;
21445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21446         ChannelDetails_set_is_public(&this_ptr_conv, val);
21447 }
21448
21449 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) {
21450         LDKThirtyTwoBytes channel_id_arg_ref;
21451         CHECK(channel_id_arg->arr_len == 32);
21452         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
21453         LDKChannelCounterparty counterparty_arg_conv;
21454         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
21455         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
21456         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
21457         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
21458         LDKOutPoint funding_txo_arg_conv;
21459         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
21460         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
21461         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
21462         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
21463         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
21464         CHECK_ACCESS(short_channel_id_arg_ptr);
21465         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
21466         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
21467         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
21468         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
21469         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
21470         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
21471         CHECK_ACCESS(confirmations_required_arg_ptr);
21472         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
21473         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
21474         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
21475         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
21476         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
21477         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
21478         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);
21479         uintptr_t ret_ref = 0;
21480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21483         ret_ref = (uintptr_t)ret_var.inner;
21484         if (ret_var.is_owned) {
21485                 ret_ref |= 1;
21486         }
21487         return ret_ref;
21488 }
21489
21490 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
21491         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
21492 uintptr_t ret_ref = 0;
21493 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21494 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21495 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21496 ret_ref = (uintptr_t)ret_var.inner;
21497 if (ret_var.is_owned) {
21498         ret_ref |= 1;
21499 }
21500         return ret_ref;
21501 }
21502 intptr_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
21503         LDKChannelDetails arg_conv;
21504         arg_conv.inner = (void*)(arg & (~1));
21505         arg_conv.is_owned = false;
21506         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21507         intptr_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
21508         return ret_val;
21509 }
21510
21511 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
21512         LDKChannelDetails orig_conv;
21513         orig_conv.inner = (void*)(orig & (~1));
21514         orig_conv.is_owned = false;
21515         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21516         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
21517         uintptr_t ret_ref = 0;
21518         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21519         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21521         ret_ref = (uintptr_t)ret_var.inner;
21522         if (ret_var.is_owned) {
21523                 ret_ref |= 1;
21524         }
21525         return ret_ref;
21526 }
21527
21528 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
21529         if ((this_ptr & 1) != 0) return;
21530         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21531         CHECK_ACCESS(this_ptr_ptr);
21532         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
21533         FREE((void*)this_ptr);
21534         PaymentSendFailure_free(this_ptr_conv);
21535 }
21536
21537 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
21538         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21539         *ret_copy = PaymentSendFailure_clone(arg);
21540 uintptr_t ret_ref = (uintptr_t)ret_copy;
21541         return ret_ref;
21542 }
21543 intptr_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
21544         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
21545         intptr_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
21546         return ret_val;
21547 }
21548
21549 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
21550         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
21551         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21552         *ret_copy = PaymentSendFailure_clone(orig_conv);
21553         uintptr_t ret_ref = (uintptr_t)ret_copy;
21554         return ret_ref;
21555 }
21556
21557 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
21558         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
21559         CHECK_ACCESS(a_ptr);
21560         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
21561         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
21562         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21563         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
21564         uintptr_t ret_ref = (uintptr_t)ret_copy;
21565         return ret_ref;
21566 }
21567
21568 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
21569         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
21570         a_constr.datalen = a->arr_len;
21571         if (a_constr.datalen > 0)
21572                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
21573         else
21574                 a_constr.data = NULL;
21575         uint32_t* a_vals = a->elems /* XXX a leaks */;
21576         for (size_t w = 0; w < a_constr.datalen; w++) {
21577                 uint32_t a_conv_22 = a_vals[w];
21578                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
21579                 CHECK_ACCESS(a_conv_22_ptr);
21580                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
21581                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
21582                 a_constr.data[w] = a_conv_22_conv;
21583         }
21584         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21585         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
21586         uintptr_t ret_ref = (uintptr_t)ret_copy;
21587         return ret_ref;
21588 }
21589
21590 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
21591         LDKCVec_APIErrorZ a_constr;
21592         a_constr.datalen = a->arr_len;
21593         if (a_constr.datalen > 0)
21594                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
21595         else
21596                 a_constr.data = NULL;
21597         uint32_t* a_vals = a->elems /* XXX a leaks */;
21598         for (size_t k = 0; k < a_constr.datalen; k++) {
21599                 uint32_t a_conv_10 = a_vals[k];
21600                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
21601                 CHECK_ACCESS(a_conv_10_ptr);
21602                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
21603                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
21604                 a_constr.data[k] = a_conv_10_conv;
21605         }
21606         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21607         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
21608         uintptr_t ret_ref = (uintptr_t)ret_copy;
21609         return ret_ref;
21610 }
21611
21612 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) {
21613         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
21614         results_constr.datalen = results->arr_len;
21615         if (results_constr.datalen > 0)
21616                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
21617         else
21618                 results_constr.data = NULL;
21619         uint32_t* results_vals = results->elems /* XXX results leaks */;
21620         for (size_t w = 0; w < results_constr.datalen; w++) {
21621                 uint32_t results_conv_22 = results_vals[w];
21622                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
21623                 CHECK_ACCESS(results_conv_22_ptr);
21624                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
21625                 results_constr.data[w] = results_conv_22_conv;
21626         }
21627         LDKRouteParameters failed_paths_retry_conv;
21628         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
21629         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
21630         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
21631         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
21632         LDKThirtyTwoBytes payment_id_ref;
21633         CHECK(payment_id->arr_len == 32);
21634         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21635         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
21636         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
21637         uintptr_t ret_ref = (uintptr_t)ret_copy;
21638         return ret_ref;
21639 }
21640
21641 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) {
21642         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
21643         CHECK_ACCESS(fee_est_ptr);
21644         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
21645         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
21646         CHECK_ACCESS(chain_monitor_ptr);
21647         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
21648         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
21649         CHECK_ACCESS(tx_broadcaster_ptr);
21650         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
21651         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
21652         CHECK_ACCESS(logger_ptr);
21653         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21654         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
21655         CHECK_ACCESS(keys_manager_ptr);
21656         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
21657         LDKUserConfig config_conv;
21658         config_conv.inner = (void*)(config & (~1));
21659         config_conv.is_owned = (config & 1) || (config == 0);
21660         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
21661         config_conv = UserConfig_clone(&config_conv);
21662         LDKChainParameters params_conv;
21663         params_conv.inner = (void*)(params & (~1));
21664         params_conv.is_owned = (params & 1) || (params == 0);
21665         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
21666         params_conv = ChainParameters_clone(&params_conv);
21667         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
21668         uintptr_t ret_ref = 0;
21669         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21670         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21672         ret_ref = (uintptr_t)ret_var.inner;
21673         if (ret_var.is_owned) {
21674                 ret_ref |= 1;
21675         }
21676         return ret_ref;
21677 }
21678
21679 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
21680         LDKChannelManager this_arg_conv;
21681         this_arg_conv.inner = (void*)(this_arg & (~1));
21682         this_arg_conv.is_owned = false;
21683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21684         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
21685         uintptr_t ret_ref = 0;
21686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21689         ret_ref = (uintptr_t)ret_var.inner;
21690         if (ret_var.is_owned) {
21691                 ret_ref |= 1;
21692         }
21693         return ret_ref;
21694 }
21695
21696 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) {
21697         LDKChannelManager this_arg_conv;
21698         this_arg_conv.inner = (void*)(this_arg & (~1));
21699         this_arg_conv.is_owned = false;
21700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21701         LDKPublicKey their_network_key_ref;
21702         CHECK(their_network_key->arr_len == 33);
21703         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
21704         LDKUserConfig override_config_conv;
21705         override_config_conv.inner = (void*)(override_config & (~1));
21706         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
21707         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
21708         override_config_conv = UserConfig_clone(&override_config_conv);
21709         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
21710         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
21711         return (uintptr_t)ret_conv;
21712 }
21713
21714 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
21715         LDKChannelManager this_arg_conv;
21716         this_arg_conv.inner = (void*)(this_arg & (~1));
21717         this_arg_conv.is_owned = false;
21718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21719         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
21720         uint32_tArray ret_arr = NULL;
21721         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21722         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21723         for (size_t q = 0; q < ret_var.datalen; q++) {
21724                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
21725                 uintptr_t ret_conv_16_ref = 0;
21726                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21727                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21728                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
21729                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
21730                 if (ret_conv_16_var.is_owned) {
21731                         ret_conv_16_ref |= 1;
21732                 }
21733                 ret_arr_ptr[q] = ret_conv_16_ref;
21734         }
21735         
21736         FREE(ret_var.data);
21737         return ret_arr;
21738 }
21739
21740 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
21741         LDKChannelManager this_arg_conv;
21742         this_arg_conv.inner = (void*)(this_arg & (~1));
21743         this_arg_conv.is_owned = false;
21744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21745         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
21746         uint32_tArray ret_arr = NULL;
21747         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21748         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21749         for (size_t q = 0; q < ret_var.datalen; q++) {
21750                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
21751                 uintptr_t ret_conv_16_ref = 0;
21752                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21753                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21754                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
21755                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
21756                 if (ret_conv_16_var.is_owned) {
21757                         ret_conv_16_ref |= 1;
21758                 }
21759                 ret_arr_ptr[q] = ret_conv_16_ref;
21760         }
21761         
21762         FREE(ret_var.data);
21763         return ret_arr;
21764 }
21765
21766 uint32_t  __attribute__((export_name("TS_ChannelManager_close_channel"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
21767         LDKChannelManager this_arg_conv;
21768         this_arg_conv.inner = (void*)(this_arg & (~1));
21769         this_arg_conv.is_owned = false;
21770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21771         unsigned char channel_id_arr[32];
21772         CHECK(channel_id->arr_len == 32);
21773         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
21774         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21775         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21776         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
21777         return (uintptr_t)ret_conv;
21778 }
21779
21780 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) {
21781         LDKChannelManager this_arg_conv;
21782         this_arg_conv.inner = (void*)(this_arg & (~1));
21783         this_arg_conv.is_owned = false;
21784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21785         unsigned char channel_id_arr[32];
21786         CHECK(channel_id->arr_len == 32);
21787         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
21788         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21789         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21790         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
21791         return (uintptr_t)ret_conv;
21792 }
21793
21794 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_channel"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
21795         LDKChannelManager this_arg_conv;
21796         this_arg_conv.inner = (void*)(this_arg & (~1));
21797         this_arg_conv.is_owned = false;
21798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21799         unsigned char channel_id_arr[32];
21800         CHECK(channel_id->arr_len == 32);
21801         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
21802         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
21803         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21804         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
21805         return (uintptr_t)ret_conv;
21806 }
21807
21808 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
21809         LDKChannelManager this_arg_conv;
21810         this_arg_conv.inner = (void*)(this_arg & (~1));
21811         this_arg_conv.is_owned = false;
21812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21813         ChannelManager_force_close_all_channels(&this_arg_conv);
21814 }
21815
21816 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) {
21817         LDKChannelManager this_arg_conv;
21818         this_arg_conv.inner = (void*)(this_arg & (~1));
21819         this_arg_conv.is_owned = false;
21820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21821         LDKRoute route_conv;
21822         route_conv.inner = (void*)(route & (~1));
21823         route_conv.is_owned = false;
21824         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21825         LDKThirtyTwoBytes payment_hash_ref;
21826         CHECK(payment_hash->arr_len == 32);
21827         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
21828         LDKThirtyTwoBytes payment_secret_ref;
21829         CHECK(payment_secret->arr_len == 32);
21830         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
21831         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
21832         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
21833         return (uintptr_t)ret_conv;
21834 }
21835
21836 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
21837         LDKChannelManager this_arg_conv;
21838         this_arg_conv.inner = (void*)(this_arg & (~1));
21839         this_arg_conv.is_owned = false;
21840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21841         LDKRoute route_conv;
21842         route_conv.inner = (void*)(route & (~1));
21843         route_conv.is_owned = false;
21844         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21845         LDKThirtyTwoBytes payment_id_ref;
21846         CHECK(payment_id->arr_len == 32);
21847         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21848         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
21849         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
21850         return (uintptr_t)ret_conv;
21851 }
21852
21853 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
21854         LDKChannelManager this_arg_conv;
21855         this_arg_conv.inner = (void*)(this_arg & (~1));
21856         this_arg_conv.is_owned = false;
21857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21858         LDKThirtyTwoBytes payment_id_ref;
21859         CHECK(payment_id->arr_len == 32);
21860         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
21861         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
21862 }
21863
21864 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) {
21865         LDKChannelManager this_arg_conv;
21866         this_arg_conv.inner = (void*)(this_arg & (~1));
21867         this_arg_conv.is_owned = false;
21868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21869         LDKRoute route_conv;
21870         route_conv.inner = (void*)(route & (~1));
21871         route_conv.is_owned = false;
21872         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
21873         LDKThirtyTwoBytes payment_preimage_ref;
21874         CHECK(payment_preimage->arr_len == 32);
21875         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
21876         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21877         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
21878         return (uintptr_t)ret_conv;
21879 }
21880
21881 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) {
21882         LDKChannelManager this_arg_conv;
21883         this_arg_conv.inner = (void*)(this_arg & (~1));
21884         this_arg_conv.is_owned = false;
21885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21886         unsigned char temporary_channel_id_arr[32];
21887         CHECK(temporary_channel_id->arr_len == 32);
21888         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
21889         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
21890         LDKTransaction funding_transaction_ref;
21891         funding_transaction_ref.datalen = funding_transaction->arr_len;
21892         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
21893         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
21894         funding_transaction_ref.data_is_owned = true;
21895         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21896         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
21897         return (uintptr_t)ret_conv;
21898 }
21899
21900 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) {
21901         LDKChannelManager this_arg_conv;
21902         this_arg_conv.inner = (void*)(this_arg & (~1));
21903         this_arg_conv.is_owned = false;
21904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21905         LDKThreeBytes rgb_ref;
21906         CHECK(rgb->arr_len == 3);
21907         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
21908         LDKThirtyTwoBytes alias_ref;
21909         CHECK(alias->arr_len == 32);
21910         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
21911         LDKCVec_NetAddressZ addresses_constr;
21912         addresses_constr.datalen = addresses->arr_len;
21913         if (addresses_constr.datalen > 0)
21914                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
21915         else
21916                 addresses_constr.data = NULL;
21917         uint32_t* addresses_vals = addresses->elems /* XXX addresses leaks */;
21918         for (size_t m = 0; m < addresses_constr.datalen; m++) {
21919                 uint32_t addresses_conv_12 = addresses_vals[m];
21920                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
21921                 CHECK_ACCESS(addresses_conv_12_ptr);
21922                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
21923                 addresses_constr.data[m] = addresses_conv_12_conv;
21924         }
21925         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
21926 }
21927
21928 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
21929         LDKChannelManager this_arg_conv;
21930         this_arg_conv.inner = (void*)(this_arg & (~1));
21931         this_arg_conv.is_owned = false;
21932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21933         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
21934 }
21935
21936 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
21937         LDKChannelManager this_arg_conv;
21938         this_arg_conv.inner = (void*)(this_arg & (~1));
21939         this_arg_conv.is_owned = false;
21940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21941         ChannelManager_timer_tick_occurred(&this_arg_conv);
21942 }
21943
21944 jboolean  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
21945         LDKChannelManager this_arg_conv;
21946         this_arg_conv.inner = (void*)(this_arg & (~1));
21947         this_arg_conv.is_owned = false;
21948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21949         unsigned char payment_hash_arr[32];
21950         CHECK(payment_hash->arr_len == 32);
21951         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
21952         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
21953         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
21954         return ret_val;
21955 }
21956
21957 jboolean  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
21958         LDKChannelManager this_arg_conv;
21959         this_arg_conv.inner = (void*)(this_arg & (~1));
21960         this_arg_conv.is_owned = false;
21961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21962         LDKThirtyTwoBytes payment_preimage_ref;
21963         CHECK(payment_preimage->arr_len == 32);
21964         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
21965         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
21966         return ret_val;
21967 }
21968
21969 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
21970         LDKChannelManager this_arg_conv;
21971         this_arg_conv.inner = (void*)(this_arg & (~1));
21972         this_arg_conv.is_owned = false;
21973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21974         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
21975         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
21976         return ret_arr;
21977 }
21978
21979 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) {
21980         LDKChannelManager this_arg_conv;
21981         this_arg_conv.inner = (void*)(this_arg & (~1));
21982         this_arg_conv.is_owned = false;
21983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21984         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
21985         CHECK_ACCESS(min_value_msat_ptr);
21986         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
21987         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
21988         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21989         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
21990         return (uintptr_t)ret_conv;
21991 }
21992
21993 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) {
21994         LDKChannelManager this_arg_conv;
21995         this_arg_conv.inner = (void*)(this_arg & (~1));
21996         this_arg_conv.is_owned = false;
21997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21998         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
21999         CHECK_ACCESS(min_value_msat_ptr);
22000         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
22001         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
22002         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
22003         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
22004         return (uintptr_t)ret_conv;
22005 }
22006
22007 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) {
22008         LDKChannelManager this_arg_conv;
22009         this_arg_conv.inner = (void*)(this_arg & (~1));
22010         this_arg_conv.is_owned = false;
22011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22012         LDKThirtyTwoBytes payment_hash_ref;
22013         CHECK(payment_hash->arr_len == 32);
22014         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
22015         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
22016         CHECK_ACCESS(min_value_msat_ptr);
22017         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
22018         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
22019         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
22020         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
22021         return (uintptr_t)ret_conv;
22022 }
22023
22024 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) {
22025         LDKChannelManager this_arg_conv;
22026         this_arg_conv.inner = (void*)(this_arg & (~1));
22027         this_arg_conv.is_owned = false;
22028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22029         LDKThirtyTwoBytes payment_hash_ref;
22030         CHECK(payment_hash->arr_len == 32);
22031         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
22032         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
22033         CHECK_ACCESS(min_value_msat_ptr);
22034         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
22035         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
22036         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
22037         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
22038         return (uintptr_t)ret_conv;
22039 }
22040
22041 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) {
22042         LDKChannelManager this_arg_conv;
22043         this_arg_conv.inner = (void*)(this_arg & (~1));
22044         this_arg_conv.is_owned = false;
22045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22046         LDKThirtyTwoBytes payment_hash_ref;
22047         CHECK(payment_hash->arr_len == 32);
22048         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
22049         LDKThirtyTwoBytes payment_secret_ref;
22050         CHECK(payment_secret->arr_len == 32);
22051         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
22052         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
22053         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
22054         return (uintptr_t)ret_conv;
22055 }
22056
22057 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
22058         LDKChannelManager this_arg_conv;
22059         this_arg_conv.inner = (void*)(this_arg & (~1));
22060         this_arg_conv.is_owned = false;
22061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22062         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
22063         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
22064         return (uintptr_t)ret_ret;
22065 }
22066
22067 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
22068         LDKChannelManager this_arg_conv;
22069         this_arg_conv.inner = (void*)(this_arg & (~1));
22070         this_arg_conv.is_owned = false;
22071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22072         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
22073         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
22074         return (uintptr_t)ret_ret;
22075 }
22076
22077 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
22078         LDKChannelManager this_arg_conv;
22079         this_arg_conv.inner = (void*)(this_arg & (~1));
22080         this_arg_conv.is_owned = false;
22081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22082         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
22083         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
22084         return (uintptr_t)ret_ret;
22085 }
22086
22087 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
22088         LDKChannelManager this_arg_conv;
22089         this_arg_conv.inner = (void*)(this_arg & (~1));
22090         this_arg_conv.is_owned = false;
22091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22092         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
22093         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
22094         return (uintptr_t)ret_ret;
22095 }
22096
22097 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
22098         LDKChannelManager this_arg_conv;
22099         this_arg_conv.inner = (void*)(this_arg & (~1));
22100         this_arg_conv.is_owned = false;
22101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22102         ChannelManager_await_persistable_update(&this_arg_conv);
22103 }
22104
22105 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
22106         LDKChannelManager this_arg_conv;
22107         this_arg_conv.inner = (void*)(this_arg & (~1));
22108         this_arg_conv.is_owned = false;
22109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22110         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
22111         uintptr_t ret_ref = 0;
22112         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22113         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22115         ret_ref = (uintptr_t)ret_var.inner;
22116         if (ret_var.is_owned) {
22117                 ret_ref |= 1;
22118         }
22119         return ret_ref;
22120 }
22121
22122 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
22123         LDKChannelManager this_arg_conv;
22124         this_arg_conv.inner = (void*)(this_arg & (~1));
22125         this_arg_conv.is_owned = false;
22126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22127         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
22128         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
22129         return (uintptr_t)ret_ret;
22130 }
22131
22132 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
22133         LDKChannelManager obj_conv;
22134         obj_conv.inner = (void*)(obj & (~1));
22135         obj_conv.is_owned = false;
22136         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22137         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
22138         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22139         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22140         CVec_u8Z_free(ret_var);
22141         return ret_arr;
22142 }
22143
22144 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
22145         LDKChannelManagerReadArgs this_obj_conv;
22146         this_obj_conv.inner = (void*)(this_obj & (~1));
22147         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22149         ChannelManagerReadArgs_free(this_obj_conv);
22150 }
22151
22152 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
22153         LDKChannelManagerReadArgs this_ptr_conv;
22154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22155         this_ptr_conv.is_owned = false;
22156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22157         // WARNING: This object doesn't live past this scope, needs clone!
22158         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
22159         return ret_ret;
22160 }
22161
22162 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
22163         LDKChannelManagerReadArgs this_ptr_conv;
22164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22165         this_ptr_conv.is_owned = false;
22166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22167         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22168         CHECK_ACCESS(val_ptr);
22169         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
22170         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
22171 }
22172
22173 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
22174         LDKChannelManagerReadArgs this_ptr_conv;
22175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22176         this_ptr_conv.is_owned = false;
22177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22178         // WARNING: This object doesn't live past this scope, needs clone!
22179         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
22180         return ret_ret;
22181 }
22182
22183 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
22184         LDKChannelManagerReadArgs this_ptr_conv;
22185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22186         this_ptr_conv.is_owned = false;
22187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22188         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22189         CHECK_ACCESS(val_ptr);
22190         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
22191         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
22192 }
22193
22194 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
22195         LDKChannelManagerReadArgs this_ptr_conv;
22196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22197         this_ptr_conv.is_owned = false;
22198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22199         // WARNING: This object doesn't live past this scope, needs clone!
22200         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
22201         return ret_ret;
22202 }
22203
22204 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
22205         LDKChannelManagerReadArgs this_ptr_conv;
22206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22207         this_ptr_conv.is_owned = false;
22208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22209         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22210         CHECK_ACCESS(val_ptr);
22211         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
22212         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
22213 }
22214
22215 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
22216         LDKChannelManagerReadArgs this_ptr_conv;
22217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22218         this_ptr_conv.is_owned = false;
22219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22220         // WARNING: This object doesn't live past this scope, needs clone!
22221         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
22222         return ret_ret;
22223 }
22224
22225 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
22226         LDKChannelManagerReadArgs this_ptr_conv;
22227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22228         this_ptr_conv.is_owned = false;
22229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22230         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22231         CHECK_ACCESS(val_ptr);
22232         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
22233         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
22234 }
22235
22236 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
22237         LDKChannelManagerReadArgs this_ptr_conv;
22238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22239         this_ptr_conv.is_owned = false;
22240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22241         // WARNING: This object doesn't live past this scope, needs clone!
22242         uintptr_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
22243         return ret_ret;
22244 }
22245
22246 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
22247         LDKChannelManagerReadArgs this_ptr_conv;
22248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22249         this_ptr_conv.is_owned = false;
22250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22251         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
22252         CHECK_ACCESS(val_ptr);
22253         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
22254         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
22255 }
22256
22257 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
22258         LDKChannelManagerReadArgs this_ptr_conv;
22259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22260         this_ptr_conv.is_owned = false;
22261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22262         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
22263         uintptr_t ret_ref = 0;
22264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22267         ret_ref = (uintptr_t)ret_var.inner;
22268         if (ret_var.is_owned) {
22269                 ret_ref |= 1;
22270         }
22271         return ret_ref;
22272 }
22273
22274 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
22275         LDKChannelManagerReadArgs this_ptr_conv;
22276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22277         this_ptr_conv.is_owned = false;
22278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22279         LDKUserConfig val_conv;
22280         val_conv.inner = (void*)(val & (~1));
22281         val_conv.is_owned = (val & 1) || (val == 0);
22282         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22283         val_conv = UserConfig_clone(&val_conv);
22284         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
22285 }
22286
22287 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) {
22288         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
22289         CHECK_ACCESS(keys_manager_ptr);
22290         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
22291         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22292         CHECK_ACCESS(fee_estimator_ptr);
22293         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22294         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
22295         CHECK_ACCESS(chain_monitor_ptr);
22296         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
22297         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
22298         CHECK_ACCESS(tx_broadcaster_ptr);
22299         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
22300         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22301         CHECK_ACCESS(logger_ptr);
22302         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22303         LDKUserConfig default_config_conv;
22304         default_config_conv.inner = (void*)(default_config & (~1));
22305         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
22306         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
22307         default_config_conv = UserConfig_clone(&default_config_conv);
22308         LDKCVec_ChannelMonitorZ channel_monitors_constr;
22309         channel_monitors_constr.datalen = channel_monitors->arr_len;
22310         if (channel_monitors_constr.datalen > 0)
22311                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
22312         else
22313                 channel_monitors_constr.data = NULL;
22314         uint32_t* channel_monitors_vals = channel_monitors->elems /* XXX channel_monitors leaks */;
22315         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
22316                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
22317                 LDKChannelMonitor channel_monitors_conv_16_conv;
22318                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
22319                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
22320                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
22321                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
22322         }
22323         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);
22324         uintptr_t ret_ref = 0;
22325         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22326         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22328         ret_ref = (uintptr_t)ret_var.inner;
22329         if (ret_var.is_owned) {
22330                 ret_ref |= 1;
22331         }
22332         return ret_ref;
22333 }
22334
22335 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
22336         LDKu8slice ser_ref;
22337         ser_ref.datalen = ser->arr_len;
22338         ser_ref.data = ser->elems /* XXX ser leaks */;
22339         LDKChannelManagerReadArgs arg_conv;
22340         arg_conv.inner = (void*)(arg & (~1));
22341         arg_conv.is_owned = (arg & 1) || (arg == 0);
22342         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22343         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
22344         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
22345         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
22346         return (uintptr_t)ret_conv;
22347 }
22348
22349 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
22350         LDKDecodeError this_obj_conv;
22351         this_obj_conv.inner = (void*)(this_obj & (~1));
22352         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22354         DecodeError_free(this_obj_conv);
22355 }
22356
22357 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
22358         LDKDecodeError ret_var = DecodeError_clone(arg);
22359 uintptr_t ret_ref = 0;
22360 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22361 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22362 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22363 ret_ref = (uintptr_t)ret_var.inner;
22364 if (ret_var.is_owned) {
22365         ret_ref |= 1;
22366 }
22367         return ret_ref;
22368 }
22369 intptr_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
22370         LDKDecodeError arg_conv;
22371         arg_conv.inner = (void*)(arg & (~1));
22372         arg_conv.is_owned = false;
22373         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22374         intptr_t ret_val = DecodeError_clone_ptr(&arg_conv);
22375         return ret_val;
22376 }
22377
22378 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
22379         LDKDecodeError orig_conv;
22380         orig_conv.inner = (void*)(orig & (~1));
22381         orig_conv.is_owned = false;
22382         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22383         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
22384         uintptr_t ret_ref = 0;
22385         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22386         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22388         ret_ref = (uintptr_t)ret_var.inner;
22389         if (ret_var.is_owned) {
22390                 ret_ref |= 1;
22391         }
22392         return ret_ref;
22393 }
22394
22395 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
22396         LDKInit this_obj_conv;
22397         this_obj_conv.inner = (void*)(this_obj & (~1));
22398         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22400         Init_free(this_obj_conv);
22401 }
22402
22403 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
22404         LDKInit this_ptr_conv;
22405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22406         this_ptr_conv.is_owned = false;
22407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22408         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
22409         uintptr_t ret_ref = 0;
22410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22413         ret_ref = (uintptr_t)ret_var.inner;
22414         if (ret_var.is_owned) {
22415                 ret_ref |= 1;
22416         }
22417         return ret_ref;
22418 }
22419
22420 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
22421         LDKInit this_ptr_conv;
22422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22423         this_ptr_conv.is_owned = false;
22424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22425         LDKInitFeatures val_conv;
22426         val_conv.inner = (void*)(val & (~1));
22427         val_conv.is_owned = (val & 1) || (val == 0);
22428         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22429         val_conv = InitFeatures_clone(&val_conv);
22430         Init_set_features(&this_ptr_conv, val_conv);
22431 }
22432
22433 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg) {
22434         LDKInitFeatures features_arg_conv;
22435         features_arg_conv.inner = (void*)(features_arg & (~1));
22436         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
22437         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
22438         features_arg_conv = InitFeatures_clone(&features_arg_conv);
22439         LDKInit ret_var = Init_new(features_arg_conv);
22440         uintptr_t ret_ref = 0;
22441         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22442         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22444         ret_ref = (uintptr_t)ret_var.inner;
22445         if (ret_var.is_owned) {
22446                 ret_ref |= 1;
22447         }
22448         return ret_ref;
22449 }
22450
22451 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
22452         LDKInit ret_var = Init_clone(arg);
22453 uintptr_t ret_ref = 0;
22454 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22455 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22456 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22457 ret_ref = (uintptr_t)ret_var.inner;
22458 if (ret_var.is_owned) {
22459         ret_ref |= 1;
22460 }
22461         return ret_ref;
22462 }
22463 intptr_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
22464         LDKInit arg_conv;
22465         arg_conv.inner = (void*)(arg & (~1));
22466         arg_conv.is_owned = false;
22467         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22468         intptr_t ret_val = Init_clone_ptr(&arg_conv);
22469         return ret_val;
22470 }
22471
22472 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
22473         LDKInit orig_conv;
22474         orig_conv.inner = (void*)(orig & (~1));
22475         orig_conv.is_owned = false;
22476         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22477         LDKInit ret_var = Init_clone(&orig_conv);
22478         uintptr_t ret_ref = 0;
22479         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22480         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22482         ret_ref = (uintptr_t)ret_var.inner;
22483         if (ret_var.is_owned) {
22484                 ret_ref |= 1;
22485         }
22486         return ret_ref;
22487 }
22488
22489 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
22490         LDKErrorMessage this_obj_conv;
22491         this_obj_conv.inner = (void*)(this_obj & (~1));
22492         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22494         ErrorMessage_free(this_obj_conv);
22495 }
22496
22497 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
22498         LDKErrorMessage this_ptr_conv;
22499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22500         this_ptr_conv.is_owned = false;
22501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22502         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22503         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
22504         return ret_arr;
22505 }
22506
22507 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
22508         LDKErrorMessage this_ptr_conv;
22509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22510         this_ptr_conv.is_owned = false;
22511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22512         LDKThirtyTwoBytes val_ref;
22513         CHECK(val->arr_len == 32);
22514         memcpy(val_ref.data, val->elems, 32); FREE(val);
22515         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
22516 }
22517
22518 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
22519         LDKErrorMessage this_ptr_conv;
22520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22521         this_ptr_conv.is_owned = false;
22522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22523         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
22524         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
22525         Str_free(ret_str);
22526         return ret_conv;
22527 }
22528
22529 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
22530         LDKErrorMessage this_ptr_conv;
22531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22532         this_ptr_conv.is_owned = false;
22533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22534         LDKStr val_conv = str_ref_to_owned_c(val);
22535         ErrorMessage_set_data(&this_ptr_conv, val_conv);
22536 }
22537
22538 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
22539         LDKThirtyTwoBytes channel_id_arg_ref;
22540         CHECK(channel_id_arg->arr_len == 32);
22541         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
22542         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
22543         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
22544         uintptr_t ret_ref = 0;
22545         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22546         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22548         ret_ref = (uintptr_t)ret_var.inner;
22549         if (ret_var.is_owned) {
22550                 ret_ref |= 1;
22551         }
22552         return ret_ref;
22553 }
22554
22555 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
22556         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
22557 uintptr_t ret_ref = 0;
22558 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22559 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22560 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22561 ret_ref = (uintptr_t)ret_var.inner;
22562 if (ret_var.is_owned) {
22563         ret_ref |= 1;
22564 }
22565         return ret_ref;
22566 }
22567 intptr_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
22568         LDKErrorMessage arg_conv;
22569         arg_conv.inner = (void*)(arg & (~1));
22570         arg_conv.is_owned = false;
22571         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22572         intptr_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
22573         return ret_val;
22574 }
22575
22576 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
22577         LDKErrorMessage orig_conv;
22578         orig_conv.inner = (void*)(orig & (~1));
22579         orig_conv.is_owned = false;
22580         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22581         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
22582         uintptr_t ret_ref = 0;
22583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22586         ret_ref = (uintptr_t)ret_var.inner;
22587         if (ret_var.is_owned) {
22588                 ret_ref |= 1;
22589         }
22590         return ret_ref;
22591 }
22592
22593 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
22594         LDKPing this_obj_conv;
22595         this_obj_conv.inner = (void*)(this_obj & (~1));
22596         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22598         Ping_free(this_obj_conv);
22599 }
22600
22601 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
22602         LDKPing this_ptr_conv;
22603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22604         this_ptr_conv.is_owned = false;
22605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22606         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
22607         return ret_val;
22608 }
22609
22610 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
22611         LDKPing this_ptr_conv;
22612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22613         this_ptr_conv.is_owned = false;
22614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22615         Ping_set_ponglen(&this_ptr_conv, val);
22616 }
22617
22618 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
22619         LDKPing this_ptr_conv;
22620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22621         this_ptr_conv.is_owned = false;
22622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22623         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
22624         return ret_val;
22625 }
22626
22627 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
22628         LDKPing this_ptr_conv;
22629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22630         this_ptr_conv.is_owned = false;
22631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22632         Ping_set_byteslen(&this_ptr_conv, val);
22633 }
22634
22635 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
22636         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
22637         uintptr_t ret_ref = 0;
22638         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22639         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22641         ret_ref = (uintptr_t)ret_var.inner;
22642         if (ret_var.is_owned) {
22643                 ret_ref |= 1;
22644         }
22645         return ret_ref;
22646 }
22647
22648 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
22649         LDKPing ret_var = Ping_clone(arg);
22650 uintptr_t ret_ref = 0;
22651 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22652 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22653 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22654 ret_ref = (uintptr_t)ret_var.inner;
22655 if (ret_var.is_owned) {
22656         ret_ref |= 1;
22657 }
22658         return ret_ref;
22659 }
22660 intptr_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
22661         LDKPing arg_conv;
22662         arg_conv.inner = (void*)(arg & (~1));
22663         arg_conv.is_owned = false;
22664         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22665         intptr_t ret_val = Ping_clone_ptr(&arg_conv);
22666         return ret_val;
22667 }
22668
22669 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
22670         LDKPing orig_conv;
22671         orig_conv.inner = (void*)(orig & (~1));
22672         orig_conv.is_owned = false;
22673         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22674         LDKPing ret_var = Ping_clone(&orig_conv);
22675         uintptr_t ret_ref = 0;
22676         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22677         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22679         ret_ref = (uintptr_t)ret_var.inner;
22680         if (ret_var.is_owned) {
22681                 ret_ref |= 1;
22682         }
22683         return ret_ref;
22684 }
22685
22686 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
22687         LDKPong this_obj_conv;
22688         this_obj_conv.inner = (void*)(this_obj & (~1));
22689         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22691         Pong_free(this_obj_conv);
22692 }
22693
22694 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
22695         LDKPong this_ptr_conv;
22696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22697         this_ptr_conv.is_owned = false;
22698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22699         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
22700         return ret_val;
22701 }
22702
22703 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
22704         LDKPong this_ptr_conv;
22705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22706         this_ptr_conv.is_owned = false;
22707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22708         Pong_set_byteslen(&this_ptr_conv, val);
22709 }
22710
22711 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
22712         LDKPong ret_var = Pong_new(byteslen_arg);
22713         uintptr_t ret_ref = 0;
22714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22717         ret_ref = (uintptr_t)ret_var.inner;
22718         if (ret_var.is_owned) {
22719                 ret_ref |= 1;
22720         }
22721         return ret_ref;
22722 }
22723
22724 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
22725         LDKPong ret_var = Pong_clone(arg);
22726 uintptr_t ret_ref = 0;
22727 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22728 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22729 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22730 ret_ref = (uintptr_t)ret_var.inner;
22731 if (ret_var.is_owned) {
22732         ret_ref |= 1;
22733 }
22734         return ret_ref;
22735 }
22736 intptr_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
22737         LDKPong arg_conv;
22738         arg_conv.inner = (void*)(arg & (~1));
22739         arg_conv.is_owned = false;
22740         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22741         intptr_t ret_val = Pong_clone_ptr(&arg_conv);
22742         return ret_val;
22743 }
22744
22745 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
22746         LDKPong orig_conv;
22747         orig_conv.inner = (void*)(orig & (~1));
22748         orig_conv.is_owned = false;
22749         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22750         LDKPong ret_var = Pong_clone(&orig_conv);
22751         uintptr_t ret_ref = 0;
22752         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22753         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22755         ret_ref = (uintptr_t)ret_var.inner;
22756         if (ret_var.is_owned) {
22757                 ret_ref |= 1;
22758         }
22759         return ret_ref;
22760 }
22761
22762 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
22763         LDKOpenChannel this_obj_conv;
22764         this_obj_conv.inner = (void*)(this_obj & (~1));
22765         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22767         OpenChannel_free(this_obj_conv);
22768 }
22769
22770 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
22771         LDKOpenChannel this_ptr_conv;
22772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22773         this_ptr_conv.is_owned = false;
22774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22775         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22776         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
22777         return ret_arr;
22778 }
22779
22780 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
22781         LDKOpenChannel this_ptr_conv;
22782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22783         this_ptr_conv.is_owned = false;
22784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22785         LDKThirtyTwoBytes val_ref;
22786         CHECK(val->arr_len == 32);
22787         memcpy(val_ref.data, val->elems, 32); FREE(val);
22788         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
22789 }
22790
22791 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
22792         LDKOpenChannel this_ptr_conv;
22793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22794         this_ptr_conv.is_owned = false;
22795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22796         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22797         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
22798         return ret_arr;
22799 }
22800
22801 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
22802         LDKOpenChannel this_ptr_conv;
22803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22804         this_ptr_conv.is_owned = false;
22805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22806         LDKThirtyTwoBytes val_ref;
22807         CHECK(val->arr_len == 32);
22808         memcpy(val_ref.data, val->elems, 32); FREE(val);
22809         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
22810 }
22811
22812 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
22813         LDKOpenChannel this_ptr_conv;
22814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22815         this_ptr_conv.is_owned = false;
22816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22817         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
22818         return ret_val;
22819 }
22820
22821 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
22822         LDKOpenChannel this_ptr_conv;
22823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22824         this_ptr_conv.is_owned = false;
22825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22826         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
22827 }
22828
22829 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
22830         LDKOpenChannel this_ptr_conv;
22831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22832         this_ptr_conv.is_owned = false;
22833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22834         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
22835         return ret_val;
22836 }
22837
22838 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
22839         LDKOpenChannel this_ptr_conv;
22840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22841         this_ptr_conv.is_owned = false;
22842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22843         OpenChannel_set_push_msat(&this_ptr_conv, val);
22844 }
22845
22846 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
22847         LDKOpenChannel this_ptr_conv;
22848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22849         this_ptr_conv.is_owned = false;
22850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22851         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
22852         return ret_val;
22853 }
22854
22855 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
22856         LDKOpenChannel this_ptr_conv;
22857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22858         this_ptr_conv.is_owned = false;
22859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22860         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
22861 }
22862
22863 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) {
22864         LDKOpenChannel this_ptr_conv;
22865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22866         this_ptr_conv.is_owned = false;
22867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22868         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
22869         return ret_val;
22870 }
22871
22872 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) {
22873         LDKOpenChannel this_ptr_conv;
22874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22875         this_ptr_conv.is_owned = false;
22876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22877         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
22878 }
22879
22880 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
22881         LDKOpenChannel this_ptr_conv;
22882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22883         this_ptr_conv.is_owned = false;
22884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22885         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
22886         return ret_val;
22887 }
22888
22889 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
22890         LDKOpenChannel this_ptr_conv;
22891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22892         this_ptr_conv.is_owned = false;
22893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22894         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
22895 }
22896
22897 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
22898         LDKOpenChannel this_ptr_conv;
22899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22900         this_ptr_conv.is_owned = false;
22901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22902         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
22903         return ret_val;
22904 }
22905
22906 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
22907         LDKOpenChannel this_ptr_conv;
22908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22909         this_ptr_conv.is_owned = false;
22910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22911         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
22912 }
22913
22914 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
22915         LDKOpenChannel this_ptr_conv;
22916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22917         this_ptr_conv.is_owned = false;
22918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22919         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
22920         return ret_val;
22921 }
22922
22923 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
22924         LDKOpenChannel this_ptr_conv;
22925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22926         this_ptr_conv.is_owned = false;
22927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22928         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
22929 }
22930
22931 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
22932         LDKOpenChannel this_ptr_conv;
22933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22934         this_ptr_conv.is_owned = false;
22935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22936         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
22937         return ret_val;
22938 }
22939
22940 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
22941         LDKOpenChannel this_ptr_conv;
22942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22943         this_ptr_conv.is_owned = false;
22944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22945         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
22946 }
22947
22948 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
22949         LDKOpenChannel this_ptr_conv;
22950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22951         this_ptr_conv.is_owned = false;
22952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22953         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
22954         return ret_val;
22955 }
22956
22957 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
22958         LDKOpenChannel this_ptr_conv;
22959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22960         this_ptr_conv.is_owned = false;
22961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22962         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
22963 }
22964
22965 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
22966         LDKOpenChannel this_ptr_conv;
22967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22968         this_ptr_conv.is_owned = false;
22969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22970         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22971         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
22972         return ret_arr;
22973 }
22974
22975 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
22976         LDKOpenChannel this_ptr_conv;
22977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22978         this_ptr_conv.is_owned = false;
22979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22980         LDKPublicKey val_ref;
22981         CHECK(val->arr_len == 33);
22982         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
22983         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
22984 }
22985
22986 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
22987         LDKOpenChannel this_ptr_conv;
22988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22989         this_ptr_conv.is_owned = false;
22990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22991         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22992         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
22993         return ret_arr;
22994 }
22995
22996 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
22997         LDKOpenChannel this_ptr_conv;
22998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22999         this_ptr_conv.is_owned = false;
23000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23001         LDKPublicKey val_ref;
23002         CHECK(val->arr_len == 33);
23003         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23004         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
23005 }
23006
23007 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
23008         LDKOpenChannel this_ptr_conv;
23009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23010         this_ptr_conv.is_owned = false;
23011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23012         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23013         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
23014         return ret_arr;
23015 }
23016
23017 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
23018         LDKOpenChannel this_ptr_conv;
23019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23020         this_ptr_conv.is_owned = false;
23021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23022         LDKPublicKey val_ref;
23023         CHECK(val->arr_len == 33);
23024         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23025         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
23026 }
23027
23028 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
23029         LDKOpenChannel this_ptr_conv;
23030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23031         this_ptr_conv.is_owned = false;
23032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23033         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23034         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
23035         return ret_arr;
23036 }
23037
23038 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
23039         LDKOpenChannel this_ptr_conv;
23040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23041         this_ptr_conv.is_owned = false;
23042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23043         LDKPublicKey val_ref;
23044         CHECK(val->arr_len == 33);
23045         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23046         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
23047 }
23048
23049 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
23050         LDKOpenChannel this_ptr_conv;
23051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23052         this_ptr_conv.is_owned = false;
23053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23054         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23055         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
23056         return ret_arr;
23057 }
23058
23059 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
23060         LDKOpenChannel this_ptr_conv;
23061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23062         this_ptr_conv.is_owned = false;
23063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23064         LDKPublicKey val_ref;
23065         CHECK(val->arr_len == 33);
23066         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23067         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
23068 }
23069
23070 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
23071         LDKOpenChannel this_ptr_conv;
23072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23073         this_ptr_conv.is_owned = false;
23074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23075         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23076         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23077         return ret_arr;
23078 }
23079
23080 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) {
23081         LDKOpenChannel this_ptr_conv;
23082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23083         this_ptr_conv.is_owned = false;
23084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23085         LDKPublicKey val_ref;
23086         CHECK(val->arr_len == 33);
23087         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23088         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
23089 }
23090
23091 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
23092         LDKOpenChannel this_ptr_conv;
23093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23094         this_ptr_conv.is_owned = false;
23095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23096         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
23097         return ret_val;
23098 }
23099
23100 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
23101         LDKOpenChannel this_ptr_conv;
23102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23103         this_ptr_conv.is_owned = false;
23104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23105         OpenChannel_set_channel_flags(&this_ptr_conv, val);
23106 }
23107
23108 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
23109         LDKOpenChannel this_ptr_conv;
23110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23111         this_ptr_conv.is_owned = false;
23112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23113         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
23114         uintptr_t ret_ref = 0;
23115         if ((uintptr_t)ret_var.inner > 4096) {
23116                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23117                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23119                 ret_ref = (uintptr_t)ret_var.inner;
23120                 if (ret_var.is_owned) {
23121                         ret_ref |= 1;
23122                 }
23123         }
23124         return ret_ref;
23125 }
23126
23127 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
23128         LDKOpenChannel this_ptr_conv;
23129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23130         this_ptr_conv.is_owned = false;
23131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23132         LDKChannelTypeFeatures val_conv;
23133         val_conv.inner = (void*)(val & (~1));
23134         val_conv.is_owned = (val & 1) || (val == 0);
23135         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23136         val_conv = ChannelTypeFeatures_clone(&val_conv);
23137         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
23138 }
23139
23140 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
23141         LDKOpenChannel ret_var = OpenChannel_clone(arg);
23142 uintptr_t ret_ref = 0;
23143 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23144 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23145 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23146 ret_ref = (uintptr_t)ret_var.inner;
23147 if (ret_var.is_owned) {
23148         ret_ref |= 1;
23149 }
23150         return ret_ref;
23151 }
23152 intptr_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
23153         LDKOpenChannel arg_conv;
23154         arg_conv.inner = (void*)(arg & (~1));
23155         arg_conv.is_owned = false;
23156         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23157         intptr_t ret_val = OpenChannel_clone_ptr(&arg_conv);
23158         return ret_val;
23159 }
23160
23161 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
23162         LDKOpenChannel orig_conv;
23163         orig_conv.inner = (void*)(orig & (~1));
23164         orig_conv.is_owned = false;
23165         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23166         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
23167         uintptr_t ret_ref = 0;
23168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23171         ret_ref = (uintptr_t)ret_var.inner;
23172         if (ret_var.is_owned) {
23173                 ret_ref |= 1;
23174         }
23175         return ret_ref;
23176 }
23177
23178 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
23179         LDKAcceptChannel this_obj_conv;
23180         this_obj_conv.inner = (void*)(this_obj & (~1));
23181         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23183         AcceptChannel_free(this_obj_conv);
23184 }
23185
23186 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
23187         LDKAcceptChannel this_ptr_conv;
23188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23189         this_ptr_conv.is_owned = false;
23190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23191         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23192         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
23193         return ret_arr;
23194 }
23195
23196 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
23197         LDKAcceptChannel this_ptr_conv;
23198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23199         this_ptr_conv.is_owned = false;
23200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23201         LDKThirtyTwoBytes val_ref;
23202         CHECK(val->arr_len == 32);
23203         memcpy(val_ref.data, val->elems, 32); FREE(val);
23204         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
23205 }
23206
23207 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
23208         LDKAcceptChannel this_ptr_conv;
23209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23210         this_ptr_conv.is_owned = false;
23211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23212         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
23213         return ret_val;
23214 }
23215
23216 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
23217         LDKAcceptChannel this_ptr_conv;
23218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23219         this_ptr_conv.is_owned = false;
23220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23221         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
23222 }
23223
23224 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) {
23225         LDKAcceptChannel this_ptr_conv;
23226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23227         this_ptr_conv.is_owned = false;
23228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23229         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
23230         return ret_val;
23231 }
23232
23233 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) {
23234         LDKAcceptChannel this_ptr_conv;
23235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23236         this_ptr_conv.is_owned = false;
23237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23238         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
23239 }
23240
23241 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
23242         LDKAcceptChannel this_ptr_conv;
23243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23244         this_ptr_conv.is_owned = false;
23245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23246         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
23247         return ret_val;
23248 }
23249
23250 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
23251         LDKAcceptChannel this_ptr_conv;
23252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23253         this_ptr_conv.is_owned = false;
23254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23255         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
23256 }
23257
23258 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
23259         LDKAcceptChannel this_ptr_conv;
23260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23261         this_ptr_conv.is_owned = false;
23262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23263         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
23264         return ret_val;
23265 }
23266
23267 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
23268         LDKAcceptChannel this_ptr_conv;
23269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23270         this_ptr_conv.is_owned = false;
23271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23272         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
23273 }
23274
23275 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
23276         LDKAcceptChannel this_ptr_conv;
23277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23278         this_ptr_conv.is_owned = false;
23279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23280         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
23281         return ret_val;
23282 }
23283
23284 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
23285         LDKAcceptChannel this_ptr_conv;
23286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23287         this_ptr_conv.is_owned = false;
23288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23289         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
23290 }
23291
23292 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
23293         LDKAcceptChannel this_ptr_conv;
23294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23295         this_ptr_conv.is_owned = false;
23296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23297         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
23298         return ret_val;
23299 }
23300
23301 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
23302         LDKAcceptChannel this_ptr_conv;
23303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23304         this_ptr_conv.is_owned = false;
23305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23306         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
23307 }
23308
23309 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
23310         LDKAcceptChannel this_ptr_conv;
23311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23312         this_ptr_conv.is_owned = false;
23313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23314         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
23315         return ret_val;
23316 }
23317
23318 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
23319         LDKAcceptChannel this_ptr_conv;
23320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23321         this_ptr_conv.is_owned = false;
23322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23323         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
23324 }
23325
23326 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
23327         LDKAcceptChannel this_ptr_conv;
23328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23329         this_ptr_conv.is_owned = false;
23330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23331         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23332         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
23333         return ret_arr;
23334 }
23335
23336 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
23337         LDKAcceptChannel this_ptr_conv;
23338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23339         this_ptr_conv.is_owned = false;
23340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23341         LDKPublicKey val_ref;
23342         CHECK(val->arr_len == 33);
23343         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23344         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
23345 }
23346
23347 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
23348         LDKAcceptChannel this_ptr_conv;
23349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23350         this_ptr_conv.is_owned = false;
23351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23352         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23353         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
23354         return ret_arr;
23355 }
23356
23357 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
23358         LDKAcceptChannel this_ptr_conv;
23359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23360         this_ptr_conv.is_owned = false;
23361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23362         LDKPublicKey val_ref;
23363         CHECK(val->arr_len == 33);
23364         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23365         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
23366 }
23367
23368 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
23369         LDKAcceptChannel this_ptr_conv;
23370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23371         this_ptr_conv.is_owned = false;
23372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23373         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23374         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
23375         return ret_arr;
23376 }
23377
23378 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
23379         LDKAcceptChannel this_ptr_conv;
23380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23381         this_ptr_conv.is_owned = false;
23382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23383         LDKPublicKey val_ref;
23384         CHECK(val->arr_len == 33);
23385         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23386         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
23387 }
23388
23389 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
23390         LDKAcceptChannel this_ptr_conv;
23391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23392         this_ptr_conv.is_owned = false;
23393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23394         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23395         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
23396         return ret_arr;
23397 }
23398
23399 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
23400         LDKAcceptChannel this_ptr_conv;
23401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23402         this_ptr_conv.is_owned = false;
23403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23404         LDKPublicKey val_ref;
23405         CHECK(val->arr_len == 33);
23406         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23407         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
23408 }
23409
23410 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
23411         LDKAcceptChannel this_ptr_conv;
23412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23413         this_ptr_conv.is_owned = false;
23414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23415         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23416         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
23417         return ret_arr;
23418 }
23419
23420 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
23421         LDKAcceptChannel this_ptr_conv;
23422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23423         this_ptr_conv.is_owned = false;
23424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23425         LDKPublicKey val_ref;
23426         CHECK(val->arr_len == 33);
23427         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23428         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
23429 }
23430
23431 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
23432         LDKAcceptChannel this_ptr_conv;
23433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23434         this_ptr_conv.is_owned = false;
23435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23436         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23437         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23438         return ret_arr;
23439 }
23440
23441 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) {
23442         LDKAcceptChannel this_ptr_conv;
23443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23444         this_ptr_conv.is_owned = false;
23445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23446         LDKPublicKey val_ref;
23447         CHECK(val->arr_len == 33);
23448         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23449         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
23450 }
23451
23452 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
23453         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
23454 uintptr_t ret_ref = 0;
23455 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23456 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23457 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23458 ret_ref = (uintptr_t)ret_var.inner;
23459 if (ret_var.is_owned) {
23460         ret_ref |= 1;
23461 }
23462         return ret_ref;
23463 }
23464 intptr_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
23465         LDKAcceptChannel arg_conv;
23466         arg_conv.inner = (void*)(arg & (~1));
23467         arg_conv.is_owned = false;
23468         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23469         intptr_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
23470         return ret_val;
23471 }
23472
23473 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
23474         LDKAcceptChannel orig_conv;
23475         orig_conv.inner = (void*)(orig & (~1));
23476         orig_conv.is_owned = false;
23477         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23478         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
23479         uintptr_t ret_ref = 0;
23480         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23481         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23482         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23483         ret_ref = (uintptr_t)ret_var.inner;
23484         if (ret_var.is_owned) {
23485                 ret_ref |= 1;
23486         }
23487         return ret_ref;
23488 }
23489
23490 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
23491         LDKFundingCreated this_obj_conv;
23492         this_obj_conv.inner = (void*)(this_obj & (~1));
23493         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23495         FundingCreated_free(this_obj_conv);
23496 }
23497
23498 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
23499         LDKFundingCreated this_ptr_conv;
23500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23501         this_ptr_conv.is_owned = false;
23502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23503         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23504         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
23505         return ret_arr;
23506 }
23507
23508 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
23509         LDKFundingCreated this_ptr_conv;
23510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23511         this_ptr_conv.is_owned = false;
23512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23513         LDKThirtyTwoBytes val_ref;
23514         CHECK(val->arr_len == 32);
23515         memcpy(val_ref.data, val->elems, 32); FREE(val);
23516         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
23517 }
23518
23519 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
23520         LDKFundingCreated this_ptr_conv;
23521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23522         this_ptr_conv.is_owned = false;
23523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23524         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23525         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
23526         return ret_arr;
23527 }
23528
23529 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
23530         LDKFundingCreated this_ptr_conv;
23531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23532         this_ptr_conv.is_owned = false;
23533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23534         LDKThirtyTwoBytes val_ref;
23535         CHECK(val->arr_len == 32);
23536         memcpy(val_ref.data, val->elems, 32); FREE(val);
23537         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
23538 }
23539
23540 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
23541         LDKFundingCreated this_ptr_conv;
23542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23543         this_ptr_conv.is_owned = false;
23544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23545         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
23546         return ret_val;
23547 }
23548
23549 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
23550         LDKFundingCreated this_ptr_conv;
23551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23552         this_ptr_conv.is_owned = false;
23553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23554         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
23555 }
23556
23557 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
23558         LDKFundingCreated this_ptr_conv;
23559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23560         this_ptr_conv.is_owned = false;
23561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23562         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
23563         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
23564         return ret_arr;
23565 }
23566
23567 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
23568         LDKFundingCreated this_ptr_conv;
23569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23570         this_ptr_conv.is_owned = false;
23571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23572         LDKSignature val_ref;
23573         CHECK(val->arr_len == 64);
23574         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
23575         FundingCreated_set_signature(&this_ptr_conv, val_ref);
23576 }
23577
23578 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) {
23579         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
23580         CHECK(temporary_channel_id_arg->arr_len == 32);
23581         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
23582         LDKThirtyTwoBytes funding_txid_arg_ref;
23583         CHECK(funding_txid_arg->arr_len == 32);
23584         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
23585         LDKSignature signature_arg_ref;
23586         CHECK(signature_arg->arr_len == 64);
23587         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
23588         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
23589         uintptr_t ret_ref = 0;
23590         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23591         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23593         ret_ref = (uintptr_t)ret_var.inner;
23594         if (ret_var.is_owned) {
23595                 ret_ref |= 1;
23596         }
23597         return ret_ref;
23598 }
23599
23600 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
23601         LDKFundingCreated ret_var = FundingCreated_clone(arg);
23602 uintptr_t ret_ref = 0;
23603 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23604 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23605 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23606 ret_ref = (uintptr_t)ret_var.inner;
23607 if (ret_var.is_owned) {
23608         ret_ref |= 1;
23609 }
23610         return ret_ref;
23611 }
23612 intptr_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
23613         LDKFundingCreated arg_conv;
23614         arg_conv.inner = (void*)(arg & (~1));
23615         arg_conv.is_owned = false;
23616         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23617         intptr_t ret_val = FundingCreated_clone_ptr(&arg_conv);
23618         return ret_val;
23619 }
23620
23621 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
23622         LDKFundingCreated orig_conv;
23623         orig_conv.inner = (void*)(orig & (~1));
23624         orig_conv.is_owned = false;
23625         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23626         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
23627         uintptr_t ret_ref = 0;
23628         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23629         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23631         ret_ref = (uintptr_t)ret_var.inner;
23632         if (ret_var.is_owned) {
23633                 ret_ref |= 1;
23634         }
23635         return ret_ref;
23636 }
23637
23638 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
23639         LDKFundingSigned this_obj_conv;
23640         this_obj_conv.inner = (void*)(this_obj & (~1));
23641         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23643         FundingSigned_free(this_obj_conv);
23644 }
23645
23646 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
23647         LDKFundingSigned this_ptr_conv;
23648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23649         this_ptr_conv.is_owned = false;
23650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23651         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23652         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
23653         return ret_arr;
23654 }
23655
23656 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23657         LDKFundingSigned this_ptr_conv;
23658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23659         this_ptr_conv.is_owned = false;
23660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23661         LDKThirtyTwoBytes val_ref;
23662         CHECK(val->arr_len == 32);
23663         memcpy(val_ref.data, val->elems, 32); FREE(val);
23664         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
23665 }
23666
23667 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
23668         LDKFundingSigned this_ptr_conv;
23669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23670         this_ptr_conv.is_owned = false;
23671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23672         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
23673         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
23674         return ret_arr;
23675 }
23676
23677 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
23678         LDKFundingSigned this_ptr_conv;
23679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23680         this_ptr_conv.is_owned = false;
23681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23682         LDKSignature val_ref;
23683         CHECK(val->arr_len == 64);
23684         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
23685         FundingSigned_set_signature(&this_ptr_conv, val_ref);
23686 }
23687
23688 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
23689         LDKThirtyTwoBytes channel_id_arg_ref;
23690         CHECK(channel_id_arg->arr_len == 32);
23691         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
23692         LDKSignature signature_arg_ref;
23693         CHECK(signature_arg->arr_len == 64);
23694         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
23695         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
23696         uintptr_t ret_ref = 0;
23697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23700         ret_ref = (uintptr_t)ret_var.inner;
23701         if (ret_var.is_owned) {
23702                 ret_ref |= 1;
23703         }
23704         return ret_ref;
23705 }
23706
23707 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
23708         LDKFundingSigned ret_var = FundingSigned_clone(arg);
23709 uintptr_t ret_ref = 0;
23710 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23711 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23712 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23713 ret_ref = (uintptr_t)ret_var.inner;
23714 if (ret_var.is_owned) {
23715         ret_ref |= 1;
23716 }
23717         return ret_ref;
23718 }
23719 intptr_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
23720         LDKFundingSigned arg_conv;
23721         arg_conv.inner = (void*)(arg & (~1));
23722         arg_conv.is_owned = false;
23723         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23724         intptr_t ret_val = FundingSigned_clone_ptr(&arg_conv);
23725         return ret_val;
23726 }
23727
23728 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
23729         LDKFundingSigned orig_conv;
23730         orig_conv.inner = (void*)(orig & (~1));
23731         orig_conv.is_owned = false;
23732         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23733         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
23734         uintptr_t ret_ref = 0;
23735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23738         ret_ref = (uintptr_t)ret_var.inner;
23739         if (ret_var.is_owned) {
23740                 ret_ref |= 1;
23741         }
23742         return ret_ref;
23743 }
23744
23745 void  __attribute__((export_name("TS_FundingLocked_free"))) TS_FundingLocked_free(uint32_t this_obj) {
23746         LDKFundingLocked this_obj_conv;
23747         this_obj_conv.inner = (void*)(this_obj & (~1));
23748         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23750         FundingLocked_free(this_obj_conv);
23751 }
23752
23753 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_channel_id"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
23754         LDKFundingLocked this_ptr_conv;
23755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23756         this_ptr_conv.is_owned = false;
23757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23758         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23759         memcpy(ret_arr->elems, *FundingLocked_get_channel_id(&this_ptr_conv), 32);
23760         return ret_arr;
23761 }
23762
23763 void  __attribute__((export_name("TS_FundingLocked_set_channel_id"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23764         LDKFundingLocked this_ptr_conv;
23765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23766         this_ptr_conv.is_owned = false;
23767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23768         LDKThirtyTwoBytes val_ref;
23769         CHECK(val->arr_len == 32);
23770         memcpy(val_ref.data, val->elems, 32); FREE(val);
23771         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
23772 }
23773
23774 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_next_per_commitment_point"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
23775         LDKFundingLocked this_ptr_conv;
23776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23777         this_ptr_conv.is_owned = false;
23778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23779         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23780         memcpy(ret_arr->elems, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23781         return ret_arr;
23782 }
23783
23784 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) {
23785         LDKFundingLocked this_ptr_conv;
23786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23787         this_ptr_conv.is_owned = false;
23788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23789         LDKPublicKey val_ref;
23790         CHECK(val->arr_len == 33);
23791         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23792         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
23793 }
23794
23795 uint32_t  __attribute__((export_name("TS_FundingLocked_new"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
23796         LDKThirtyTwoBytes channel_id_arg_ref;
23797         CHECK(channel_id_arg->arr_len == 32);
23798         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
23799         LDKPublicKey next_per_commitment_point_arg_ref;
23800         CHECK(next_per_commitment_point_arg->arr_len == 33);
23801         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
23802         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
23803         uintptr_t ret_ref = 0;
23804         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23805         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23807         ret_ref = (uintptr_t)ret_var.inner;
23808         if (ret_var.is_owned) {
23809                 ret_ref |= 1;
23810         }
23811         return ret_ref;
23812 }
23813
23814 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
23815         LDKFundingLocked ret_var = FundingLocked_clone(arg);
23816 uintptr_t ret_ref = 0;
23817 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23818 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23819 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23820 ret_ref = (uintptr_t)ret_var.inner;
23821 if (ret_var.is_owned) {
23822         ret_ref |= 1;
23823 }
23824         return ret_ref;
23825 }
23826 intptr_t  __attribute__((export_name("TS_FundingLocked_clone_ptr"))) TS_FundingLocked_clone_ptr(uint32_t arg) {
23827         LDKFundingLocked arg_conv;
23828         arg_conv.inner = (void*)(arg & (~1));
23829         arg_conv.is_owned = false;
23830         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23831         intptr_t ret_val = FundingLocked_clone_ptr(&arg_conv);
23832         return ret_val;
23833 }
23834
23835 uint32_t  __attribute__((export_name("TS_FundingLocked_clone"))) TS_FundingLocked_clone(uint32_t orig) {
23836         LDKFundingLocked orig_conv;
23837         orig_conv.inner = (void*)(orig & (~1));
23838         orig_conv.is_owned = false;
23839         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23840         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
23841         uintptr_t ret_ref = 0;
23842         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23843         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23845         ret_ref = (uintptr_t)ret_var.inner;
23846         if (ret_var.is_owned) {
23847                 ret_ref |= 1;
23848         }
23849         return ret_ref;
23850 }
23851
23852 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
23853         LDKShutdown this_obj_conv;
23854         this_obj_conv.inner = (void*)(this_obj & (~1));
23855         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23857         Shutdown_free(this_obj_conv);
23858 }
23859
23860 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
23861         LDKShutdown this_ptr_conv;
23862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23863         this_ptr_conv.is_owned = false;
23864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23865         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23866         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
23867         return ret_arr;
23868 }
23869
23870 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
23871         LDKShutdown this_ptr_conv;
23872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23873         this_ptr_conv.is_owned = false;
23874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23875         LDKThirtyTwoBytes val_ref;
23876         CHECK(val->arr_len == 32);
23877         memcpy(val_ref.data, val->elems, 32); FREE(val);
23878         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
23879 }
23880
23881 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
23882         LDKShutdown this_ptr_conv;
23883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23884         this_ptr_conv.is_owned = false;
23885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23886         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
23887         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23888         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23889         return ret_arr;
23890 }
23891
23892 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
23893         LDKShutdown this_ptr_conv;
23894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23895         this_ptr_conv.is_owned = false;
23896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23897         LDKCVec_u8Z val_ref;
23898         val_ref.datalen = val->arr_len;
23899         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
23900         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
23901         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
23902 }
23903
23904 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
23905         LDKThirtyTwoBytes channel_id_arg_ref;
23906         CHECK(channel_id_arg->arr_len == 32);
23907         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
23908         LDKCVec_u8Z scriptpubkey_arg_ref;
23909         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
23910         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
23911         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
23912         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
23913         uintptr_t ret_ref = 0;
23914         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23915         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23917         ret_ref = (uintptr_t)ret_var.inner;
23918         if (ret_var.is_owned) {
23919                 ret_ref |= 1;
23920         }
23921         return ret_ref;
23922 }
23923
23924 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
23925         LDKShutdown ret_var = Shutdown_clone(arg);
23926 uintptr_t ret_ref = 0;
23927 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23928 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23929 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23930 ret_ref = (uintptr_t)ret_var.inner;
23931 if (ret_var.is_owned) {
23932         ret_ref |= 1;
23933 }
23934         return ret_ref;
23935 }
23936 intptr_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
23937         LDKShutdown arg_conv;
23938         arg_conv.inner = (void*)(arg & (~1));
23939         arg_conv.is_owned = false;
23940         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23941         intptr_t ret_val = Shutdown_clone_ptr(&arg_conv);
23942         return ret_val;
23943 }
23944
23945 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
23946         LDKShutdown orig_conv;
23947         orig_conv.inner = (void*)(orig & (~1));
23948         orig_conv.is_owned = false;
23949         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23950         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
23951         uintptr_t ret_ref = 0;
23952         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23953         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23955         ret_ref = (uintptr_t)ret_var.inner;
23956         if (ret_var.is_owned) {
23957                 ret_ref |= 1;
23958         }
23959         return ret_ref;
23960 }
23961
23962 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
23963         LDKClosingSignedFeeRange this_obj_conv;
23964         this_obj_conv.inner = (void*)(this_obj & (~1));
23965         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23967         ClosingSignedFeeRange_free(this_obj_conv);
23968 }
23969
23970 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
23971         LDKClosingSignedFeeRange this_ptr_conv;
23972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23973         this_ptr_conv.is_owned = false;
23974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23975         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
23976         return ret_val;
23977 }
23978
23979 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
23980         LDKClosingSignedFeeRange this_ptr_conv;
23981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23982         this_ptr_conv.is_owned = false;
23983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23984         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
23985 }
23986
23987 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
23988         LDKClosingSignedFeeRange this_ptr_conv;
23989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23990         this_ptr_conv.is_owned = false;
23991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23992         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
23993         return ret_val;
23994 }
23995
23996 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
23997         LDKClosingSignedFeeRange this_ptr_conv;
23998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23999         this_ptr_conv.is_owned = false;
24000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24001         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
24002 }
24003
24004 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
24005         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
24006         uintptr_t ret_ref = 0;
24007         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24008         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24010         ret_ref = (uintptr_t)ret_var.inner;
24011         if (ret_var.is_owned) {
24012                 ret_ref |= 1;
24013         }
24014         return ret_ref;
24015 }
24016
24017 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
24018         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
24019 uintptr_t ret_ref = 0;
24020 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24021 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24022 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24023 ret_ref = (uintptr_t)ret_var.inner;
24024 if (ret_var.is_owned) {
24025         ret_ref |= 1;
24026 }
24027         return ret_ref;
24028 }
24029 intptr_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
24030         LDKClosingSignedFeeRange arg_conv;
24031         arg_conv.inner = (void*)(arg & (~1));
24032         arg_conv.is_owned = false;
24033         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24034         intptr_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
24035         return ret_val;
24036 }
24037
24038 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
24039         LDKClosingSignedFeeRange orig_conv;
24040         orig_conv.inner = (void*)(orig & (~1));
24041         orig_conv.is_owned = false;
24042         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24043         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
24044         uintptr_t ret_ref = 0;
24045         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24046         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24048         ret_ref = (uintptr_t)ret_var.inner;
24049         if (ret_var.is_owned) {
24050                 ret_ref |= 1;
24051         }
24052         return ret_ref;
24053 }
24054
24055 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
24056         LDKClosingSigned this_obj_conv;
24057         this_obj_conv.inner = (void*)(this_obj & (~1));
24058         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24060         ClosingSigned_free(this_obj_conv);
24061 }
24062
24063 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
24064         LDKClosingSigned this_ptr_conv;
24065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24066         this_ptr_conv.is_owned = false;
24067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24068         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24069         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
24070         return ret_arr;
24071 }
24072
24073 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24074         LDKClosingSigned this_ptr_conv;
24075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24076         this_ptr_conv.is_owned = false;
24077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24078         LDKThirtyTwoBytes val_ref;
24079         CHECK(val->arr_len == 32);
24080         memcpy(val_ref.data, val->elems, 32); FREE(val);
24081         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
24082 }
24083
24084 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
24085         LDKClosingSigned this_ptr_conv;
24086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24087         this_ptr_conv.is_owned = false;
24088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24089         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
24090         return ret_val;
24091 }
24092
24093 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
24094         LDKClosingSigned this_ptr_conv;
24095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24096         this_ptr_conv.is_owned = false;
24097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24098         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
24099 }
24100
24101 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
24102         LDKClosingSigned this_ptr_conv;
24103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24104         this_ptr_conv.is_owned = false;
24105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24106         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
24107         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
24108         return ret_arr;
24109 }
24110
24111 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
24112         LDKClosingSigned this_ptr_conv;
24113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24114         this_ptr_conv.is_owned = false;
24115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24116         LDKSignature val_ref;
24117         CHECK(val->arr_len == 64);
24118         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
24119         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
24120 }
24121
24122 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
24123         LDKClosingSigned this_ptr_conv;
24124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24125         this_ptr_conv.is_owned = false;
24126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24127         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
24128         uintptr_t ret_ref = 0;
24129         if ((uintptr_t)ret_var.inner > 4096) {
24130                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24131                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24133                 ret_ref = (uintptr_t)ret_var.inner;
24134                 if (ret_var.is_owned) {
24135                         ret_ref |= 1;
24136                 }
24137         }
24138         return ret_ref;
24139 }
24140
24141 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
24142         LDKClosingSigned this_ptr_conv;
24143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24144         this_ptr_conv.is_owned = false;
24145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24146         LDKClosingSignedFeeRange val_conv;
24147         val_conv.inner = (void*)(val & (~1));
24148         val_conv.is_owned = (val & 1) || (val == 0);
24149         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24150         val_conv = ClosingSignedFeeRange_clone(&val_conv);
24151         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
24152 }
24153
24154 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) {
24155         LDKThirtyTwoBytes channel_id_arg_ref;
24156         CHECK(channel_id_arg->arr_len == 32);
24157         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24158         LDKSignature signature_arg_ref;
24159         CHECK(signature_arg->arr_len == 64);
24160         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
24161         LDKClosingSignedFeeRange fee_range_arg_conv;
24162         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
24163         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
24164         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
24165         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
24166         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
24167         uintptr_t ret_ref = 0;
24168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24171         ret_ref = (uintptr_t)ret_var.inner;
24172         if (ret_var.is_owned) {
24173                 ret_ref |= 1;
24174         }
24175         return ret_ref;
24176 }
24177
24178 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
24179         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
24180 uintptr_t ret_ref = 0;
24181 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24182 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24183 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24184 ret_ref = (uintptr_t)ret_var.inner;
24185 if (ret_var.is_owned) {
24186         ret_ref |= 1;
24187 }
24188         return ret_ref;
24189 }
24190 intptr_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
24191         LDKClosingSigned arg_conv;
24192         arg_conv.inner = (void*)(arg & (~1));
24193         arg_conv.is_owned = false;
24194         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24195         intptr_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
24196         return ret_val;
24197 }
24198
24199 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
24200         LDKClosingSigned orig_conv;
24201         orig_conv.inner = (void*)(orig & (~1));
24202         orig_conv.is_owned = false;
24203         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24204         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
24205         uintptr_t ret_ref = 0;
24206         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24207         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24209         ret_ref = (uintptr_t)ret_var.inner;
24210         if (ret_var.is_owned) {
24211                 ret_ref |= 1;
24212         }
24213         return ret_ref;
24214 }
24215
24216 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
24217         LDKUpdateAddHTLC this_obj_conv;
24218         this_obj_conv.inner = (void*)(this_obj & (~1));
24219         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24221         UpdateAddHTLC_free(this_obj_conv);
24222 }
24223
24224 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
24225         LDKUpdateAddHTLC this_ptr_conv;
24226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24227         this_ptr_conv.is_owned = false;
24228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24229         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24230         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
24231         return ret_arr;
24232 }
24233
24234 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24235         LDKUpdateAddHTLC this_ptr_conv;
24236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24237         this_ptr_conv.is_owned = false;
24238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24239         LDKThirtyTwoBytes val_ref;
24240         CHECK(val->arr_len == 32);
24241         memcpy(val_ref.data, val->elems, 32); FREE(val);
24242         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
24243 }
24244
24245 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
24246         LDKUpdateAddHTLC this_ptr_conv;
24247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24248         this_ptr_conv.is_owned = false;
24249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24250         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
24251         return ret_val;
24252 }
24253
24254 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24255         LDKUpdateAddHTLC this_ptr_conv;
24256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24257         this_ptr_conv.is_owned = false;
24258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24259         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
24260 }
24261
24262 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
24263         LDKUpdateAddHTLC this_ptr_conv;
24264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24265         this_ptr_conv.is_owned = false;
24266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24267         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
24268         return ret_val;
24269 }
24270
24271 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
24272         LDKUpdateAddHTLC this_ptr_conv;
24273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24274         this_ptr_conv.is_owned = false;
24275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24276         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
24277 }
24278
24279 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
24280         LDKUpdateAddHTLC this_ptr_conv;
24281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24282         this_ptr_conv.is_owned = false;
24283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24284         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24285         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
24286         return ret_arr;
24287 }
24288
24289 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
24290         LDKUpdateAddHTLC this_ptr_conv;
24291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24292         this_ptr_conv.is_owned = false;
24293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24294         LDKThirtyTwoBytes val_ref;
24295         CHECK(val->arr_len == 32);
24296         memcpy(val_ref.data, val->elems, 32); FREE(val);
24297         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
24298 }
24299
24300 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
24301         LDKUpdateAddHTLC this_ptr_conv;
24302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24303         this_ptr_conv.is_owned = false;
24304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24305         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
24306         return ret_val;
24307 }
24308
24309 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
24310         LDKUpdateAddHTLC this_ptr_conv;
24311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24312         this_ptr_conv.is_owned = false;
24313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24314         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
24315 }
24316
24317 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
24318         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
24319 uintptr_t ret_ref = 0;
24320 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24321 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24322 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24323 ret_ref = (uintptr_t)ret_var.inner;
24324 if (ret_var.is_owned) {
24325         ret_ref |= 1;
24326 }
24327         return ret_ref;
24328 }
24329 intptr_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
24330         LDKUpdateAddHTLC arg_conv;
24331         arg_conv.inner = (void*)(arg & (~1));
24332         arg_conv.is_owned = false;
24333         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24334         intptr_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
24335         return ret_val;
24336 }
24337
24338 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
24339         LDKUpdateAddHTLC orig_conv;
24340         orig_conv.inner = (void*)(orig & (~1));
24341         orig_conv.is_owned = false;
24342         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24343         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
24344         uintptr_t ret_ref = 0;
24345         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24346         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24348         ret_ref = (uintptr_t)ret_var.inner;
24349         if (ret_var.is_owned) {
24350                 ret_ref |= 1;
24351         }
24352         return ret_ref;
24353 }
24354
24355 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
24356         LDKUpdateFulfillHTLC this_obj_conv;
24357         this_obj_conv.inner = (void*)(this_obj & (~1));
24358         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24360         UpdateFulfillHTLC_free(this_obj_conv);
24361 }
24362
24363 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
24364         LDKUpdateFulfillHTLC this_ptr_conv;
24365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24366         this_ptr_conv.is_owned = false;
24367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24368         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24369         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
24370         return ret_arr;
24371 }
24372
24373 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24374         LDKUpdateFulfillHTLC this_ptr_conv;
24375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24376         this_ptr_conv.is_owned = false;
24377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24378         LDKThirtyTwoBytes val_ref;
24379         CHECK(val->arr_len == 32);
24380         memcpy(val_ref.data, val->elems, 32); FREE(val);
24381         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
24382 }
24383
24384 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
24385         LDKUpdateFulfillHTLC this_ptr_conv;
24386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24387         this_ptr_conv.is_owned = false;
24388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24389         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
24390         return ret_val;
24391 }
24392
24393 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24394         LDKUpdateFulfillHTLC this_ptr_conv;
24395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24396         this_ptr_conv.is_owned = false;
24397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24398         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
24399 }
24400
24401 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
24402         LDKUpdateFulfillHTLC this_ptr_conv;
24403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24404         this_ptr_conv.is_owned = false;
24405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24406         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24407         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
24408         return ret_arr;
24409 }
24410
24411 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
24412         LDKUpdateFulfillHTLC this_ptr_conv;
24413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24414         this_ptr_conv.is_owned = false;
24415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24416         LDKThirtyTwoBytes val_ref;
24417         CHECK(val->arr_len == 32);
24418         memcpy(val_ref.data, val->elems, 32); FREE(val);
24419         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
24420 }
24421
24422 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) {
24423         LDKThirtyTwoBytes channel_id_arg_ref;
24424         CHECK(channel_id_arg->arr_len == 32);
24425         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24426         LDKThirtyTwoBytes payment_preimage_arg_ref;
24427         CHECK(payment_preimage_arg->arr_len == 32);
24428         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
24429         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
24430         uintptr_t ret_ref = 0;
24431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24434         ret_ref = (uintptr_t)ret_var.inner;
24435         if (ret_var.is_owned) {
24436                 ret_ref |= 1;
24437         }
24438         return ret_ref;
24439 }
24440
24441 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
24442         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
24443 uintptr_t ret_ref = 0;
24444 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24445 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24446 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24447 ret_ref = (uintptr_t)ret_var.inner;
24448 if (ret_var.is_owned) {
24449         ret_ref |= 1;
24450 }
24451         return ret_ref;
24452 }
24453 intptr_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
24454         LDKUpdateFulfillHTLC arg_conv;
24455         arg_conv.inner = (void*)(arg & (~1));
24456         arg_conv.is_owned = false;
24457         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24458         intptr_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
24459         return ret_val;
24460 }
24461
24462 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
24463         LDKUpdateFulfillHTLC orig_conv;
24464         orig_conv.inner = (void*)(orig & (~1));
24465         orig_conv.is_owned = false;
24466         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24467         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
24468         uintptr_t ret_ref = 0;
24469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24472         ret_ref = (uintptr_t)ret_var.inner;
24473         if (ret_var.is_owned) {
24474                 ret_ref |= 1;
24475         }
24476         return ret_ref;
24477 }
24478
24479 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
24480         LDKUpdateFailHTLC this_obj_conv;
24481         this_obj_conv.inner = (void*)(this_obj & (~1));
24482         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24484         UpdateFailHTLC_free(this_obj_conv);
24485 }
24486
24487 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
24488         LDKUpdateFailHTLC this_ptr_conv;
24489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24490         this_ptr_conv.is_owned = false;
24491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24492         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24493         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
24494         return ret_arr;
24495 }
24496
24497 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24498         LDKUpdateFailHTLC this_ptr_conv;
24499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24500         this_ptr_conv.is_owned = false;
24501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24502         LDKThirtyTwoBytes val_ref;
24503         CHECK(val->arr_len == 32);
24504         memcpy(val_ref.data, val->elems, 32); FREE(val);
24505         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
24506 }
24507
24508 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
24509         LDKUpdateFailHTLC this_ptr_conv;
24510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24511         this_ptr_conv.is_owned = false;
24512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24513         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
24514         return ret_val;
24515 }
24516
24517 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24518         LDKUpdateFailHTLC this_ptr_conv;
24519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24520         this_ptr_conv.is_owned = false;
24521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24522         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
24523 }
24524
24525 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
24526         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
24527 uintptr_t ret_ref = 0;
24528 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24529 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24530 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24531 ret_ref = (uintptr_t)ret_var.inner;
24532 if (ret_var.is_owned) {
24533         ret_ref |= 1;
24534 }
24535         return ret_ref;
24536 }
24537 intptr_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
24538         LDKUpdateFailHTLC arg_conv;
24539         arg_conv.inner = (void*)(arg & (~1));
24540         arg_conv.is_owned = false;
24541         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24542         intptr_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
24543         return ret_val;
24544 }
24545
24546 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
24547         LDKUpdateFailHTLC orig_conv;
24548         orig_conv.inner = (void*)(orig & (~1));
24549         orig_conv.is_owned = false;
24550         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24551         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
24552         uintptr_t ret_ref = 0;
24553         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24554         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24556         ret_ref = (uintptr_t)ret_var.inner;
24557         if (ret_var.is_owned) {
24558                 ret_ref |= 1;
24559         }
24560         return ret_ref;
24561 }
24562
24563 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
24564         LDKUpdateFailMalformedHTLC this_obj_conv;
24565         this_obj_conv.inner = (void*)(this_obj & (~1));
24566         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24568         UpdateFailMalformedHTLC_free(this_obj_conv);
24569 }
24570
24571 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
24572         LDKUpdateFailMalformedHTLC this_ptr_conv;
24573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24574         this_ptr_conv.is_owned = false;
24575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24576         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24577         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
24578         return ret_arr;
24579 }
24580
24581 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24582         LDKUpdateFailMalformedHTLC this_ptr_conv;
24583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24584         this_ptr_conv.is_owned = false;
24585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24586         LDKThirtyTwoBytes val_ref;
24587         CHECK(val->arr_len == 32);
24588         memcpy(val_ref.data, val->elems, 32); FREE(val);
24589         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
24590 }
24591
24592 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
24593         LDKUpdateFailMalformedHTLC this_ptr_conv;
24594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24595         this_ptr_conv.is_owned = false;
24596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24597         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
24598         return ret_val;
24599 }
24600
24601 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
24602         LDKUpdateFailMalformedHTLC this_ptr_conv;
24603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24604         this_ptr_conv.is_owned = false;
24605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24606         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
24607 }
24608
24609 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
24610         LDKUpdateFailMalformedHTLC this_ptr_conv;
24611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24612         this_ptr_conv.is_owned = false;
24613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24614         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
24615         return ret_val;
24616 }
24617
24618 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
24619         LDKUpdateFailMalformedHTLC this_ptr_conv;
24620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24621         this_ptr_conv.is_owned = false;
24622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24623         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
24624 }
24625
24626 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
24627         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
24628 uintptr_t ret_ref = 0;
24629 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24630 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24631 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24632 ret_ref = (uintptr_t)ret_var.inner;
24633 if (ret_var.is_owned) {
24634         ret_ref |= 1;
24635 }
24636         return ret_ref;
24637 }
24638 intptr_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
24639         LDKUpdateFailMalformedHTLC arg_conv;
24640         arg_conv.inner = (void*)(arg & (~1));
24641         arg_conv.is_owned = false;
24642         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24643         intptr_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
24644         return ret_val;
24645 }
24646
24647 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
24648         LDKUpdateFailMalformedHTLC orig_conv;
24649         orig_conv.inner = (void*)(orig & (~1));
24650         orig_conv.is_owned = false;
24651         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24652         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
24653         uintptr_t ret_ref = 0;
24654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24657         ret_ref = (uintptr_t)ret_var.inner;
24658         if (ret_var.is_owned) {
24659                 ret_ref |= 1;
24660         }
24661         return ret_ref;
24662 }
24663
24664 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
24665         LDKCommitmentSigned this_obj_conv;
24666         this_obj_conv.inner = (void*)(this_obj & (~1));
24667         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24669         CommitmentSigned_free(this_obj_conv);
24670 }
24671
24672 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
24673         LDKCommitmentSigned this_ptr_conv;
24674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24675         this_ptr_conv.is_owned = false;
24676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24677         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24678         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
24679         return ret_arr;
24680 }
24681
24682 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24683         LDKCommitmentSigned this_ptr_conv;
24684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24685         this_ptr_conv.is_owned = false;
24686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24687         LDKThirtyTwoBytes val_ref;
24688         CHECK(val->arr_len == 32);
24689         memcpy(val_ref.data, val->elems, 32); FREE(val);
24690         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
24691 }
24692
24693 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
24694         LDKCommitmentSigned this_ptr_conv;
24695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24696         this_ptr_conv.is_owned = false;
24697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24698         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
24699         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
24700         return ret_arr;
24701 }
24702
24703 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
24704         LDKCommitmentSigned this_ptr_conv;
24705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24706         this_ptr_conv.is_owned = false;
24707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24708         LDKSignature val_ref;
24709         CHECK(val->arr_len == 64);
24710         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
24711         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
24712 }
24713
24714 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
24715         LDKCommitmentSigned this_ptr_conv;
24716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24717         this_ptr_conv.is_owned = false;
24718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24719         LDKCVec_SignatureZ val_constr;
24720         val_constr.datalen = val->arr_len;
24721         if (val_constr.datalen > 0)
24722                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
24723         else
24724                 val_constr.data = NULL;
24725         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
24726         for (size_t m = 0; m < val_constr.datalen; m++) {
24727                 int8_tArray val_conv_12 = val_vals[m];
24728                 LDKSignature val_conv_12_ref;
24729                 CHECK(val_conv_12->arr_len == 64);
24730                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
24731                 val_constr.data[m] = val_conv_12_ref;
24732         }
24733         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
24734 }
24735
24736 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
24737         LDKThirtyTwoBytes channel_id_arg_ref;
24738         CHECK(channel_id_arg->arr_len == 32);
24739         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24740         LDKSignature signature_arg_ref;
24741         CHECK(signature_arg->arr_len == 64);
24742         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
24743         LDKCVec_SignatureZ htlc_signatures_arg_constr;
24744         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
24745         if (htlc_signatures_arg_constr.datalen > 0)
24746                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
24747         else
24748                 htlc_signatures_arg_constr.data = NULL;
24749         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems /* XXX htlc_signatures_arg leaks */;
24750         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
24751                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
24752                 LDKSignature htlc_signatures_arg_conv_12_ref;
24753                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
24754                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
24755                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
24756         }
24757         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
24758         uintptr_t ret_ref = 0;
24759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24762         ret_ref = (uintptr_t)ret_var.inner;
24763         if (ret_var.is_owned) {
24764                 ret_ref |= 1;
24765         }
24766         return ret_ref;
24767 }
24768
24769 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
24770         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
24771 uintptr_t ret_ref = 0;
24772 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24773 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24774 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24775 ret_ref = (uintptr_t)ret_var.inner;
24776 if (ret_var.is_owned) {
24777         ret_ref |= 1;
24778 }
24779         return ret_ref;
24780 }
24781 intptr_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
24782         LDKCommitmentSigned arg_conv;
24783         arg_conv.inner = (void*)(arg & (~1));
24784         arg_conv.is_owned = false;
24785         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24786         intptr_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
24787         return ret_val;
24788 }
24789
24790 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
24791         LDKCommitmentSigned orig_conv;
24792         orig_conv.inner = (void*)(orig & (~1));
24793         orig_conv.is_owned = false;
24794         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24795         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
24796         uintptr_t ret_ref = 0;
24797         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24798         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24800         ret_ref = (uintptr_t)ret_var.inner;
24801         if (ret_var.is_owned) {
24802                 ret_ref |= 1;
24803         }
24804         return ret_ref;
24805 }
24806
24807 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
24808         LDKRevokeAndACK this_obj_conv;
24809         this_obj_conv.inner = (void*)(this_obj & (~1));
24810         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24812         RevokeAndACK_free(this_obj_conv);
24813 }
24814
24815 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
24816         LDKRevokeAndACK this_ptr_conv;
24817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24818         this_ptr_conv.is_owned = false;
24819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24820         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24821         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
24822         return ret_arr;
24823 }
24824
24825 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24826         LDKRevokeAndACK this_ptr_conv;
24827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24828         this_ptr_conv.is_owned = false;
24829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24830         LDKThirtyTwoBytes val_ref;
24831         CHECK(val->arr_len == 32);
24832         memcpy(val_ref.data, val->elems, 32); FREE(val);
24833         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
24834 }
24835
24836 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
24837         LDKRevokeAndACK this_ptr_conv;
24838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24839         this_ptr_conv.is_owned = false;
24840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24841         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24842         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
24843         return ret_arr;
24844 }
24845
24846 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
24847         LDKRevokeAndACK this_ptr_conv;
24848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24849         this_ptr_conv.is_owned = false;
24850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24851         LDKThirtyTwoBytes val_ref;
24852         CHECK(val->arr_len == 32);
24853         memcpy(val_ref.data, val->elems, 32); FREE(val);
24854         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
24855 }
24856
24857 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
24858         LDKRevokeAndACK this_ptr_conv;
24859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24860         this_ptr_conv.is_owned = false;
24861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24862         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24863         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
24864         return ret_arr;
24865 }
24866
24867 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) {
24868         LDKRevokeAndACK this_ptr_conv;
24869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24870         this_ptr_conv.is_owned = false;
24871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24872         LDKPublicKey val_ref;
24873         CHECK(val->arr_len == 33);
24874         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24875         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
24876 }
24877
24878 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) {
24879         LDKThirtyTwoBytes channel_id_arg_ref;
24880         CHECK(channel_id_arg->arr_len == 32);
24881         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24882         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
24883         CHECK(per_commitment_secret_arg->arr_len == 32);
24884         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
24885         LDKPublicKey next_per_commitment_point_arg_ref;
24886         CHECK(next_per_commitment_point_arg->arr_len == 33);
24887         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
24888         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
24889         uintptr_t ret_ref = 0;
24890         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24891         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24893         ret_ref = (uintptr_t)ret_var.inner;
24894         if (ret_var.is_owned) {
24895                 ret_ref |= 1;
24896         }
24897         return ret_ref;
24898 }
24899
24900 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
24901         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
24902 uintptr_t ret_ref = 0;
24903 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24904 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24905 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24906 ret_ref = (uintptr_t)ret_var.inner;
24907 if (ret_var.is_owned) {
24908         ret_ref |= 1;
24909 }
24910         return ret_ref;
24911 }
24912 intptr_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
24913         LDKRevokeAndACK arg_conv;
24914         arg_conv.inner = (void*)(arg & (~1));
24915         arg_conv.is_owned = false;
24916         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24917         intptr_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
24918         return ret_val;
24919 }
24920
24921 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
24922         LDKRevokeAndACK orig_conv;
24923         orig_conv.inner = (void*)(orig & (~1));
24924         orig_conv.is_owned = false;
24925         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24926         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
24927         uintptr_t ret_ref = 0;
24928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24931         ret_ref = (uintptr_t)ret_var.inner;
24932         if (ret_var.is_owned) {
24933                 ret_ref |= 1;
24934         }
24935         return ret_ref;
24936 }
24937
24938 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
24939         LDKUpdateFee this_obj_conv;
24940         this_obj_conv.inner = (void*)(this_obj & (~1));
24941         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24943         UpdateFee_free(this_obj_conv);
24944 }
24945
24946 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
24947         LDKUpdateFee this_ptr_conv;
24948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24949         this_ptr_conv.is_owned = false;
24950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24951         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24952         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
24953         return ret_arr;
24954 }
24955
24956 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24957         LDKUpdateFee this_ptr_conv;
24958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24959         this_ptr_conv.is_owned = false;
24960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24961         LDKThirtyTwoBytes val_ref;
24962         CHECK(val->arr_len == 32);
24963         memcpy(val_ref.data, val->elems, 32); FREE(val);
24964         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
24965 }
24966
24967 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
24968         LDKUpdateFee this_ptr_conv;
24969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24970         this_ptr_conv.is_owned = false;
24971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24972         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
24973         return ret_val;
24974 }
24975
24976 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
24977         LDKUpdateFee this_ptr_conv;
24978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24979         this_ptr_conv.is_owned = false;
24980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24981         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
24982 }
24983
24984 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
24985         LDKThirtyTwoBytes channel_id_arg_ref;
24986         CHECK(channel_id_arg->arr_len == 32);
24987         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24988         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
24989         uintptr_t ret_ref = 0;
24990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24993         ret_ref = (uintptr_t)ret_var.inner;
24994         if (ret_var.is_owned) {
24995                 ret_ref |= 1;
24996         }
24997         return ret_ref;
24998 }
24999
25000 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
25001         LDKUpdateFee ret_var = UpdateFee_clone(arg);
25002 uintptr_t ret_ref = 0;
25003 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25004 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25005 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25006 ret_ref = (uintptr_t)ret_var.inner;
25007 if (ret_var.is_owned) {
25008         ret_ref |= 1;
25009 }
25010         return ret_ref;
25011 }
25012 intptr_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
25013         LDKUpdateFee arg_conv;
25014         arg_conv.inner = (void*)(arg & (~1));
25015         arg_conv.is_owned = false;
25016         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25017         intptr_t ret_val = UpdateFee_clone_ptr(&arg_conv);
25018         return ret_val;
25019 }
25020
25021 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
25022         LDKUpdateFee orig_conv;
25023         orig_conv.inner = (void*)(orig & (~1));
25024         orig_conv.is_owned = false;
25025         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25026         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
25027         uintptr_t ret_ref = 0;
25028         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25029         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25031         ret_ref = (uintptr_t)ret_var.inner;
25032         if (ret_var.is_owned) {
25033                 ret_ref |= 1;
25034         }
25035         return ret_ref;
25036 }
25037
25038 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
25039         LDKDataLossProtect this_obj_conv;
25040         this_obj_conv.inner = (void*)(this_obj & (~1));
25041         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25043         DataLossProtect_free(this_obj_conv);
25044 }
25045
25046 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) {
25047         LDKDataLossProtect this_ptr_conv;
25048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25049         this_ptr_conv.is_owned = false;
25050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25051         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25052         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
25053         return ret_arr;
25054 }
25055
25056 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) {
25057         LDKDataLossProtect this_ptr_conv;
25058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25059         this_ptr_conv.is_owned = false;
25060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25061         LDKThirtyTwoBytes val_ref;
25062         CHECK(val->arr_len == 32);
25063         memcpy(val_ref.data, val->elems, 32); FREE(val);
25064         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
25065 }
25066
25067 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) {
25068         LDKDataLossProtect this_ptr_conv;
25069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25070         this_ptr_conv.is_owned = false;
25071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25072         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25073         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
25074         return ret_arr;
25075 }
25076
25077 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) {
25078         LDKDataLossProtect this_ptr_conv;
25079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25080         this_ptr_conv.is_owned = false;
25081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25082         LDKPublicKey val_ref;
25083         CHECK(val->arr_len == 33);
25084         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25085         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
25086 }
25087
25088 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) {
25089         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
25090         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
25091         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
25092         LDKPublicKey my_current_per_commitment_point_arg_ref;
25093         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
25094         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);
25095         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
25096         uintptr_t ret_ref = 0;
25097         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25098         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25100         ret_ref = (uintptr_t)ret_var.inner;
25101         if (ret_var.is_owned) {
25102                 ret_ref |= 1;
25103         }
25104         return ret_ref;
25105 }
25106
25107 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
25108         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
25109 uintptr_t ret_ref = 0;
25110 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25111 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25112 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25113 ret_ref = (uintptr_t)ret_var.inner;
25114 if (ret_var.is_owned) {
25115         ret_ref |= 1;
25116 }
25117         return ret_ref;
25118 }
25119 intptr_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
25120         LDKDataLossProtect arg_conv;
25121         arg_conv.inner = (void*)(arg & (~1));
25122         arg_conv.is_owned = false;
25123         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25124         intptr_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
25125         return ret_val;
25126 }
25127
25128 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
25129         LDKDataLossProtect orig_conv;
25130         orig_conv.inner = (void*)(orig & (~1));
25131         orig_conv.is_owned = false;
25132         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25133         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
25134         uintptr_t ret_ref = 0;
25135         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25136         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25138         ret_ref = (uintptr_t)ret_var.inner;
25139         if (ret_var.is_owned) {
25140                 ret_ref |= 1;
25141         }
25142         return ret_ref;
25143 }
25144
25145 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
25146         LDKChannelReestablish this_obj_conv;
25147         this_obj_conv.inner = (void*)(this_obj & (~1));
25148         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25150         ChannelReestablish_free(this_obj_conv);
25151 }
25152
25153 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
25154         LDKChannelReestablish this_ptr_conv;
25155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25156         this_ptr_conv.is_owned = false;
25157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25158         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25159         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
25160         return ret_arr;
25161 }
25162
25163 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25164         LDKChannelReestablish this_ptr_conv;
25165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25166         this_ptr_conv.is_owned = false;
25167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25168         LDKThirtyTwoBytes val_ref;
25169         CHECK(val->arr_len == 32);
25170         memcpy(val_ref.data, val->elems, 32); FREE(val);
25171         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
25172 }
25173
25174 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
25175         LDKChannelReestablish this_ptr_conv;
25176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25177         this_ptr_conv.is_owned = false;
25178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25179         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
25180         return ret_val;
25181 }
25182
25183 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) {
25184         LDKChannelReestablish this_ptr_conv;
25185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25186         this_ptr_conv.is_owned = false;
25187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25188         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
25189 }
25190
25191 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
25192         LDKChannelReestablish this_ptr_conv;
25193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25194         this_ptr_conv.is_owned = false;
25195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25196         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
25197         return ret_val;
25198 }
25199
25200 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) {
25201         LDKChannelReestablish this_ptr_conv;
25202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25203         this_ptr_conv.is_owned = false;
25204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25205         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
25206 }
25207
25208 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
25209         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
25210 uintptr_t ret_ref = 0;
25211 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25212 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25213 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25214 ret_ref = (uintptr_t)ret_var.inner;
25215 if (ret_var.is_owned) {
25216         ret_ref |= 1;
25217 }
25218         return ret_ref;
25219 }
25220 intptr_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
25221         LDKChannelReestablish arg_conv;
25222         arg_conv.inner = (void*)(arg & (~1));
25223         arg_conv.is_owned = false;
25224         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25225         intptr_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
25226         return ret_val;
25227 }
25228
25229 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
25230         LDKChannelReestablish orig_conv;
25231         orig_conv.inner = (void*)(orig & (~1));
25232         orig_conv.is_owned = false;
25233         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25234         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
25235         uintptr_t ret_ref = 0;
25236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25239         ret_ref = (uintptr_t)ret_var.inner;
25240         if (ret_var.is_owned) {
25241                 ret_ref |= 1;
25242         }
25243         return ret_ref;
25244 }
25245
25246 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
25247         LDKAnnouncementSignatures this_obj_conv;
25248         this_obj_conv.inner = (void*)(this_obj & (~1));
25249         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25251         AnnouncementSignatures_free(this_obj_conv);
25252 }
25253
25254 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
25255         LDKAnnouncementSignatures this_ptr_conv;
25256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25257         this_ptr_conv.is_owned = false;
25258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25259         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25260         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
25261         return ret_arr;
25262 }
25263
25264 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25265         LDKAnnouncementSignatures this_ptr_conv;
25266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25267         this_ptr_conv.is_owned = false;
25268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25269         LDKThirtyTwoBytes val_ref;
25270         CHECK(val->arr_len == 32);
25271         memcpy(val_ref.data, val->elems, 32); FREE(val);
25272         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
25273 }
25274
25275 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
25276         LDKAnnouncementSignatures this_ptr_conv;
25277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25278         this_ptr_conv.is_owned = false;
25279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25280         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
25281         return ret_val;
25282 }
25283
25284 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
25285         LDKAnnouncementSignatures this_ptr_conv;
25286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25287         this_ptr_conv.is_owned = false;
25288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25289         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
25290 }
25291
25292 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
25293         LDKAnnouncementSignatures this_ptr_conv;
25294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25295         this_ptr_conv.is_owned = false;
25296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25297         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
25298         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
25299         return ret_arr;
25300 }
25301
25302 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
25303         LDKAnnouncementSignatures this_ptr_conv;
25304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25305         this_ptr_conv.is_owned = false;
25306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25307         LDKSignature val_ref;
25308         CHECK(val->arr_len == 64);
25309         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
25310         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
25311 }
25312
25313 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
25314         LDKAnnouncementSignatures this_ptr_conv;
25315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25316         this_ptr_conv.is_owned = false;
25317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25318         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
25319         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
25320         return ret_arr;
25321 }
25322
25323 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
25324         LDKAnnouncementSignatures this_ptr_conv;
25325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25326         this_ptr_conv.is_owned = false;
25327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25328         LDKSignature val_ref;
25329         CHECK(val->arr_len == 64);
25330         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
25331         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
25332 }
25333
25334 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) {
25335         LDKThirtyTwoBytes channel_id_arg_ref;
25336         CHECK(channel_id_arg->arr_len == 32);
25337         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
25338         LDKSignature node_signature_arg_ref;
25339         CHECK(node_signature_arg->arr_len == 64);
25340         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
25341         LDKSignature bitcoin_signature_arg_ref;
25342         CHECK(bitcoin_signature_arg->arr_len == 64);
25343         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
25344         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
25345         uintptr_t ret_ref = 0;
25346         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25347         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25349         ret_ref = (uintptr_t)ret_var.inner;
25350         if (ret_var.is_owned) {
25351                 ret_ref |= 1;
25352         }
25353         return ret_ref;
25354 }
25355
25356 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
25357         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
25358 uintptr_t ret_ref = 0;
25359 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25360 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25361 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25362 ret_ref = (uintptr_t)ret_var.inner;
25363 if (ret_var.is_owned) {
25364         ret_ref |= 1;
25365 }
25366         return ret_ref;
25367 }
25368 intptr_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
25369         LDKAnnouncementSignatures arg_conv;
25370         arg_conv.inner = (void*)(arg & (~1));
25371         arg_conv.is_owned = false;
25372         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25373         intptr_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
25374         return ret_val;
25375 }
25376
25377 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
25378         LDKAnnouncementSignatures orig_conv;
25379         orig_conv.inner = (void*)(orig & (~1));
25380         orig_conv.is_owned = false;
25381         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25382         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
25383         uintptr_t ret_ref = 0;
25384         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25385         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25387         ret_ref = (uintptr_t)ret_var.inner;
25388         if (ret_var.is_owned) {
25389                 ret_ref |= 1;
25390         }
25391         return ret_ref;
25392 }
25393
25394 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
25395         if ((this_ptr & 1) != 0) return;
25396         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25397         CHECK_ACCESS(this_ptr_ptr);
25398         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
25399         FREE((void*)this_ptr);
25400         NetAddress_free(this_ptr_conv);
25401 }
25402
25403 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
25404         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25405         *ret_copy = NetAddress_clone(arg);
25406 uintptr_t ret_ref = (uintptr_t)ret_copy;
25407         return ret_ref;
25408 }
25409 intptr_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
25410         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
25411         intptr_t ret_val = NetAddress_clone_ptr(arg_conv);
25412         return ret_val;
25413 }
25414
25415 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
25416         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
25417         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25418         *ret_copy = NetAddress_clone(orig_conv);
25419         uintptr_t ret_ref = (uintptr_t)ret_copy;
25420         return ret_ref;
25421 }
25422
25423 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
25424         LDKFourBytes addr_ref;
25425         CHECK(addr->arr_len == 4);
25426         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
25427         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25428         *ret_copy = NetAddress_ipv4(addr_ref, port);
25429         uintptr_t ret_ref = (uintptr_t)ret_copy;
25430         return ret_ref;
25431 }
25432
25433 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
25434         LDKSixteenBytes addr_ref;
25435         CHECK(addr->arr_len == 16);
25436         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
25437         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25438         *ret_copy = NetAddress_ipv6(addr_ref, port);
25439         uintptr_t ret_ref = (uintptr_t)ret_copy;
25440         return ret_ref;
25441 }
25442
25443 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
25444         LDKTwelveBytes a_ref;
25445         CHECK(a->arr_len == 12);
25446         memcpy(a_ref.data, a->elems, 12); FREE(a);
25447         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25448         *ret_copy = NetAddress_onion_v2(a_ref);
25449         uintptr_t ret_ref = (uintptr_t)ret_copy;
25450         return ret_ref;
25451 }
25452
25453 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) {
25454         LDKThirtyTwoBytes ed25519_pubkey_ref;
25455         CHECK(ed25519_pubkey->arr_len == 32);
25456         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
25457         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
25458         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
25459         uintptr_t ret_ref = (uintptr_t)ret_copy;
25460         return ret_ref;
25461 }
25462
25463 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
25464         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
25465         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
25466         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25467         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25468         CVec_u8Z_free(ret_var);
25469         return ret_arr;
25470 }
25471
25472 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
25473         LDKu8slice ser_ref;
25474         ser_ref.datalen = ser->arr_len;
25475         ser_ref.data = ser->elems /* XXX ser leaks */;
25476         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
25477         *ret_conv = NetAddress_read(ser_ref);
25478         return (uintptr_t)ret_conv;
25479 }
25480
25481 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
25482         LDKUnsignedNodeAnnouncement this_obj_conv;
25483         this_obj_conv.inner = (void*)(this_obj & (~1));
25484         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25486         UnsignedNodeAnnouncement_free(this_obj_conv);
25487 }
25488
25489 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
25490         LDKUnsignedNodeAnnouncement this_ptr_conv;
25491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25492         this_ptr_conv.is_owned = false;
25493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25494         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
25495         uintptr_t ret_ref = 0;
25496         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25497         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25499         ret_ref = (uintptr_t)ret_var.inner;
25500         if (ret_var.is_owned) {
25501                 ret_ref |= 1;
25502         }
25503         return ret_ref;
25504 }
25505
25506 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
25507         LDKUnsignedNodeAnnouncement this_ptr_conv;
25508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25509         this_ptr_conv.is_owned = false;
25510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25511         LDKNodeFeatures val_conv;
25512         val_conv.inner = (void*)(val & (~1));
25513         val_conv.is_owned = (val & 1) || (val == 0);
25514         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25515         val_conv = NodeFeatures_clone(&val_conv);
25516         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
25517 }
25518
25519 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
25520         LDKUnsignedNodeAnnouncement this_ptr_conv;
25521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25522         this_ptr_conv.is_owned = false;
25523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25524         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
25525         return ret_val;
25526 }
25527
25528 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
25529         LDKUnsignedNodeAnnouncement this_ptr_conv;
25530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25531         this_ptr_conv.is_owned = false;
25532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25533         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
25534 }
25535
25536 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
25537         LDKUnsignedNodeAnnouncement this_ptr_conv;
25538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25539         this_ptr_conv.is_owned = false;
25540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25541         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25542         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
25543         return ret_arr;
25544 }
25545
25546 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
25547         LDKUnsignedNodeAnnouncement this_ptr_conv;
25548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25549         this_ptr_conv.is_owned = false;
25550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25551         LDKPublicKey val_ref;
25552         CHECK(val->arr_len == 33);
25553         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25554         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
25555 }
25556
25557 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
25558         LDKUnsignedNodeAnnouncement this_ptr_conv;
25559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25560         this_ptr_conv.is_owned = false;
25561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25562         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
25563         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
25564         return ret_arr;
25565 }
25566
25567 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
25568         LDKUnsignedNodeAnnouncement this_ptr_conv;
25569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25570         this_ptr_conv.is_owned = false;
25571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25572         LDKThreeBytes val_ref;
25573         CHECK(val->arr_len == 3);
25574         memcpy(val_ref.data, val->elems, 3); FREE(val);
25575         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
25576 }
25577
25578 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
25579         LDKUnsignedNodeAnnouncement this_ptr_conv;
25580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25581         this_ptr_conv.is_owned = false;
25582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25583         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25584         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
25585         return ret_arr;
25586 }
25587
25588 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
25589         LDKUnsignedNodeAnnouncement this_ptr_conv;
25590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25591         this_ptr_conv.is_owned = false;
25592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25593         LDKThirtyTwoBytes val_ref;
25594         CHECK(val->arr_len == 32);
25595         memcpy(val_ref.data, val->elems, 32); FREE(val);
25596         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
25597 }
25598
25599 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
25600         LDKUnsignedNodeAnnouncement this_ptr_conv;
25601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25602         this_ptr_conv.is_owned = false;
25603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25604         LDKCVec_NetAddressZ val_constr;
25605         val_constr.datalen = val->arr_len;
25606         if (val_constr.datalen > 0)
25607                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25608         else
25609                 val_constr.data = NULL;
25610         uint32_t* val_vals = val->elems /* XXX val leaks */;
25611         for (size_t m = 0; m < val_constr.datalen; m++) {
25612                 uint32_t val_conv_12 = val_vals[m];
25613                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
25614                 CHECK_ACCESS(val_conv_12_ptr);
25615                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
25616                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
25617                 val_constr.data[m] = val_conv_12_conv;
25618         }
25619         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
25620 }
25621
25622 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
25623         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
25624 uintptr_t ret_ref = 0;
25625 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25626 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25627 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25628 ret_ref = (uintptr_t)ret_var.inner;
25629 if (ret_var.is_owned) {
25630         ret_ref |= 1;
25631 }
25632         return ret_ref;
25633 }
25634 intptr_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
25635         LDKUnsignedNodeAnnouncement arg_conv;
25636         arg_conv.inner = (void*)(arg & (~1));
25637         arg_conv.is_owned = false;
25638         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25639         intptr_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
25640         return ret_val;
25641 }
25642
25643 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
25644         LDKUnsignedNodeAnnouncement orig_conv;
25645         orig_conv.inner = (void*)(orig & (~1));
25646         orig_conv.is_owned = false;
25647         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25648         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
25649         uintptr_t ret_ref = 0;
25650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25653         ret_ref = (uintptr_t)ret_var.inner;
25654         if (ret_var.is_owned) {
25655                 ret_ref |= 1;
25656         }
25657         return ret_ref;
25658 }
25659
25660 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
25661         LDKNodeAnnouncement this_obj_conv;
25662         this_obj_conv.inner = (void*)(this_obj & (~1));
25663         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25665         NodeAnnouncement_free(this_obj_conv);
25666 }
25667
25668 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
25669         LDKNodeAnnouncement this_ptr_conv;
25670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25671         this_ptr_conv.is_owned = false;
25672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25673         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
25674         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
25675         return ret_arr;
25676 }
25677
25678 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
25679         LDKNodeAnnouncement this_ptr_conv;
25680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25681         this_ptr_conv.is_owned = false;
25682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25683         LDKSignature val_ref;
25684         CHECK(val->arr_len == 64);
25685         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
25686         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
25687 }
25688
25689 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
25690         LDKNodeAnnouncement this_ptr_conv;
25691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25692         this_ptr_conv.is_owned = false;
25693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25694         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
25695         uintptr_t ret_ref = 0;
25696         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25697         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25699         ret_ref = (uintptr_t)ret_var.inner;
25700         if (ret_var.is_owned) {
25701                 ret_ref |= 1;
25702         }
25703         return ret_ref;
25704 }
25705
25706 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
25707         LDKNodeAnnouncement this_ptr_conv;
25708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25709         this_ptr_conv.is_owned = false;
25710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25711         LDKUnsignedNodeAnnouncement val_conv;
25712         val_conv.inner = (void*)(val & (~1));
25713         val_conv.is_owned = (val & 1) || (val == 0);
25714         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25715         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
25716         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
25717 }
25718
25719 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
25720         LDKSignature signature_arg_ref;
25721         CHECK(signature_arg->arr_len == 64);
25722         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
25723         LDKUnsignedNodeAnnouncement contents_arg_conv;
25724         contents_arg_conv.inner = (void*)(contents_arg & (~1));
25725         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
25726         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
25727         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
25728         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
25729         uintptr_t ret_ref = 0;
25730         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25731         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25733         ret_ref = (uintptr_t)ret_var.inner;
25734         if (ret_var.is_owned) {
25735                 ret_ref |= 1;
25736         }
25737         return ret_ref;
25738 }
25739
25740 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
25741         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
25742 uintptr_t ret_ref = 0;
25743 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25744 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25745 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25746 ret_ref = (uintptr_t)ret_var.inner;
25747 if (ret_var.is_owned) {
25748         ret_ref |= 1;
25749 }
25750         return ret_ref;
25751 }
25752 intptr_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
25753         LDKNodeAnnouncement arg_conv;
25754         arg_conv.inner = (void*)(arg & (~1));
25755         arg_conv.is_owned = false;
25756         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25757         intptr_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
25758         return ret_val;
25759 }
25760
25761 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
25762         LDKNodeAnnouncement orig_conv;
25763         orig_conv.inner = (void*)(orig & (~1));
25764         orig_conv.is_owned = false;
25765         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25766         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
25767         uintptr_t ret_ref = 0;
25768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25771         ret_ref = (uintptr_t)ret_var.inner;
25772         if (ret_var.is_owned) {
25773                 ret_ref |= 1;
25774         }
25775         return ret_ref;
25776 }
25777
25778 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
25779         LDKUnsignedChannelAnnouncement this_obj_conv;
25780         this_obj_conv.inner = (void*)(this_obj & (~1));
25781         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25783         UnsignedChannelAnnouncement_free(this_obj_conv);
25784 }
25785
25786 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
25787         LDKUnsignedChannelAnnouncement this_ptr_conv;
25788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25789         this_ptr_conv.is_owned = false;
25790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25791         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
25792         uintptr_t ret_ref = 0;
25793         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25794         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25796         ret_ref = (uintptr_t)ret_var.inner;
25797         if (ret_var.is_owned) {
25798                 ret_ref |= 1;
25799         }
25800         return ret_ref;
25801 }
25802
25803 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
25804         LDKUnsignedChannelAnnouncement this_ptr_conv;
25805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25806         this_ptr_conv.is_owned = false;
25807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25808         LDKChannelFeatures val_conv;
25809         val_conv.inner = (void*)(val & (~1));
25810         val_conv.is_owned = (val & 1) || (val == 0);
25811         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25812         val_conv = ChannelFeatures_clone(&val_conv);
25813         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
25814 }
25815
25816 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
25817         LDKUnsignedChannelAnnouncement this_ptr_conv;
25818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25819         this_ptr_conv.is_owned = false;
25820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25821         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25822         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
25823         return ret_arr;
25824 }
25825
25826 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
25827         LDKUnsignedChannelAnnouncement this_ptr_conv;
25828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25829         this_ptr_conv.is_owned = false;
25830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25831         LDKThirtyTwoBytes val_ref;
25832         CHECK(val->arr_len == 32);
25833         memcpy(val_ref.data, val->elems, 32); FREE(val);
25834         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
25835 }
25836
25837 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
25838         LDKUnsignedChannelAnnouncement this_ptr_conv;
25839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25840         this_ptr_conv.is_owned = false;
25841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25842         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
25843         return ret_val;
25844 }
25845
25846 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
25847         LDKUnsignedChannelAnnouncement this_ptr_conv;
25848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25849         this_ptr_conv.is_owned = false;
25850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25851         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
25852 }
25853
25854 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
25855         LDKUnsignedChannelAnnouncement this_ptr_conv;
25856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25857         this_ptr_conv.is_owned = false;
25858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25859         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25860         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
25861         return ret_arr;
25862 }
25863
25864 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
25865         LDKUnsignedChannelAnnouncement this_ptr_conv;
25866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25867         this_ptr_conv.is_owned = false;
25868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25869         LDKPublicKey val_ref;
25870         CHECK(val->arr_len == 33);
25871         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25872         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
25873 }
25874
25875 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
25876         LDKUnsignedChannelAnnouncement this_ptr_conv;
25877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25878         this_ptr_conv.is_owned = false;
25879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25880         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25881         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
25882         return ret_arr;
25883 }
25884
25885 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
25886         LDKUnsignedChannelAnnouncement this_ptr_conv;
25887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25888         this_ptr_conv.is_owned = false;
25889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25890         LDKPublicKey val_ref;
25891         CHECK(val->arr_len == 33);
25892         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25893         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
25894 }
25895
25896 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
25897         LDKUnsignedChannelAnnouncement this_ptr_conv;
25898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25899         this_ptr_conv.is_owned = false;
25900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25901         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25902         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
25903         return ret_arr;
25904 }
25905
25906 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
25907         LDKUnsignedChannelAnnouncement this_ptr_conv;
25908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25909         this_ptr_conv.is_owned = false;
25910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25911         LDKPublicKey val_ref;
25912         CHECK(val->arr_len == 33);
25913         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25914         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
25915 }
25916
25917 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
25918         LDKUnsignedChannelAnnouncement this_ptr_conv;
25919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25920         this_ptr_conv.is_owned = false;
25921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25922         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25923         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
25924         return ret_arr;
25925 }
25926
25927 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
25928         LDKUnsignedChannelAnnouncement this_ptr_conv;
25929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25930         this_ptr_conv.is_owned = false;
25931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25932         LDKPublicKey val_ref;
25933         CHECK(val->arr_len == 33);
25934         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25935         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
25936 }
25937
25938 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
25939         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
25940 uintptr_t ret_ref = 0;
25941 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25942 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25943 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25944 ret_ref = (uintptr_t)ret_var.inner;
25945 if (ret_var.is_owned) {
25946         ret_ref |= 1;
25947 }
25948         return ret_ref;
25949 }
25950 intptr_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
25951         LDKUnsignedChannelAnnouncement arg_conv;
25952         arg_conv.inner = (void*)(arg & (~1));
25953         arg_conv.is_owned = false;
25954         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25955         intptr_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
25956         return ret_val;
25957 }
25958
25959 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
25960         LDKUnsignedChannelAnnouncement orig_conv;
25961         orig_conv.inner = (void*)(orig & (~1));
25962         orig_conv.is_owned = false;
25963         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25964         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
25965         uintptr_t ret_ref = 0;
25966         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25967         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25969         ret_ref = (uintptr_t)ret_var.inner;
25970         if (ret_var.is_owned) {
25971                 ret_ref |= 1;
25972         }
25973         return ret_ref;
25974 }
25975
25976 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
25977         LDKChannelAnnouncement this_obj_conv;
25978         this_obj_conv.inner = (void*)(this_obj & (~1));
25979         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25981         ChannelAnnouncement_free(this_obj_conv);
25982 }
25983
25984 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
25985         LDKChannelAnnouncement this_ptr_conv;
25986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25987         this_ptr_conv.is_owned = false;
25988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25989         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
25990         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
25991         return ret_arr;
25992 }
25993
25994 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
25995         LDKChannelAnnouncement this_ptr_conv;
25996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25997         this_ptr_conv.is_owned = false;
25998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25999         LDKSignature val_ref;
26000         CHECK(val->arr_len == 64);
26001         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
26002         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
26003 }
26004
26005 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
26006         LDKChannelAnnouncement this_ptr_conv;
26007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26008         this_ptr_conv.is_owned = false;
26009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26010         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
26011         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
26012         return ret_arr;
26013 }
26014
26015 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
26016         LDKChannelAnnouncement this_ptr_conv;
26017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26018         this_ptr_conv.is_owned = false;
26019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26020         LDKSignature val_ref;
26021         CHECK(val->arr_len == 64);
26022         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
26023         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
26024 }
26025
26026 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
26027         LDKChannelAnnouncement this_ptr_conv;
26028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26029         this_ptr_conv.is_owned = false;
26030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26031         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
26032         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
26033         return ret_arr;
26034 }
26035
26036 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
26037         LDKChannelAnnouncement this_ptr_conv;
26038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26039         this_ptr_conv.is_owned = false;
26040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26041         LDKSignature val_ref;
26042         CHECK(val->arr_len == 64);
26043         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
26044         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
26045 }
26046
26047 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
26048         LDKChannelAnnouncement this_ptr_conv;
26049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26050         this_ptr_conv.is_owned = false;
26051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26052         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
26053         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
26054         return ret_arr;
26055 }
26056
26057 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
26058         LDKChannelAnnouncement this_ptr_conv;
26059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26060         this_ptr_conv.is_owned = false;
26061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26062         LDKSignature val_ref;
26063         CHECK(val->arr_len == 64);
26064         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
26065         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
26066 }
26067
26068 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
26069         LDKChannelAnnouncement this_ptr_conv;
26070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26071         this_ptr_conv.is_owned = false;
26072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26073         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
26074         uintptr_t ret_ref = 0;
26075         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26076         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26078         ret_ref = (uintptr_t)ret_var.inner;
26079         if (ret_var.is_owned) {
26080                 ret_ref |= 1;
26081         }
26082         return ret_ref;
26083 }
26084
26085 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
26086         LDKChannelAnnouncement this_ptr_conv;
26087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26088         this_ptr_conv.is_owned = false;
26089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26090         LDKUnsignedChannelAnnouncement val_conv;
26091         val_conv.inner = (void*)(val & (~1));
26092         val_conv.is_owned = (val & 1) || (val == 0);
26093         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26094         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
26095         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
26096 }
26097
26098 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) {
26099         LDKSignature node_signature_1_arg_ref;
26100         CHECK(node_signature_1_arg->arr_len == 64);
26101         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
26102         LDKSignature node_signature_2_arg_ref;
26103         CHECK(node_signature_2_arg->arr_len == 64);
26104         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
26105         LDKSignature bitcoin_signature_1_arg_ref;
26106         CHECK(bitcoin_signature_1_arg->arr_len == 64);
26107         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
26108         LDKSignature bitcoin_signature_2_arg_ref;
26109         CHECK(bitcoin_signature_2_arg->arr_len == 64);
26110         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
26111         LDKUnsignedChannelAnnouncement contents_arg_conv;
26112         contents_arg_conv.inner = (void*)(contents_arg & (~1));
26113         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
26114         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
26115         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
26116         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);
26117         uintptr_t ret_ref = 0;
26118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26121         ret_ref = (uintptr_t)ret_var.inner;
26122         if (ret_var.is_owned) {
26123                 ret_ref |= 1;
26124         }
26125         return ret_ref;
26126 }
26127
26128 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
26129         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
26130 uintptr_t ret_ref = 0;
26131 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26132 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26133 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26134 ret_ref = (uintptr_t)ret_var.inner;
26135 if (ret_var.is_owned) {
26136         ret_ref |= 1;
26137 }
26138         return ret_ref;
26139 }
26140 intptr_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
26141         LDKChannelAnnouncement arg_conv;
26142         arg_conv.inner = (void*)(arg & (~1));
26143         arg_conv.is_owned = false;
26144         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26145         intptr_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
26146         return ret_val;
26147 }
26148
26149 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
26150         LDKChannelAnnouncement orig_conv;
26151         orig_conv.inner = (void*)(orig & (~1));
26152         orig_conv.is_owned = false;
26153         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26154         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
26155         uintptr_t ret_ref = 0;
26156         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26157         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26159         ret_ref = (uintptr_t)ret_var.inner;
26160         if (ret_var.is_owned) {
26161                 ret_ref |= 1;
26162         }
26163         return ret_ref;
26164 }
26165
26166 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
26167         LDKUnsignedChannelUpdate this_obj_conv;
26168         this_obj_conv.inner = (void*)(this_obj & (~1));
26169         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26171         UnsignedChannelUpdate_free(this_obj_conv);
26172 }
26173
26174 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
26175         LDKUnsignedChannelUpdate this_ptr_conv;
26176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26177         this_ptr_conv.is_owned = false;
26178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26179         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26180         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
26181         return ret_arr;
26182 }
26183
26184 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26185         LDKUnsignedChannelUpdate this_ptr_conv;
26186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26187         this_ptr_conv.is_owned = false;
26188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26189         LDKThirtyTwoBytes val_ref;
26190         CHECK(val->arr_len == 32);
26191         memcpy(val_ref.data, val->elems, 32); FREE(val);
26192         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
26193 }
26194
26195 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
26196         LDKUnsignedChannelUpdate this_ptr_conv;
26197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26198         this_ptr_conv.is_owned = false;
26199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26200         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
26201         return ret_val;
26202 }
26203
26204 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
26205         LDKUnsignedChannelUpdate this_ptr_conv;
26206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26207         this_ptr_conv.is_owned = false;
26208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26209         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
26210 }
26211
26212 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
26213         LDKUnsignedChannelUpdate this_ptr_conv;
26214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26215         this_ptr_conv.is_owned = false;
26216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26217         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
26218         return ret_val;
26219 }
26220
26221 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
26222         LDKUnsignedChannelUpdate this_ptr_conv;
26223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26224         this_ptr_conv.is_owned = false;
26225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26226         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
26227 }
26228
26229 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
26230         LDKUnsignedChannelUpdate this_ptr_conv;
26231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26232         this_ptr_conv.is_owned = false;
26233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26234         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
26235         return ret_val;
26236 }
26237
26238 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
26239         LDKUnsignedChannelUpdate this_ptr_conv;
26240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26241         this_ptr_conv.is_owned = false;
26242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26243         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
26244 }
26245
26246 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
26247         LDKUnsignedChannelUpdate this_ptr_conv;
26248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26249         this_ptr_conv.is_owned = false;
26250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26251         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
26252         return ret_val;
26253 }
26254
26255 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
26256         LDKUnsignedChannelUpdate this_ptr_conv;
26257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26258         this_ptr_conv.is_owned = false;
26259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26260         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
26261 }
26262
26263 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
26264         LDKUnsignedChannelUpdate this_ptr_conv;
26265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26266         this_ptr_conv.is_owned = false;
26267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26268         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
26269         return ret_val;
26270 }
26271
26272 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26273         LDKUnsignedChannelUpdate this_ptr_conv;
26274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26275         this_ptr_conv.is_owned = false;
26276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26277         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
26278 }
26279
26280 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
26281         LDKUnsignedChannelUpdate this_ptr_conv;
26282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26283         this_ptr_conv.is_owned = false;
26284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26285         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
26286         return ret_val;
26287 }
26288
26289 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
26290         LDKUnsignedChannelUpdate this_ptr_conv;
26291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26292         this_ptr_conv.is_owned = false;
26293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26294         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
26295 }
26296
26297 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
26298         LDKUnsignedChannelUpdate this_ptr_conv;
26299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26300         this_ptr_conv.is_owned = false;
26301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26302         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
26303         return ret_val;
26304 }
26305
26306 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
26307         LDKUnsignedChannelUpdate this_ptr_conv;
26308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26309         this_ptr_conv.is_owned = false;
26310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26311         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
26312 }
26313
26314 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
26315         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
26316 uintptr_t ret_ref = 0;
26317 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26318 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26319 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26320 ret_ref = (uintptr_t)ret_var.inner;
26321 if (ret_var.is_owned) {
26322         ret_ref |= 1;
26323 }
26324         return ret_ref;
26325 }
26326 intptr_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
26327         LDKUnsignedChannelUpdate arg_conv;
26328         arg_conv.inner = (void*)(arg & (~1));
26329         arg_conv.is_owned = false;
26330         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26331         intptr_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
26332         return ret_val;
26333 }
26334
26335 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
26336         LDKUnsignedChannelUpdate orig_conv;
26337         orig_conv.inner = (void*)(orig & (~1));
26338         orig_conv.is_owned = false;
26339         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26340         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
26341         uintptr_t ret_ref = 0;
26342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26345         ret_ref = (uintptr_t)ret_var.inner;
26346         if (ret_var.is_owned) {
26347                 ret_ref |= 1;
26348         }
26349         return ret_ref;
26350 }
26351
26352 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
26353         LDKChannelUpdate this_obj_conv;
26354         this_obj_conv.inner = (void*)(this_obj & (~1));
26355         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26357         ChannelUpdate_free(this_obj_conv);
26358 }
26359
26360 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
26361         LDKChannelUpdate this_ptr_conv;
26362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26363         this_ptr_conv.is_owned = false;
26364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26365         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
26366         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
26367         return ret_arr;
26368 }
26369
26370 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
26371         LDKChannelUpdate this_ptr_conv;
26372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26373         this_ptr_conv.is_owned = false;
26374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26375         LDKSignature val_ref;
26376         CHECK(val->arr_len == 64);
26377         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
26378         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
26379 }
26380
26381 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
26382         LDKChannelUpdate this_ptr_conv;
26383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26384         this_ptr_conv.is_owned = false;
26385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26386         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
26387         uintptr_t ret_ref = 0;
26388         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26389         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26390         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26391         ret_ref = (uintptr_t)ret_var.inner;
26392         if (ret_var.is_owned) {
26393                 ret_ref |= 1;
26394         }
26395         return ret_ref;
26396 }
26397
26398 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
26399         LDKChannelUpdate this_ptr_conv;
26400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26401         this_ptr_conv.is_owned = false;
26402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26403         LDKUnsignedChannelUpdate val_conv;
26404         val_conv.inner = (void*)(val & (~1));
26405         val_conv.is_owned = (val & 1) || (val == 0);
26406         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26407         val_conv = UnsignedChannelUpdate_clone(&val_conv);
26408         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
26409 }
26410
26411 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
26412         LDKSignature signature_arg_ref;
26413         CHECK(signature_arg->arr_len == 64);
26414         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
26415         LDKUnsignedChannelUpdate contents_arg_conv;
26416         contents_arg_conv.inner = (void*)(contents_arg & (~1));
26417         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
26418         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
26419         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
26420         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
26421         uintptr_t ret_ref = 0;
26422         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26423         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26425         ret_ref = (uintptr_t)ret_var.inner;
26426         if (ret_var.is_owned) {
26427                 ret_ref |= 1;
26428         }
26429         return ret_ref;
26430 }
26431
26432 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
26433         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
26434 uintptr_t ret_ref = 0;
26435 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26436 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26437 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26438 ret_ref = (uintptr_t)ret_var.inner;
26439 if (ret_var.is_owned) {
26440         ret_ref |= 1;
26441 }
26442         return ret_ref;
26443 }
26444 intptr_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
26445         LDKChannelUpdate arg_conv;
26446         arg_conv.inner = (void*)(arg & (~1));
26447         arg_conv.is_owned = false;
26448         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26449         intptr_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
26450         return ret_val;
26451 }
26452
26453 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
26454         LDKChannelUpdate orig_conv;
26455         orig_conv.inner = (void*)(orig & (~1));
26456         orig_conv.is_owned = false;
26457         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26458         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
26459         uintptr_t ret_ref = 0;
26460         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26461         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26463         ret_ref = (uintptr_t)ret_var.inner;
26464         if (ret_var.is_owned) {
26465                 ret_ref |= 1;
26466         }
26467         return ret_ref;
26468 }
26469
26470 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
26471         LDKQueryChannelRange this_obj_conv;
26472         this_obj_conv.inner = (void*)(this_obj & (~1));
26473         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26475         QueryChannelRange_free(this_obj_conv);
26476 }
26477
26478 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
26479         LDKQueryChannelRange this_ptr_conv;
26480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26481         this_ptr_conv.is_owned = false;
26482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26483         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26484         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
26485         return ret_arr;
26486 }
26487
26488 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26489         LDKQueryChannelRange this_ptr_conv;
26490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26491         this_ptr_conv.is_owned = false;
26492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26493         LDKThirtyTwoBytes val_ref;
26494         CHECK(val->arr_len == 32);
26495         memcpy(val_ref.data, val->elems, 32); FREE(val);
26496         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
26497 }
26498
26499 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
26500         LDKQueryChannelRange this_ptr_conv;
26501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26502         this_ptr_conv.is_owned = false;
26503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26504         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
26505         return ret_val;
26506 }
26507
26508 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
26509         LDKQueryChannelRange this_ptr_conv;
26510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26511         this_ptr_conv.is_owned = false;
26512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26513         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
26514 }
26515
26516 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
26517         LDKQueryChannelRange this_ptr_conv;
26518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26519         this_ptr_conv.is_owned = false;
26520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26521         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
26522         return ret_val;
26523 }
26524
26525 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
26526         LDKQueryChannelRange this_ptr_conv;
26527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26528         this_ptr_conv.is_owned = false;
26529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26530         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
26531 }
26532
26533 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) {
26534         LDKThirtyTwoBytes chain_hash_arg_ref;
26535         CHECK(chain_hash_arg->arr_len == 32);
26536         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
26537         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
26538         uintptr_t ret_ref = 0;
26539         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26540         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26542         ret_ref = (uintptr_t)ret_var.inner;
26543         if (ret_var.is_owned) {
26544                 ret_ref |= 1;
26545         }
26546         return ret_ref;
26547 }
26548
26549 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
26550         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
26551 uintptr_t ret_ref = 0;
26552 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26553 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26554 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26555 ret_ref = (uintptr_t)ret_var.inner;
26556 if (ret_var.is_owned) {
26557         ret_ref |= 1;
26558 }
26559         return ret_ref;
26560 }
26561 intptr_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
26562         LDKQueryChannelRange arg_conv;
26563         arg_conv.inner = (void*)(arg & (~1));
26564         arg_conv.is_owned = false;
26565         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26566         intptr_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
26567         return ret_val;
26568 }
26569
26570 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
26571         LDKQueryChannelRange orig_conv;
26572         orig_conv.inner = (void*)(orig & (~1));
26573         orig_conv.is_owned = false;
26574         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26575         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
26576         uintptr_t ret_ref = 0;
26577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26580         ret_ref = (uintptr_t)ret_var.inner;
26581         if (ret_var.is_owned) {
26582                 ret_ref |= 1;
26583         }
26584         return ret_ref;
26585 }
26586
26587 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
26588         LDKReplyChannelRange this_obj_conv;
26589         this_obj_conv.inner = (void*)(this_obj & (~1));
26590         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26592         ReplyChannelRange_free(this_obj_conv);
26593 }
26594
26595 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
26596         LDKReplyChannelRange this_ptr_conv;
26597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26598         this_ptr_conv.is_owned = false;
26599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26600         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26601         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
26602         return ret_arr;
26603 }
26604
26605 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26606         LDKReplyChannelRange this_ptr_conv;
26607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26608         this_ptr_conv.is_owned = false;
26609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26610         LDKThirtyTwoBytes val_ref;
26611         CHECK(val->arr_len == 32);
26612         memcpy(val_ref.data, val->elems, 32); FREE(val);
26613         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
26614 }
26615
26616 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
26617         LDKReplyChannelRange this_ptr_conv;
26618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26619         this_ptr_conv.is_owned = false;
26620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26621         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
26622         return ret_val;
26623 }
26624
26625 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
26626         LDKReplyChannelRange this_ptr_conv;
26627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26628         this_ptr_conv.is_owned = false;
26629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26630         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
26631 }
26632
26633 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
26634         LDKReplyChannelRange this_ptr_conv;
26635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26636         this_ptr_conv.is_owned = false;
26637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26638         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
26639         return ret_val;
26640 }
26641
26642 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
26643         LDKReplyChannelRange this_ptr_conv;
26644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26645         this_ptr_conv.is_owned = false;
26646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26647         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
26648 }
26649
26650 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
26651         LDKReplyChannelRange this_ptr_conv;
26652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26653         this_ptr_conv.is_owned = false;
26654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26655         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
26656         return ret_val;
26657 }
26658
26659 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
26660         LDKReplyChannelRange this_ptr_conv;
26661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26662         this_ptr_conv.is_owned = false;
26663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26664         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
26665 }
26666
26667 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
26668         LDKReplyChannelRange this_ptr_conv;
26669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26670         this_ptr_conv.is_owned = false;
26671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26672         LDKCVec_u64Z val_constr;
26673         val_constr.datalen = val->arr_len;
26674         if (val_constr.datalen > 0)
26675                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26676         else
26677                 val_constr.data = NULL;
26678         int64_t* val_vals = val->elems /* XXX val leaks */;
26679         for (size_t i = 0; i < val_constr.datalen; i++) {
26680                 int64_t val_conv_8 = val_vals[i];
26681                 val_constr.data[i] = val_conv_8;
26682         }
26683         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
26684 }
26685
26686 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) {
26687         LDKThirtyTwoBytes chain_hash_arg_ref;
26688         CHECK(chain_hash_arg->arr_len == 32);
26689         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
26690         LDKCVec_u64Z short_channel_ids_arg_constr;
26691         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
26692         if (short_channel_ids_arg_constr.datalen > 0)
26693                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26694         else
26695                 short_channel_ids_arg_constr.data = NULL;
26696         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
26697         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
26698                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
26699                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
26700         }
26701         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
26702         uintptr_t ret_ref = 0;
26703         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26704         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26706         ret_ref = (uintptr_t)ret_var.inner;
26707         if (ret_var.is_owned) {
26708                 ret_ref |= 1;
26709         }
26710         return ret_ref;
26711 }
26712
26713 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
26714         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
26715 uintptr_t ret_ref = 0;
26716 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26717 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26718 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26719 ret_ref = (uintptr_t)ret_var.inner;
26720 if (ret_var.is_owned) {
26721         ret_ref |= 1;
26722 }
26723         return ret_ref;
26724 }
26725 intptr_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
26726         LDKReplyChannelRange arg_conv;
26727         arg_conv.inner = (void*)(arg & (~1));
26728         arg_conv.is_owned = false;
26729         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26730         intptr_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
26731         return ret_val;
26732 }
26733
26734 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
26735         LDKReplyChannelRange orig_conv;
26736         orig_conv.inner = (void*)(orig & (~1));
26737         orig_conv.is_owned = false;
26738         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26739         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
26740         uintptr_t ret_ref = 0;
26741         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26742         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26744         ret_ref = (uintptr_t)ret_var.inner;
26745         if (ret_var.is_owned) {
26746                 ret_ref |= 1;
26747         }
26748         return ret_ref;
26749 }
26750
26751 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
26752         LDKQueryShortChannelIds this_obj_conv;
26753         this_obj_conv.inner = (void*)(this_obj & (~1));
26754         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26756         QueryShortChannelIds_free(this_obj_conv);
26757 }
26758
26759 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
26760         LDKQueryShortChannelIds this_ptr_conv;
26761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26762         this_ptr_conv.is_owned = false;
26763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26764         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26765         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
26766         return ret_arr;
26767 }
26768
26769 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26770         LDKQueryShortChannelIds this_ptr_conv;
26771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26772         this_ptr_conv.is_owned = false;
26773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26774         LDKThirtyTwoBytes val_ref;
26775         CHECK(val->arr_len == 32);
26776         memcpy(val_ref.data, val->elems, 32); FREE(val);
26777         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
26778 }
26779
26780 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
26781         LDKQueryShortChannelIds this_ptr_conv;
26782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26783         this_ptr_conv.is_owned = false;
26784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26785         LDKCVec_u64Z val_constr;
26786         val_constr.datalen = val->arr_len;
26787         if (val_constr.datalen > 0)
26788                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26789         else
26790                 val_constr.data = NULL;
26791         int64_t* val_vals = val->elems /* XXX val leaks */;
26792         for (size_t i = 0; i < val_constr.datalen; i++) {
26793                 int64_t val_conv_8 = val_vals[i];
26794                 val_constr.data[i] = val_conv_8;
26795         }
26796         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
26797 }
26798
26799 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
26800         LDKThirtyTwoBytes chain_hash_arg_ref;
26801         CHECK(chain_hash_arg->arr_len == 32);
26802         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
26803         LDKCVec_u64Z short_channel_ids_arg_constr;
26804         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
26805         if (short_channel_ids_arg_constr.datalen > 0)
26806                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
26807         else
26808                 short_channel_ids_arg_constr.data = NULL;
26809         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
26810         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
26811                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
26812                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
26813         }
26814         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
26815         uintptr_t ret_ref = 0;
26816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26819         ret_ref = (uintptr_t)ret_var.inner;
26820         if (ret_var.is_owned) {
26821                 ret_ref |= 1;
26822         }
26823         return ret_ref;
26824 }
26825
26826 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
26827         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
26828 uintptr_t ret_ref = 0;
26829 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26830 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26831 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26832 ret_ref = (uintptr_t)ret_var.inner;
26833 if (ret_var.is_owned) {
26834         ret_ref |= 1;
26835 }
26836         return ret_ref;
26837 }
26838 intptr_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
26839         LDKQueryShortChannelIds arg_conv;
26840         arg_conv.inner = (void*)(arg & (~1));
26841         arg_conv.is_owned = false;
26842         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26843         intptr_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
26844         return ret_val;
26845 }
26846
26847 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
26848         LDKQueryShortChannelIds orig_conv;
26849         orig_conv.inner = (void*)(orig & (~1));
26850         orig_conv.is_owned = false;
26851         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26852         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
26853         uintptr_t ret_ref = 0;
26854         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26855         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26857         ret_ref = (uintptr_t)ret_var.inner;
26858         if (ret_var.is_owned) {
26859                 ret_ref |= 1;
26860         }
26861         return ret_ref;
26862 }
26863
26864 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
26865         LDKReplyShortChannelIdsEnd this_obj_conv;
26866         this_obj_conv.inner = (void*)(this_obj & (~1));
26867         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26869         ReplyShortChannelIdsEnd_free(this_obj_conv);
26870 }
26871
26872 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
26873         LDKReplyShortChannelIdsEnd this_ptr_conv;
26874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26875         this_ptr_conv.is_owned = false;
26876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26877         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26878         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
26879         return ret_arr;
26880 }
26881
26882 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26883         LDKReplyShortChannelIdsEnd this_ptr_conv;
26884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26885         this_ptr_conv.is_owned = false;
26886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26887         LDKThirtyTwoBytes val_ref;
26888         CHECK(val->arr_len == 32);
26889         memcpy(val_ref.data, val->elems, 32); FREE(val);
26890         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
26891 }
26892
26893 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
26894         LDKReplyShortChannelIdsEnd this_ptr_conv;
26895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26896         this_ptr_conv.is_owned = false;
26897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26898         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
26899         return ret_val;
26900 }
26901
26902 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
26903         LDKReplyShortChannelIdsEnd this_ptr_conv;
26904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26905         this_ptr_conv.is_owned = false;
26906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26907         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
26908 }
26909
26910 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
26911         LDKThirtyTwoBytes chain_hash_arg_ref;
26912         CHECK(chain_hash_arg->arr_len == 32);
26913         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
26914         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
26915         uintptr_t ret_ref = 0;
26916         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26917         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26919         ret_ref = (uintptr_t)ret_var.inner;
26920         if (ret_var.is_owned) {
26921                 ret_ref |= 1;
26922         }
26923         return ret_ref;
26924 }
26925
26926 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
26927         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
26928 uintptr_t ret_ref = 0;
26929 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26930 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26931 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26932 ret_ref = (uintptr_t)ret_var.inner;
26933 if (ret_var.is_owned) {
26934         ret_ref |= 1;
26935 }
26936         return ret_ref;
26937 }
26938 intptr_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
26939         LDKReplyShortChannelIdsEnd arg_conv;
26940         arg_conv.inner = (void*)(arg & (~1));
26941         arg_conv.is_owned = false;
26942         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26943         intptr_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
26944         return ret_val;
26945 }
26946
26947 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
26948         LDKReplyShortChannelIdsEnd orig_conv;
26949         orig_conv.inner = (void*)(orig & (~1));
26950         orig_conv.is_owned = false;
26951         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26952         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
26953         uintptr_t ret_ref = 0;
26954         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26955         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26957         ret_ref = (uintptr_t)ret_var.inner;
26958         if (ret_var.is_owned) {
26959                 ret_ref |= 1;
26960         }
26961         return ret_ref;
26962 }
26963
26964 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
26965         LDKGossipTimestampFilter this_obj_conv;
26966         this_obj_conv.inner = (void*)(this_obj & (~1));
26967         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26969         GossipTimestampFilter_free(this_obj_conv);
26970 }
26971
26972 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
26973         LDKGossipTimestampFilter this_ptr_conv;
26974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26975         this_ptr_conv.is_owned = false;
26976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26977         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26978         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
26979         return ret_arr;
26980 }
26981
26982 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26983         LDKGossipTimestampFilter this_ptr_conv;
26984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26985         this_ptr_conv.is_owned = false;
26986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26987         LDKThirtyTwoBytes val_ref;
26988         CHECK(val->arr_len == 32);
26989         memcpy(val_ref.data, val->elems, 32); FREE(val);
26990         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
26991 }
26992
26993 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
26994         LDKGossipTimestampFilter this_ptr_conv;
26995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26996         this_ptr_conv.is_owned = false;
26997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26998         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
26999         return ret_val;
27000 }
27001
27002 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
27003         LDKGossipTimestampFilter this_ptr_conv;
27004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27005         this_ptr_conv.is_owned = false;
27006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27007         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
27008 }
27009
27010 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
27011         LDKGossipTimestampFilter this_ptr_conv;
27012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27013         this_ptr_conv.is_owned = false;
27014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27015         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
27016         return ret_val;
27017 }
27018
27019 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
27020         LDKGossipTimestampFilter this_ptr_conv;
27021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27022         this_ptr_conv.is_owned = false;
27023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27024         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
27025 }
27026
27027 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) {
27028         LDKThirtyTwoBytes chain_hash_arg_ref;
27029         CHECK(chain_hash_arg->arr_len == 32);
27030         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
27031         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
27032         uintptr_t ret_ref = 0;
27033         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27034         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27035         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27036         ret_ref = (uintptr_t)ret_var.inner;
27037         if (ret_var.is_owned) {
27038                 ret_ref |= 1;
27039         }
27040         return ret_ref;
27041 }
27042
27043 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
27044         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
27045 uintptr_t ret_ref = 0;
27046 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27047 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27048 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27049 ret_ref = (uintptr_t)ret_var.inner;
27050 if (ret_var.is_owned) {
27051         ret_ref |= 1;
27052 }
27053         return ret_ref;
27054 }
27055 intptr_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
27056         LDKGossipTimestampFilter arg_conv;
27057         arg_conv.inner = (void*)(arg & (~1));
27058         arg_conv.is_owned = false;
27059         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27060         intptr_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
27061         return ret_val;
27062 }
27063
27064 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
27065         LDKGossipTimestampFilter orig_conv;
27066         orig_conv.inner = (void*)(orig & (~1));
27067         orig_conv.is_owned = false;
27068         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27069         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
27070         uintptr_t ret_ref = 0;
27071         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27072         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27074         ret_ref = (uintptr_t)ret_var.inner;
27075         if (ret_var.is_owned) {
27076                 ret_ref |= 1;
27077         }
27078         return ret_ref;
27079 }
27080
27081 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
27082         if ((this_ptr & 1) != 0) return;
27083         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27084         CHECK_ACCESS(this_ptr_ptr);
27085         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
27086         FREE((void*)this_ptr);
27087         ErrorAction_free(this_ptr_conv);
27088 }
27089
27090 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
27091         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27092         *ret_copy = ErrorAction_clone(arg);
27093 uintptr_t ret_ref = (uintptr_t)ret_copy;
27094         return ret_ref;
27095 }
27096 intptr_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
27097         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
27098         intptr_t ret_val = ErrorAction_clone_ptr(arg_conv);
27099         return ret_val;
27100 }
27101
27102 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
27103         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
27104         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27105         *ret_copy = ErrorAction_clone(orig_conv);
27106         uintptr_t ret_ref = (uintptr_t)ret_copy;
27107         return ret_ref;
27108 }
27109
27110 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
27111         LDKErrorMessage msg_conv;
27112         msg_conv.inner = (void*)(msg & (~1));
27113         msg_conv.is_owned = (msg & 1) || (msg == 0);
27114         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27115         msg_conv = ErrorMessage_clone(&msg_conv);
27116         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27117         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
27118         uintptr_t ret_ref = (uintptr_t)ret_copy;
27119         return ret_ref;
27120 }
27121
27122 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
27123         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27124         *ret_copy = ErrorAction_ignore_error();
27125         uintptr_t ret_ref = (uintptr_t)ret_copy;
27126         return ret_ref;
27127 }
27128
27129 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
27130         LDKLevel a_conv = LDKLevel_from_js(a);
27131         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27132         *ret_copy = ErrorAction_ignore_and_log(a_conv);
27133         uintptr_t ret_ref = (uintptr_t)ret_copy;
27134         return ret_ref;
27135 }
27136
27137 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
27138         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27139         *ret_copy = ErrorAction_ignore_duplicate_gossip();
27140         uintptr_t ret_ref = (uintptr_t)ret_copy;
27141         return ret_ref;
27142 }
27143
27144 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
27145         LDKErrorMessage msg_conv;
27146         msg_conv.inner = (void*)(msg & (~1));
27147         msg_conv.is_owned = (msg & 1) || (msg == 0);
27148         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
27149         msg_conv = ErrorMessage_clone(&msg_conv);
27150         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27151         *ret_copy = ErrorAction_send_error_message(msg_conv);
27152         uintptr_t ret_ref = (uintptr_t)ret_copy;
27153         return ret_ref;
27154 }
27155
27156 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
27157         LDKLightningError this_obj_conv;
27158         this_obj_conv.inner = (void*)(this_obj & (~1));
27159         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27161         LightningError_free(this_obj_conv);
27162 }
27163
27164 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
27165         LDKLightningError this_ptr_conv;
27166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27167         this_ptr_conv.is_owned = false;
27168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27169         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
27170         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27171         Str_free(ret_str);
27172         return ret_conv;
27173 }
27174
27175 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
27176         LDKLightningError this_ptr_conv;
27177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27178         this_ptr_conv.is_owned = false;
27179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27180         LDKStr val_conv = str_ref_to_owned_c(val);
27181         LightningError_set_err(&this_ptr_conv, val_conv);
27182 }
27183
27184 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
27185         LDKLightningError this_ptr_conv;
27186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27187         this_ptr_conv.is_owned = false;
27188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27189         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
27190         *ret_copy = LightningError_get_action(&this_ptr_conv);
27191         uintptr_t ret_ref = (uintptr_t)ret_copy;
27192         return ret_ref;
27193 }
27194
27195 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
27196         LDKLightningError this_ptr_conv;
27197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27198         this_ptr_conv.is_owned = false;
27199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27200         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27201         CHECK_ACCESS(val_ptr);
27202         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
27203         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
27204         LightningError_set_action(&this_ptr_conv, val_conv);
27205 }
27206
27207 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
27208         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
27209         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
27210         CHECK_ACCESS(action_arg_ptr);
27211         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
27212         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
27213         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
27214         uintptr_t ret_ref = 0;
27215         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27216         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27218         ret_ref = (uintptr_t)ret_var.inner;
27219         if (ret_var.is_owned) {
27220                 ret_ref |= 1;
27221         }
27222         return ret_ref;
27223 }
27224
27225 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
27226         LDKLightningError ret_var = LightningError_clone(arg);
27227 uintptr_t ret_ref = 0;
27228 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27229 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27230 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27231 ret_ref = (uintptr_t)ret_var.inner;
27232 if (ret_var.is_owned) {
27233         ret_ref |= 1;
27234 }
27235         return ret_ref;
27236 }
27237 intptr_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
27238         LDKLightningError arg_conv;
27239         arg_conv.inner = (void*)(arg & (~1));
27240         arg_conv.is_owned = false;
27241         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27242         intptr_t ret_val = LightningError_clone_ptr(&arg_conv);
27243         return ret_val;
27244 }
27245
27246 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
27247         LDKLightningError orig_conv;
27248         orig_conv.inner = (void*)(orig & (~1));
27249         orig_conv.is_owned = false;
27250         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27251         LDKLightningError ret_var = LightningError_clone(&orig_conv);
27252         uintptr_t ret_ref = 0;
27253         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27254         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27256         ret_ref = (uintptr_t)ret_var.inner;
27257         if (ret_var.is_owned) {
27258                 ret_ref |= 1;
27259         }
27260         return ret_ref;
27261 }
27262
27263 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
27264         LDKCommitmentUpdate this_obj_conv;
27265         this_obj_conv.inner = (void*)(this_obj & (~1));
27266         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27268         CommitmentUpdate_free(this_obj_conv);
27269 }
27270
27271 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
27272         LDKCommitmentUpdate this_ptr_conv;
27273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27274         this_ptr_conv.is_owned = false;
27275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27276         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
27277         uint32_tArray ret_arr = NULL;
27278         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27279         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27280         for (size_t p = 0; p < ret_var.datalen; p++) {
27281                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
27282                 uintptr_t ret_conv_15_ref = 0;
27283                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27284                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27285                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
27286                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
27287                 if (ret_conv_15_var.is_owned) {
27288                         ret_conv_15_ref |= 1;
27289                 }
27290                 ret_arr_ptr[p] = ret_conv_15_ref;
27291         }
27292         
27293         FREE(ret_var.data);
27294         return ret_arr;
27295 }
27296
27297 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
27298         LDKCommitmentUpdate this_ptr_conv;
27299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27300         this_ptr_conv.is_owned = false;
27301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27302         LDKCVec_UpdateAddHTLCZ val_constr;
27303         val_constr.datalen = val->arr_len;
27304         if (val_constr.datalen > 0)
27305                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
27306         else
27307                 val_constr.data = NULL;
27308         uint32_t* val_vals = val->elems /* XXX val leaks */;
27309         for (size_t p = 0; p < val_constr.datalen; p++) {
27310                 uint32_t val_conv_15 = val_vals[p];
27311                 LDKUpdateAddHTLC val_conv_15_conv;
27312                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
27313                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
27314                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
27315                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
27316                 val_constr.data[p] = val_conv_15_conv;
27317         }
27318         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
27319 }
27320
27321 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
27322         LDKCommitmentUpdate this_ptr_conv;
27323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27324         this_ptr_conv.is_owned = false;
27325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27326         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
27327         uint32_tArray ret_arr = NULL;
27328         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27329         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27330         for (size_t t = 0; t < ret_var.datalen; t++) {
27331                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
27332                 uintptr_t ret_conv_19_ref = 0;
27333                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27334                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27335                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
27336                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
27337                 if (ret_conv_19_var.is_owned) {
27338                         ret_conv_19_ref |= 1;
27339                 }
27340                 ret_arr_ptr[t] = ret_conv_19_ref;
27341         }
27342         
27343         FREE(ret_var.data);
27344         return ret_arr;
27345 }
27346
27347 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
27348         LDKCommitmentUpdate this_ptr_conv;
27349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27350         this_ptr_conv.is_owned = false;
27351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27352         LDKCVec_UpdateFulfillHTLCZ val_constr;
27353         val_constr.datalen = val->arr_len;
27354         if (val_constr.datalen > 0)
27355                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
27356         else
27357                 val_constr.data = NULL;
27358         uint32_t* val_vals = val->elems /* XXX val leaks */;
27359         for (size_t t = 0; t < val_constr.datalen; t++) {
27360                 uint32_t val_conv_19 = val_vals[t];
27361                 LDKUpdateFulfillHTLC val_conv_19_conv;
27362                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
27363                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
27364                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
27365                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
27366                 val_constr.data[t] = val_conv_19_conv;
27367         }
27368         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
27369 }
27370
27371 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
27372         LDKCommitmentUpdate this_ptr_conv;
27373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27374         this_ptr_conv.is_owned = false;
27375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27376         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
27377         uint32_tArray ret_arr = NULL;
27378         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27379         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27380         for (size_t q = 0; q < ret_var.datalen; q++) {
27381                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
27382                 uintptr_t ret_conv_16_ref = 0;
27383                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27384                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27385                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
27386                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
27387                 if (ret_conv_16_var.is_owned) {
27388                         ret_conv_16_ref |= 1;
27389                 }
27390                 ret_arr_ptr[q] = ret_conv_16_ref;
27391         }
27392         
27393         FREE(ret_var.data);
27394         return ret_arr;
27395 }
27396
27397 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
27398         LDKCommitmentUpdate this_ptr_conv;
27399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27400         this_ptr_conv.is_owned = false;
27401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27402         LDKCVec_UpdateFailHTLCZ val_constr;
27403         val_constr.datalen = val->arr_len;
27404         if (val_constr.datalen > 0)
27405                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
27406         else
27407                 val_constr.data = NULL;
27408         uint32_t* val_vals = val->elems /* XXX val leaks */;
27409         for (size_t q = 0; q < val_constr.datalen; q++) {
27410                 uint32_t val_conv_16 = val_vals[q];
27411                 LDKUpdateFailHTLC val_conv_16_conv;
27412                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
27413                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
27414                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
27415                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
27416                 val_constr.data[q] = val_conv_16_conv;
27417         }
27418         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
27419 }
27420
27421 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
27422         LDKCommitmentUpdate this_ptr_conv;
27423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27424         this_ptr_conv.is_owned = false;
27425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27426         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
27427         uint32_tArray ret_arr = NULL;
27428         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
27429         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
27430         for (size_t z = 0; z < ret_var.datalen; z++) {
27431                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
27432                 uintptr_t ret_conv_25_ref = 0;
27433                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27434                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27435                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
27436                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
27437                 if (ret_conv_25_var.is_owned) {
27438                         ret_conv_25_ref |= 1;
27439                 }
27440                 ret_arr_ptr[z] = ret_conv_25_ref;
27441         }
27442         
27443         FREE(ret_var.data);
27444         return ret_arr;
27445 }
27446
27447 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) {
27448         LDKCommitmentUpdate this_ptr_conv;
27449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27450         this_ptr_conv.is_owned = false;
27451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27452         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
27453         val_constr.datalen = val->arr_len;
27454         if (val_constr.datalen > 0)
27455                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
27456         else
27457                 val_constr.data = NULL;
27458         uint32_t* val_vals = val->elems /* XXX val leaks */;
27459         for (size_t z = 0; z < val_constr.datalen; z++) {
27460                 uint32_t val_conv_25 = val_vals[z];
27461                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
27462                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
27463                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
27464                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
27465                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
27466                 val_constr.data[z] = val_conv_25_conv;
27467         }
27468         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
27469 }
27470
27471 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
27472         LDKCommitmentUpdate this_ptr_conv;
27473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27474         this_ptr_conv.is_owned = false;
27475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27476         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
27477         uintptr_t ret_ref = 0;
27478         if ((uintptr_t)ret_var.inner > 4096) {
27479                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27480                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27482                 ret_ref = (uintptr_t)ret_var.inner;
27483                 if (ret_var.is_owned) {
27484                         ret_ref |= 1;
27485                 }
27486         }
27487         return ret_ref;
27488 }
27489
27490 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
27491         LDKCommitmentUpdate this_ptr_conv;
27492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27493         this_ptr_conv.is_owned = false;
27494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27495         LDKUpdateFee val_conv;
27496         val_conv.inner = (void*)(val & (~1));
27497         val_conv.is_owned = (val & 1) || (val == 0);
27498         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27499         val_conv = UpdateFee_clone(&val_conv);
27500         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
27501 }
27502
27503 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
27504         LDKCommitmentUpdate this_ptr_conv;
27505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27506         this_ptr_conv.is_owned = false;
27507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27508         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
27509         uintptr_t ret_ref = 0;
27510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27513         ret_ref = (uintptr_t)ret_var.inner;
27514         if (ret_var.is_owned) {
27515                 ret_ref |= 1;
27516         }
27517         return ret_ref;
27518 }
27519
27520 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
27521         LDKCommitmentUpdate this_ptr_conv;
27522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27523         this_ptr_conv.is_owned = false;
27524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27525         LDKCommitmentSigned val_conv;
27526         val_conv.inner = (void*)(val & (~1));
27527         val_conv.is_owned = (val & 1) || (val == 0);
27528         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27529         val_conv = CommitmentSigned_clone(&val_conv);
27530         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
27531 }
27532
27533 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) {
27534         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
27535         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
27536         if (update_add_htlcs_arg_constr.datalen > 0)
27537                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
27538         else
27539                 update_add_htlcs_arg_constr.data = NULL;
27540         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems /* XXX update_add_htlcs_arg leaks */;
27541         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
27542                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
27543                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
27544                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
27545                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
27546                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
27547                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
27548                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
27549         }
27550         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
27551         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
27552         if (update_fulfill_htlcs_arg_constr.datalen > 0)
27553                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
27554         else
27555                 update_fulfill_htlcs_arg_constr.data = NULL;
27556         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems /* XXX update_fulfill_htlcs_arg leaks */;
27557         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
27558                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
27559                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
27560                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
27561                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
27562                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
27563                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
27564                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
27565         }
27566         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
27567         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
27568         if (update_fail_htlcs_arg_constr.datalen > 0)
27569                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
27570         else
27571                 update_fail_htlcs_arg_constr.data = NULL;
27572         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems /* XXX update_fail_htlcs_arg leaks */;
27573         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
27574                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
27575                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
27576                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
27577                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
27578                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
27579                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
27580                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
27581         }
27582         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
27583         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
27584         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
27585                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
27586         else
27587                 update_fail_malformed_htlcs_arg_constr.data = NULL;
27588         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems /* XXX update_fail_malformed_htlcs_arg leaks */;
27589         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
27590                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
27591                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
27592                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
27593                 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);
27594                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
27595                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
27596                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
27597         }
27598         LDKUpdateFee update_fee_arg_conv;
27599         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
27600         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
27601         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
27602         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
27603         LDKCommitmentSigned commitment_signed_arg_conv;
27604         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
27605         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
27606         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
27607         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
27608         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);
27609         uintptr_t ret_ref = 0;
27610         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27611         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27613         ret_ref = (uintptr_t)ret_var.inner;
27614         if (ret_var.is_owned) {
27615                 ret_ref |= 1;
27616         }
27617         return ret_ref;
27618 }
27619
27620 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
27621         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
27622 uintptr_t ret_ref = 0;
27623 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27624 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27625 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27626 ret_ref = (uintptr_t)ret_var.inner;
27627 if (ret_var.is_owned) {
27628         ret_ref |= 1;
27629 }
27630         return ret_ref;
27631 }
27632 intptr_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
27633         LDKCommitmentUpdate arg_conv;
27634         arg_conv.inner = (void*)(arg & (~1));
27635         arg_conv.is_owned = false;
27636         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27637         intptr_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
27638         return ret_val;
27639 }
27640
27641 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
27642         LDKCommitmentUpdate orig_conv;
27643         orig_conv.inner = (void*)(orig & (~1));
27644         orig_conv.is_owned = false;
27645         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27646         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
27647         uintptr_t ret_ref = 0;
27648         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27649         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27651         ret_ref = (uintptr_t)ret_var.inner;
27652         if (ret_var.is_owned) {
27653                 ret_ref |= 1;
27654         }
27655         return ret_ref;
27656 }
27657
27658 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
27659         if ((this_ptr & 1) != 0) return;
27660         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27661         CHECK_ACCESS(this_ptr_ptr);
27662         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
27663         FREE((void*)this_ptr);
27664         ChannelMessageHandler_free(this_ptr_conv);
27665 }
27666
27667 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
27668         if ((this_ptr & 1) != 0) return;
27669         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
27670         CHECK_ACCESS(this_ptr_ptr);
27671         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
27672         FREE((void*)this_ptr);
27673         RoutingMessageHandler_free(this_ptr_conv);
27674 }
27675
27676 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
27677         LDKAcceptChannel obj_conv;
27678         obj_conv.inner = (void*)(obj & (~1));
27679         obj_conv.is_owned = false;
27680         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27681         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
27682         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27683         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27684         CVec_u8Z_free(ret_var);
27685         return ret_arr;
27686 }
27687
27688 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
27689         LDKu8slice ser_ref;
27690         ser_ref.datalen = ser->arr_len;
27691         ser_ref.data = ser->elems /* XXX ser leaks */;
27692         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
27693         *ret_conv = AcceptChannel_read(ser_ref);
27694         return (uintptr_t)ret_conv;
27695 }
27696
27697 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
27698         LDKAnnouncementSignatures obj_conv;
27699         obj_conv.inner = (void*)(obj & (~1));
27700         obj_conv.is_owned = false;
27701         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27702         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
27703         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27704         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27705         CVec_u8Z_free(ret_var);
27706         return ret_arr;
27707 }
27708
27709 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
27710         LDKu8slice ser_ref;
27711         ser_ref.datalen = ser->arr_len;
27712         ser_ref.data = ser->elems /* XXX ser leaks */;
27713         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
27714         *ret_conv = AnnouncementSignatures_read(ser_ref);
27715         return (uintptr_t)ret_conv;
27716 }
27717
27718 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
27719         LDKChannelReestablish obj_conv;
27720         obj_conv.inner = (void*)(obj & (~1));
27721         obj_conv.is_owned = false;
27722         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27723         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
27724         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27725         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27726         CVec_u8Z_free(ret_var);
27727         return ret_arr;
27728 }
27729
27730 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
27731         LDKu8slice ser_ref;
27732         ser_ref.datalen = ser->arr_len;
27733         ser_ref.data = ser->elems /* XXX ser leaks */;
27734         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
27735         *ret_conv = ChannelReestablish_read(ser_ref);
27736         return (uintptr_t)ret_conv;
27737 }
27738
27739 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
27740         LDKClosingSigned obj_conv;
27741         obj_conv.inner = (void*)(obj & (~1));
27742         obj_conv.is_owned = false;
27743         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27744         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
27745         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27746         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27747         CVec_u8Z_free(ret_var);
27748         return ret_arr;
27749 }
27750
27751 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
27752         LDKu8slice ser_ref;
27753         ser_ref.datalen = ser->arr_len;
27754         ser_ref.data = ser->elems /* XXX ser leaks */;
27755         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
27756         *ret_conv = ClosingSigned_read(ser_ref);
27757         return (uintptr_t)ret_conv;
27758 }
27759
27760 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
27761         LDKClosingSignedFeeRange obj_conv;
27762         obj_conv.inner = (void*)(obj & (~1));
27763         obj_conv.is_owned = false;
27764         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27765         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
27766         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27767         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27768         CVec_u8Z_free(ret_var);
27769         return ret_arr;
27770 }
27771
27772 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
27773         LDKu8slice ser_ref;
27774         ser_ref.datalen = ser->arr_len;
27775         ser_ref.data = ser->elems /* XXX ser leaks */;
27776         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
27777         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
27778         return (uintptr_t)ret_conv;
27779 }
27780
27781 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
27782         LDKCommitmentSigned obj_conv;
27783         obj_conv.inner = (void*)(obj & (~1));
27784         obj_conv.is_owned = false;
27785         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27786         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
27787         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27788         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27789         CVec_u8Z_free(ret_var);
27790         return ret_arr;
27791 }
27792
27793 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
27794         LDKu8slice ser_ref;
27795         ser_ref.datalen = ser->arr_len;
27796         ser_ref.data = ser->elems /* XXX ser leaks */;
27797         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
27798         *ret_conv = CommitmentSigned_read(ser_ref);
27799         return (uintptr_t)ret_conv;
27800 }
27801
27802 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
27803         LDKFundingCreated obj_conv;
27804         obj_conv.inner = (void*)(obj & (~1));
27805         obj_conv.is_owned = false;
27806         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27807         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
27808         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27809         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27810         CVec_u8Z_free(ret_var);
27811         return ret_arr;
27812 }
27813
27814 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
27815         LDKu8slice ser_ref;
27816         ser_ref.datalen = ser->arr_len;
27817         ser_ref.data = ser->elems /* XXX ser leaks */;
27818         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
27819         *ret_conv = FundingCreated_read(ser_ref);
27820         return (uintptr_t)ret_conv;
27821 }
27822
27823 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
27824         LDKFundingSigned obj_conv;
27825         obj_conv.inner = (void*)(obj & (~1));
27826         obj_conv.is_owned = false;
27827         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27828         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
27829         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27830         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27831         CVec_u8Z_free(ret_var);
27832         return ret_arr;
27833 }
27834
27835 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
27836         LDKu8slice ser_ref;
27837         ser_ref.datalen = ser->arr_len;
27838         ser_ref.data = ser->elems /* XXX ser leaks */;
27839         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
27840         *ret_conv = FundingSigned_read(ser_ref);
27841         return (uintptr_t)ret_conv;
27842 }
27843
27844 int8_tArray  __attribute__((export_name("TS_FundingLocked_write"))) TS_FundingLocked_write(uint32_t obj) {
27845         LDKFundingLocked obj_conv;
27846         obj_conv.inner = (void*)(obj & (~1));
27847         obj_conv.is_owned = false;
27848         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27849         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
27850         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27851         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27852         CVec_u8Z_free(ret_var);
27853         return ret_arr;
27854 }
27855
27856 uint32_t  __attribute__((export_name("TS_FundingLocked_read"))) TS_FundingLocked_read(int8_tArray ser) {
27857         LDKu8slice ser_ref;
27858         ser_ref.datalen = ser->arr_len;
27859         ser_ref.data = ser->elems /* XXX ser leaks */;
27860         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
27861         *ret_conv = FundingLocked_read(ser_ref);
27862         return (uintptr_t)ret_conv;
27863 }
27864
27865 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
27866         LDKInit obj_conv;
27867         obj_conv.inner = (void*)(obj & (~1));
27868         obj_conv.is_owned = false;
27869         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27870         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
27871         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27872         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27873         CVec_u8Z_free(ret_var);
27874         return ret_arr;
27875 }
27876
27877 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
27878         LDKu8slice ser_ref;
27879         ser_ref.datalen = ser->arr_len;
27880         ser_ref.data = ser->elems /* XXX ser leaks */;
27881         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
27882         *ret_conv = Init_read(ser_ref);
27883         return (uintptr_t)ret_conv;
27884 }
27885
27886 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
27887         LDKOpenChannel obj_conv;
27888         obj_conv.inner = (void*)(obj & (~1));
27889         obj_conv.is_owned = false;
27890         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27891         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
27892         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27893         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27894         CVec_u8Z_free(ret_var);
27895         return ret_arr;
27896 }
27897
27898 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
27899         LDKu8slice ser_ref;
27900         ser_ref.datalen = ser->arr_len;
27901         ser_ref.data = ser->elems /* XXX ser leaks */;
27902         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
27903         *ret_conv = OpenChannel_read(ser_ref);
27904         return (uintptr_t)ret_conv;
27905 }
27906
27907 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
27908         LDKRevokeAndACK obj_conv;
27909         obj_conv.inner = (void*)(obj & (~1));
27910         obj_conv.is_owned = false;
27911         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27912         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
27913         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27914         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27915         CVec_u8Z_free(ret_var);
27916         return ret_arr;
27917 }
27918
27919 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
27920         LDKu8slice ser_ref;
27921         ser_ref.datalen = ser->arr_len;
27922         ser_ref.data = ser->elems /* XXX ser leaks */;
27923         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
27924         *ret_conv = RevokeAndACK_read(ser_ref);
27925         return (uintptr_t)ret_conv;
27926 }
27927
27928 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
27929         LDKShutdown obj_conv;
27930         obj_conv.inner = (void*)(obj & (~1));
27931         obj_conv.is_owned = false;
27932         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27933         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
27934         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27935         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27936         CVec_u8Z_free(ret_var);
27937         return ret_arr;
27938 }
27939
27940 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
27941         LDKu8slice ser_ref;
27942         ser_ref.datalen = ser->arr_len;
27943         ser_ref.data = ser->elems /* XXX ser leaks */;
27944         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
27945         *ret_conv = Shutdown_read(ser_ref);
27946         return (uintptr_t)ret_conv;
27947 }
27948
27949 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
27950         LDKUpdateFailHTLC obj_conv;
27951         obj_conv.inner = (void*)(obj & (~1));
27952         obj_conv.is_owned = false;
27953         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27954         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
27955         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27956         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27957         CVec_u8Z_free(ret_var);
27958         return ret_arr;
27959 }
27960
27961 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
27962         LDKu8slice ser_ref;
27963         ser_ref.datalen = ser->arr_len;
27964         ser_ref.data = ser->elems /* XXX ser leaks */;
27965         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
27966         *ret_conv = UpdateFailHTLC_read(ser_ref);
27967         return (uintptr_t)ret_conv;
27968 }
27969
27970 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
27971         LDKUpdateFailMalformedHTLC obj_conv;
27972         obj_conv.inner = (void*)(obj & (~1));
27973         obj_conv.is_owned = false;
27974         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27975         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
27976         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27977         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27978         CVec_u8Z_free(ret_var);
27979         return ret_arr;
27980 }
27981
27982 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
27983         LDKu8slice ser_ref;
27984         ser_ref.datalen = ser->arr_len;
27985         ser_ref.data = ser->elems /* XXX ser leaks */;
27986         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
27987         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
27988         return (uintptr_t)ret_conv;
27989 }
27990
27991 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
27992         LDKUpdateFee obj_conv;
27993         obj_conv.inner = (void*)(obj & (~1));
27994         obj_conv.is_owned = false;
27995         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27996         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
27997         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27998         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27999         CVec_u8Z_free(ret_var);
28000         return ret_arr;
28001 }
28002
28003 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
28004         LDKu8slice ser_ref;
28005         ser_ref.datalen = ser->arr_len;
28006         ser_ref.data = ser->elems /* XXX ser leaks */;
28007         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
28008         *ret_conv = UpdateFee_read(ser_ref);
28009         return (uintptr_t)ret_conv;
28010 }
28011
28012 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
28013         LDKUpdateFulfillHTLC obj_conv;
28014         obj_conv.inner = (void*)(obj & (~1));
28015         obj_conv.is_owned = false;
28016         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28017         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
28018         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28019         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28020         CVec_u8Z_free(ret_var);
28021         return ret_arr;
28022 }
28023
28024 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
28025         LDKu8slice ser_ref;
28026         ser_ref.datalen = ser->arr_len;
28027         ser_ref.data = ser->elems /* XXX ser leaks */;
28028         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
28029         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
28030         return (uintptr_t)ret_conv;
28031 }
28032
28033 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
28034         LDKUpdateAddHTLC obj_conv;
28035         obj_conv.inner = (void*)(obj & (~1));
28036         obj_conv.is_owned = false;
28037         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28038         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
28039         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28040         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28041         CVec_u8Z_free(ret_var);
28042         return ret_arr;
28043 }
28044
28045 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
28046         LDKu8slice ser_ref;
28047         ser_ref.datalen = ser->arr_len;
28048         ser_ref.data = ser->elems /* XXX ser leaks */;
28049         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
28050         *ret_conv = UpdateAddHTLC_read(ser_ref);
28051         return (uintptr_t)ret_conv;
28052 }
28053
28054 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
28055         LDKPing obj_conv;
28056         obj_conv.inner = (void*)(obj & (~1));
28057         obj_conv.is_owned = false;
28058         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28059         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
28060         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28061         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28062         CVec_u8Z_free(ret_var);
28063         return ret_arr;
28064 }
28065
28066 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
28067         LDKu8slice ser_ref;
28068         ser_ref.datalen = ser->arr_len;
28069         ser_ref.data = ser->elems /* XXX ser leaks */;
28070         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
28071         *ret_conv = Ping_read(ser_ref);
28072         return (uintptr_t)ret_conv;
28073 }
28074
28075 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
28076         LDKPong obj_conv;
28077         obj_conv.inner = (void*)(obj & (~1));
28078         obj_conv.is_owned = false;
28079         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28080         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
28081         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28082         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28083         CVec_u8Z_free(ret_var);
28084         return ret_arr;
28085 }
28086
28087 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
28088         LDKu8slice ser_ref;
28089         ser_ref.datalen = ser->arr_len;
28090         ser_ref.data = ser->elems /* XXX ser leaks */;
28091         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
28092         *ret_conv = Pong_read(ser_ref);
28093         return (uintptr_t)ret_conv;
28094 }
28095
28096 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
28097         LDKUnsignedChannelAnnouncement obj_conv;
28098         obj_conv.inner = (void*)(obj & (~1));
28099         obj_conv.is_owned = false;
28100         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28101         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
28102         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28103         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28104         CVec_u8Z_free(ret_var);
28105         return ret_arr;
28106 }
28107
28108 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
28109         LDKu8slice ser_ref;
28110         ser_ref.datalen = ser->arr_len;
28111         ser_ref.data = ser->elems /* XXX ser leaks */;
28112         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
28113         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
28114         return (uintptr_t)ret_conv;
28115 }
28116
28117 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
28118         LDKChannelAnnouncement obj_conv;
28119         obj_conv.inner = (void*)(obj & (~1));
28120         obj_conv.is_owned = false;
28121         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28122         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
28123         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28124         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28125         CVec_u8Z_free(ret_var);
28126         return ret_arr;
28127 }
28128
28129 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
28130         LDKu8slice ser_ref;
28131         ser_ref.datalen = ser->arr_len;
28132         ser_ref.data = ser->elems /* XXX ser leaks */;
28133         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
28134         *ret_conv = ChannelAnnouncement_read(ser_ref);
28135         return (uintptr_t)ret_conv;
28136 }
28137
28138 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
28139         LDKUnsignedChannelUpdate obj_conv;
28140         obj_conv.inner = (void*)(obj & (~1));
28141         obj_conv.is_owned = false;
28142         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28143         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
28144         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28145         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28146         CVec_u8Z_free(ret_var);
28147         return ret_arr;
28148 }
28149
28150 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
28151         LDKu8slice ser_ref;
28152         ser_ref.datalen = ser->arr_len;
28153         ser_ref.data = ser->elems /* XXX ser leaks */;
28154         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
28155         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
28156         return (uintptr_t)ret_conv;
28157 }
28158
28159 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
28160         LDKChannelUpdate obj_conv;
28161         obj_conv.inner = (void*)(obj & (~1));
28162         obj_conv.is_owned = false;
28163         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28164         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
28165         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28166         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28167         CVec_u8Z_free(ret_var);
28168         return ret_arr;
28169 }
28170
28171 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
28172         LDKu8slice ser_ref;
28173         ser_ref.datalen = ser->arr_len;
28174         ser_ref.data = ser->elems /* XXX ser leaks */;
28175         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
28176         *ret_conv = ChannelUpdate_read(ser_ref);
28177         return (uintptr_t)ret_conv;
28178 }
28179
28180 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
28181         LDKErrorMessage obj_conv;
28182         obj_conv.inner = (void*)(obj & (~1));
28183         obj_conv.is_owned = false;
28184         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28185         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
28186         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28187         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28188         CVec_u8Z_free(ret_var);
28189         return ret_arr;
28190 }
28191
28192 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
28193         LDKu8slice ser_ref;
28194         ser_ref.datalen = ser->arr_len;
28195         ser_ref.data = ser->elems /* XXX ser leaks */;
28196         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
28197         *ret_conv = ErrorMessage_read(ser_ref);
28198         return (uintptr_t)ret_conv;
28199 }
28200
28201 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
28202         LDKUnsignedNodeAnnouncement obj_conv;
28203         obj_conv.inner = (void*)(obj & (~1));
28204         obj_conv.is_owned = false;
28205         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28206         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
28207         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28208         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28209         CVec_u8Z_free(ret_var);
28210         return ret_arr;
28211 }
28212
28213 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
28214         LDKu8slice ser_ref;
28215         ser_ref.datalen = ser->arr_len;
28216         ser_ref.data = ser->elems /* XXX ser leaks */;
28217         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
28218         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
28219         return (uintptr_t)ret_conv;
28220 }
28221
28222 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
28223         LDKNodeAnnouncement obj_conv;
28224         obj_conv.inner = (void*)(obj & (~1));
28225         obj_conv.is_owned = false;
28226         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28227         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
28228         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28229         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28230         CVec_u8Z_free(ret_var);
28231         return ret_arr;
28232 }
28233
28234 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
28235         LDKu8slice ser_ref;
28236         ser_ref.datalen = ser->arr_len;
28237         ser_ref.data = ser->elems /* XXX ser leaks */;
28238         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
28239         *ret_conv = NodeAnnouncement_read(ser_ref);
28240         return (uintptr_t)ret_conv;
28241 }
28242
28243 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
28244         LDKu8slice ser_ref;
28245         ser_ref.datalen = ser->arr_len;
28246         ser_ref.data = ser->elems /* XXX ser leaks */;
28247         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
28248         *ret_conv = QueryShortChannelIds_read(ser_ref);
28249         return (uintptr_t)ret_conv;
28250 }
28251
28252 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
28253         LDKQueryShortChannelIds obj_conv;
28254         obj_conv.inner = (void*)(obj & (~1));
28255         obj_conv.is_owned = false;
28256         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28257         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
28258         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28259         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28260         CVec_u8Z_free(ret_var);
28261         return ret_arr;
28262 }
28263
28264 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
28265         LDKReplyShortChannelIdsEnd obj_conv;
28266         obj_conv.inner = (void*)(obj & (~1));
28267         obj_conv.is_owned = false;
28268         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28269         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
28270         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28271         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28272         CVec_u8Z_free(ret_var);
28273         return ret_arr;
28274 }
28275
28276 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
28277         LDKu8slice ser_ref;
28278         ser_ref.datalen = ser->arr_len;
28279         ser_ref.data = ser->elems /* XXX ser leaks */;
28280         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
28281         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
28282         return (uintptr_t)ret_conv;
28283 }
28284
28285 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
28286         LDKQueryChannelRange this_arg_conv;
28287         this_arg_conv.inner = (void*)(this_arg & (~1));
28288         this_arg_conv.is_owned = false;
28289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28290         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
28291         return ret_val;
28292 }
28293
28294 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
28295         LDKQueryChannelRange obj_conv;
28296         obj_conv.inner = (void*)(obj & (~1));
28297         obj_conv.is_owned = false;
28298         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28299         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
28300         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28301         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28302         CVec_u8Z_free(ret_var);
28303         return ret_arr;
28304 }
28305
28306 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
28307         LDKu8slice ser_ref;
28308         ser_ref.datalen = ser->arr_len;
28309         ser_ref.data = ser->elems /* XXX ser leaks */;
28310         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
28311         *ret_conv = QueryChannelRange_read(ser_ref);
28312         return (uintptr_t)ret_conv;
28313 }
28314
28315 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
28316         LDKu8slice ser_ref;
28317         ser_ref.datalen = ser->arr_len;
28318         ser_ref.data = ser->elems /* XXX ser leaks */;
28319         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
28320         *ret_conv = ReplyChannelRange_read(ser_ref);
28321         return (uintptr_t)ret_conv;
28322 }
28323
28324 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
28325         LDKReplyChannelRange obj_conv;
28326         obj_conv.inner = (void*)(obj & (~1));
28327         obj_conv.is_owned = false;
28328         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28329         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
28330         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28331         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28332         CVec_u8Z_free(ret_var);
28333         return ret_arr;
28334 }
28335
28336 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
28337         LDKGossipTimestampFilter obj_conv;
28338         obj_conv.inner = (void*)(obj & (~1));
28339         obj_conv.is_owned = false;
28340         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28341         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
28342         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28343         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28344         CVec_u8Z_free(ret_var);
28345         return ret_arr;
28346 }
28347
28348 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
28349         LDKu8slice ser_ref;
28350         ser_ref.datalen = ser->arr_len;
28351         ser_ref.data = ser->elems /* XXX ser leaks */;
28352         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
28353         *ret_conv = GossipTimestampFilter_read(ser_ref);
28354         return (uintptr_t)ret_conv;
28355 }
28356
28357 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
28358         if ((this_ptr & 1) != 0) return;
28359         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28360         CHECK_ACCESS(this_ptr_ptr);
28361         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
28362         FREE((void*)this_ptr);
28363         CustomMessageHandler_free(this_ptr_conv);
28364 }
28365
28366 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
28367         LDKIgnoringMessageHandler this_obj_conv;
28368         this_obj_conv.inner = (void*)(this_obj & (~1));
28369         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28371         IgnoringMessageHandler_free(this_obj_conv);
28372 }
28373
28374 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
28375         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
28376         uintptr_t ret_ref = 0;
28377         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28378         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28380         ret_ref = (uintptr_t)ret_var.inner;
28381         if (ret_var.is_owned) {
28382                 ret_ref |= 1;
28383         }
28384         return ret_ref;
28385 }
28386
28387 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
28388         LDKIgnoringMessageHandler this_arg_conv;
28389         this_arg_conv.inner = (void*)(this_arg & (~1));
28390         this_arg_conv.is_owned = false;
28391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28392         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
28393         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
28394         return (uintptr_t)ret_ret;
28395 }
28396
28397 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
28398         LDKIgnoringMessageHandler this_arg_conv;
28399         this_arg_conv.inner = (void*)(this_arg & (~1));
28400         this_arg_conv.is_owned = false;
28401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28402         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
28403         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
28404         return (uintptr_t)ret_ret;
28405 }
28406
28407 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
28408         LDKIgnoringMessageHandler this_arg_conv;
28409         this_arg_conv.inner = (void*)(this_arg & (~1));
28410         this_arg_conv.is_owned = false;
28411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28412         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
28413         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
28414         return (uintptr_t)ret_ret;
28415 }
28416
28417 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
28418         LDKIgnoringMessageHandler this_arg_conv;
28419         this_arg_conv.inner = (void*)(this_arg & (~1));
28420         this_arg_conv.is_owned = false;
28421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28422         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
28423         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
28424         return (uintptr_t)ret_ret;
28425 }
28426
28427 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
28428         LDKErroringMessageHandler this_obj_conv;
28429         this_obj_conv.inner = (void*)(this_obj & (~1));
28430         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28432         ErroringMessageHandler_free(this_obj_conv);
28433 }
28434
28435 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
28436         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
28437         uintptr_t ret_ref = 0;
28438         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28439         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28441         ret_ref = (uintptr_t)ret_var.inner;
28442         if (ret_var.is_owned) {
28443                 ret_ref |= 1;
28444         }
28445         return ret_ref;
28446 }
28447
28448 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
28449         LDKErroringMessageHandler this_arg_conv;
28450         this_arg_conv.inner = (void*)(this_arg & (~1));
28451         this_arg_conv.is_owned = false;
28452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28453         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
28454         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
28455         return (uintptr_t)ret_ret;
28456 }
28457
28458 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
28459         LDKErroringMessageHandler this_arg_conv;
28460         this_arg_conv.inner = (void*)(this_arg & (~1));
28461         this_arg_conv.is_owned = false;
28462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28463         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
28464         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
28465         return (uintptr_t)ret_ret;
28466 }
28467
28468 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
28469         LDKMessageHandler this_obj_conv;
28470         this_obj_conv.inner = (void*)(this_obj & (~1));
28471         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28473         MessageHandler_free(this_obj_conv);
28474 }
28475
28476 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
28477         LDKMessageHandler this_ptr_conv;
28478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28479         this_ptr_conv.is_owned = false;
28480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28481         // WARNING: This object doesn't live past this scope, needs clone!
28482         uintptr_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
28483         return ret_ret;
28484 }
28485
28486 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
28487         LDKMessageHandler this_ptr_conv;
28488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28489         this_ptr_conv.is_owned = false;
28490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28491         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28492         CHECK_ACCESS(val_ptr);
28493         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
28494         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
28495 }
28496
28497 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
28498         LDKMessageHandler this_ptr_conv;
28499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28500         this_ptr_conv.is_owned = false;
28501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28502         // WARNING: This object doesn't live past this scope, needs clone!
28503         uintptr_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
28504         return ret_ret;
28505 }
28506
28507 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
28508         LDKMessageHandler this_ptr_conv;
28509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28510         this_ptr_conv.is_owned = false;
28511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28512         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28513         CHECK_ACCESS(val_ptr);
28514         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
28515         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
28516 }
28517
28518 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
28519         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
28520         CHECK_ACCESS(chan_handler_arg_ptr);
28521         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
28522         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
28523         CHECK_ACCESS(route_handler_arg_ptr);
28524         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
28525         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
28526         uintptr_t ret_ref = 0;
28527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28530         ret_ref = (uintptr_t)ret_var.inner;
28531         if (ret_var.is_owned) {
28532                 ret_ref |= 1;
28533         }
28534         return ret_ref;
28535 }
28536
28537 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
28538         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
28539         *ret_ret = SocketDescriptor_clone(arg);
28540         return (uintptr_t)ret_ret;
28541 }
28542 intptr_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
28543         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
28544         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
28545         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
28546         intptr_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
28547         return ret_val;
28548 }
28549
28550 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
28551         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
28552         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
28553         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
28554         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
28555         *ret_ret = SocketDescriptor_clone(orig_conv);
28556         return (uintptr_t)ret_ret;
28557 }
28558
28559 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
28560         if ((this_ptr & 1) != 0) return;
28561         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
28562         CHECK_ACCESS(this_ptr_ptr);
28563         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
28564         FREE((void*)this_ptr);
28565         SocketDescriptor_free(this_ptr_conv);
28566 }
28567
28568 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
28569         LDKPeerHandleError this_obj_conv;
28570         this_obj_conv.inner = (void*)(this_obj & (~1));
28571         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28573         PeerHandleError_free(this_obj_conv);
28574 }
28575
28576 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
28577         LDKPeerHandleError this_ptr_conv;
28578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28579         this_ptr_conv.is_owned = false;
28580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28581         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
28582         return ret_val;
28583 }
28584
28585 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
28586         LDKPeerHandleError this_ptr_conv;
28587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28588         this_ptr_conv.is_owned = false;
28589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28590         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
28591 }
28592
28593 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
28594         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
28595         uintptr_t ret_ref = 0;
28596         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28597         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28599         ret_ref = (uintptr_t)ret_var.inner;
28600         if (ret_var.is_owned) {
28601                 ret_ref |= 1;
28602         }
28603         return ret_ref;
28604 }
28605
28606 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
28607         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
28608 uintptr_t ret_ref = 0;
28609 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28610 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28611 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28612 ret_ref = (uintptr_t)ret_var.inner;
28613 if (ret_var.is_owned) {
28614         ret_ref |= 1;
28615 }
28616         return ret_ref;
28617 }
28618 intptr_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
28619         LDKPeerHandleError arg_conv;
28620         arg_conv.inner = (void*)(arg & (~1));
28621         arg_conv.is_owned = false;
28622         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28623         intptr_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
28624         return ret_val;
28625 }
28626
28627 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
28628         LDKPeerHandleError orig_conv;
28629         orig_conv.inner = (void*)(orig & (~1));
28630         orig_conv.is_owned = false;
28631         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28632         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
28633         uintptr_t ret_ref = 0;
28634         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28635         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28637         ret_ref = (uintptr_t)ret_var.inner;
28638         if (ret_var.is_owned) {
28639                 ret_ref |= 1;
28640         }
28641         return ret_ref;
28642 }
28643
28644 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
28645         LDKPeerManager this_obj_conv;
28646         this_obj_conv.inner = (void*)(this_obj & (~1));
28647         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28649         PeerManager_free(this_obj_conv);
28650 }
28651
28652 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) {
28653         LDKMessageHandler message_handler_conv;
28654         message_handler_conv.inner = (void*)(message_handler & (~1));
28655         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
28656         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
28657         // Warning: we need a move here but no clone is available for LDKMessageHandler
28658         LDKSecretKey our_node_secret_ref;
28659         CHECK(our_node_secret->arr_len == 32);
28660         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
28661         unsigned char ephemeral_random_data_arr[32];
28662         CHECK(ephemeral_random_data->arr_len == 32);
28663         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
28664         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
28665         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
28666         CHECK_ACCESS(logger_ptr);
28667         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28668         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
28669         CHECK_ACCESS(custom_message_handler_ptr);
28670         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
28671         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
28672         uintptr_t ret_ref = 0;
28673         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28674         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28676         ret_ref = (uintptr_t)ret_var.inner;
28677         if (ret_var.is_owned) {
28678                 ret_ref |= 1;
28679         }
28680         return ret_ref;
28681 }
28682
28683 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
28684         LDKPeerManager this_arg_conv;
28685         this_arg_conv.inner = (void*)(this_arg & (~1));
28686         this_arg_conv.is_owned = false;
28687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28688         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
28689         ptrArray ret_arr = NULL;
28690         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
28691         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
28692         for (size_t m = 0; m < ret_var.datalen; m++) {
28693                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
28694                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
28695                 ret_arr_ptr[m] = ret_conv_12_arr;
28696         }
28697         
28698         FREE(ret_var.data);
28699         return ret_arr;
28700 }
28701
28702 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) {
28703         LDKPeerManager this_arg_conv;
28704         this_arg_conv.inner = (void*)(this_arg & (~1));
28705         this_arg_conv.is_owned = false;
28706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28707         LDKPublicKey their_node_id_ref;
28708         CHECK(their_node_id->arr_len == 33);
28709         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
28710         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
28711         CHECK_ACCESS(descriptor_ptr);
28712         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
28713         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
28714         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
28715         return (uintptr_t)ret_conv;
28716 }
28717
28718 uint32_t  __attribute__((export_name("TS_PeerManager_new_inbound_connection"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
28719         LDKPeerManager this_arg_conv;
28720         this_arg_conv.inner = (void*)(this_arg & (~1));
28721         this_arg_conv.is_owned = false;
28722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28723         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
28724         CHECK_ACCESS(descriptor_ptr);
28725         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
28726         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
28727         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
28728         return (uintptr_t)ret_conv;
28729 }
28730
28731 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
28732         LDKPeerManager this_arg_conv;
28733         this_arg_conv.inner = (void*)(this_arg & (~1));
28734         this_arg_conv.is_owned = false;
28735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28736         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
28737         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
28738         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
28739         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
28740         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
28741         return (uintptr_t)ret_conv;
28742 }
28743
28744 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
28745         LDKPeerManager this_arg_conv;
28746         this_arg_conv.inner = (void*)(this_arg & (~1));
28747         this_arg_conv.is_owned = false;
28748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28749         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
28750         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
28751         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
28752         LDKu8slice data_ref;
28753         data_ref.datalen = data->arr_len;
28754         data_ref.data = data->elems /* XXX data leaks */;
28755         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
28756         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
28757         return (uintptr_t)ret_conv;
28758 }
28759
28760 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
28761         LDKPeerManager this_arg_conv;
28762         this_arg_conv.inner = (void*)(this_arg & (~1));
28763         this_arg_conv.is_owned = false;
28764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28765         PeerManager_process_events(&this_arg_conv);
28766 }
28767
28768 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
28769         LDKPeerManager this_arg_conv;
28770         this_arg_conv.inner = (void*)(this_arg & (~1));
28771         this_arg_conv.is_owned = false;
28772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28773         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
28774         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
28775         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
28776         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
28777 }
28778
28779 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) {
28780         LDKPeerManager this_arg_conv;
28781         this_arg_conv.inner = (void*)(this_arg & (~1));
28782         this_arg_conv.is_owned = false;
28783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28784         LDKPublicKey node_id_ref;
28785         CHECK(node_id->arr_len == 33);
28786         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
28787         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
28788 }
28789
28790 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
28791         LDKPeerManager this_arg_conv;
28792         this_arg_conv.inner = (void*)(this_arg & (~1));
28793         this_arg_conv.is_owned = false;
28794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28795         PeerManager_disconnect_all_peers(&this_arg_conv);
28796 }
28797
28798 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
28799         LDKPeerManager this_arg_conv;
28800         this_arg_conv.inner = (void*)(this_arg & (~1));
28801         this_arg_conv.is_owned = false;
28802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28803         PeerManager_timer_tick_occurred(&this_arg_conv);
28804 }
28805
28806 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
28807         int64_t ret_val = htlc_success_tx_weight(opt_anchors);
28808         return ret_val;
28809 }
28810
28811 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
28812         int64_t ret_val = htlc_timeout_tx_weight(opt_anchors);
28813         return ret_val;
28814 }
28815
28816 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
28817         unsigned char commitment_seed_arr[32];
28818         CHECK(commitment_seed->arr_len == 32);
28819         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
28820         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
28821         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28822         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
28823         return ret_arr;
28824 }
28825
28826 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) {
28827         LDKCVec_u8Z to_holder_script_ref;
28828         to_holder_script_ref.datalen = to_holder_script->arr_len;
28829         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
28830         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
28831         LDKCVec_u8Z to_counterparty_script_ref;
28832         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
28833         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
28834         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
28835         LDKOutPoint funding_outpoint_conv;
28836         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
28837         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
28838         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
28839         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
28840         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);
28841         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28842         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28843         Transaction_free(ret_var);
28844         return ret_arr;
28845 }
28846
28847 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
28848         LDKPublicKey per_commitment_point_ref;
28849         CHECK(per_commitment_point->arr_len == 33);
28850         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
28851         unsigned char base_secret_arr[32];
28852         CHECK(base_secret->arr_len == 32);
28853         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
28854         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
28855         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
28856         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
28857         return (uintptr_t)ret_conv;
28858 }
28859
28860 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
28861         LDKPublicKey per_commitment_point_ref;
28862         CHECK(per_commitment_point->arr_len == 33);
28863         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
28864         LDKPublicKey base_point_ref;
28865         CHECK(base_point->arr_len == 33);
28866         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
28867         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
28868         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
28869         return (uintptr_t)ret_conv;
28870 }
28871
28872 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) {
28873         unsigned char per_commitment_secret_arr[32];
28874         CHECK(per_commitment_secret->arr_len == 32);
28875         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
28876         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
28877         unsigned char countersignatory_revocation_base_secret_arr[32];
28878         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
28879         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
28880         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
28881         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
28882         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
28883         return (uintptr_t)ret_conv;
28884 }
28885
28886 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) {
28887         LDKPublicKey per_commitment_point_ref;
28888         CHECK(per_commitment_point->arr_len == 33);
28889         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
28890         LDKPublicKey countersignatory_revocation_base_point_ref;
28891         CHECK(countersignatory_revocation_base_point->arr_len == 33);
28892         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
28893         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
28894         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
28895         return (uintptr_t)ret_conv;
28896 }
28897
28898 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
28899         LDKTxCreationKeys this_obj_conv;
28900         this_obj_conv.inner = (void*)(this_obj & (~1));
28901         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28903         TxCreationKeys_free(this_obj_conv);
28904 }
28905
28906 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
28907         LDKTxCreationKeys this_ptr_conv;
28908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28909         this_ptr_conv.is_owned = false;
28910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28911         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28912         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28913         return ret_arr;
28914 }
28915
28916 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
28917         LDKTxCreationKeys this_ptr_conv;
28918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28919         this_ptr_conv.is_owned = false;
28920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28921         LDKPublicKey val_ref;
28922         CHECK(val->arr_len == 33);
28923         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28924         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
28925 }
28926
28927 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
28928         LDKTxCreationKeys this_ptr_conv;
28929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28930         this_ptr_conv.is_owned = false;
28931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28932         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28933         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
28934         return ret_arr;
28935 }
28936
28937 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
28938         LDKTxCreationKeys this_ptr_conv;
28939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28940         this_ptr_conv.is_owned = false;
28941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28942         LDKPublicKey val_ref;
28943         CHECK(val->arr_len == 33);
28944         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28945         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
28946 }
28947
28948 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
28949         LDKTxCreationKeys this_ptr_conv;
28950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28951         this_ptr_conv.is_owned = false;
28952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28953         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28954         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
28955         return ret_arr;
28956 }
28957
28958 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
28959         LDKTxCreationKeys this_ptr_conv;
28960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28961         this_ptr_conv.is_owned = false;
28962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28963         LDKPublicKey val_ref;
28964         CHECK(val->arr_len == 33);
28965         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28966         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
28967 }
28968
28969 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
28970         LDKTxCreationKeys this_ptr_conv;
28971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28972         this_ptr_conv.is_owned = false;
28973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28974         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28975         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
28976         return ret_arr;
28977 }
28978
28979 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
28980         LDKTxCreationKeys this_ptr_conv;
28981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28982         this_ptr_conv.is_owned = false;
28983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28984         LDKPublicKey val_ref;
28985         CHECK(val->arr_len == 33);
28986         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28987         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
28988 }
28989
28990 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
28991         LDKTxCreationKeys this_ptr_conv;
28992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28993         this_ptr_conv.is_owned = false;
28994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28995         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28996         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
28997         return ret_arr;
28998 }
28999
29000 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) {
29001         LDKTxCreationKeys this_ptr_conv;
29002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29003         this_ptr_conv.is_owned = false;
29004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29005         LDKPublicKey val_ref;
29006         CHECK(val->arr_len == 33);
29007         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29008         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
29009 }
29010
29011 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) {
29012         LDKPublicKey per_commitment_point_arg_ref;
29013         CHECK(per_commitment_point_arg->arr_len == 33);
29014         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
29015         LDKPublicKey revocation_key_arg_ref;
29016         CHECK(revocation_key_arg->arr_len == 33);
29017         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
29018         LDKPublicKey broadcaster_htlc_key_arg_ref;
29019         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
29020         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
29021         LDKPublicKey countersignatory_htlc_key_arg_ref;
29022         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
29023         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
29024         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
29025         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
29026         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
29027         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);
29028         uintptr_t ret_ref = 0;
29029         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29030         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29031         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29032         ret_ref = (uintptr_t)ret_var.inner;
29033         if (ret_var.is_owned) {
29034                 ret_ref |= 1;
29035         }
29036         return ret_ref;
29037 }
29038
29039 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
29040         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
29041 uintptr_t ret_ref = 0;
29042 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29043 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29044 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29045 ret_ref = (uintptr_t)ret_var.inner;
29046 if (ret_var.is_owned) {
29047         ret_ref |= 1;
29048 }
29049         return ret_ref;
29050 }
29051 intptr_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
29052         LDKTxCreationKeys arg_conv;
29053         arg_conv.inner = (void*)(arg & (~1));
29054         arg_conv.is_owned = false;
29055         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29056         intptr_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
29057         return ret_val;
29058 }
29059
29060 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
29061         LDKTxCreationKeys orig_conv;
29062         orig_conv.inner = (void*)(orig & (~1));
29063         orig_conv.is_owned = false;
29064         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29065         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
29066         uintptr_t ret_ref = 0;
29067         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29068         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29070         ret_ref = (uintptr_t)ret_var.inner;
29071         if (ret_var.is_owned) {
29072                 ret_ref |= 1;
29073         }
29074         return ret_ref;
29075 }
29076
29077 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
29078         LDKTxCreationKeys obj_conv;
29079         obj_conv.inner = (void*)(obj & (~1));
29080         obj_conv.is_owned = false;
29081         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29082         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
29083         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29084         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29085         CVec_u8Z_free(ret_var);
29086         return ret_arr;
29087 }
29088
29089 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
29090         LDKu8slice ser_ref;
29091         ser_ref.datalen = ser->arr_len;
29092         ser_ref.data = ser->elems /* XXX ser leaks */;
29093         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
29094         *ret_conv = TxCreationKeys_read(ser_ref);
29095         return (uintptr_t)ret_conv;
29096 }
29097
29098 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
29099         LDKChannelPublicKeys this_obj_conv;
29100         this_obj_conv.inner = (void*)(this_obj & (~1));
29101         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29103         ChannelPublicKeys_free(this_obj_conv);
29104 }
29105
29106 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
29107         LDKChannelPublicKeys this_ptr_conv;
29108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29109         this_ptr_conv.is_owned = false;
29110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29111         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29112         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
29113         return ret_arr;
29114 }
29115
29116 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
29117         LDKChannelPublicKeys this_ptr_conv;
29118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29119         this_ptr_conv.is_owned = false;
29120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29121         LDKPublicKey val_ref;
29122         CHECK(val->arr_len == 33);
29123         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29124         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
29125 }
29126
29127 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
29128         LDKChannelPublicKeys this_ptr_conv;
29129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29130         this_ptr_conv.is_owned = false;
29131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29132         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29133         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
29134         return ret_arr;
29135 }
29136
29137 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
29138         LDKChannelPublicKeys this_ptr_conv;
29139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29140         this_ptr_conv.is_owned = false;
29141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29142         LDKPublicKey val_ref;
29143         CHECK(val->arr_len == 33);
29144         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29145         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
29146 }
29147
29148 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
29149         LDKChannelPublicKeys this_ptr_conv;
29150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29151         this_ptr_conv.is_owned = false;
29152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29153         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29154         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
29155         return ret_arr;
29156 }
29157
29158 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
29159         LDKChannelPublicKeys this_ptr_conv;
29160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29161         this_ptr_conv.is_owned = false;
29162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29163         LDKPublicKey val_ref;
29164         CHECK(val->arr_len == 33);
29165         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29166         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
29167 }
29168
29169 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
29170         LDKChannelPublicKeys this_ptr_conv;
29171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29172         this_ptr_conv.is_owned = false;
29173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29174         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29175         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
29176         return ret_arr;
29177 }
29178
29179 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
29180         LDKChannelPublicKeys this_ptr_conv;
29181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29182         this_ptr_conv.is_owned = false;
29183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29184         LDKPublicKey val_ref;
29185         CHECK(val->arr_len == 33);
29186         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29187         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
29188 }
29189
29190 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
29191         LDKChannelPublicKeys this_ptr_conv;
29192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29193         this_ptr_conv.is_owned = false;
29194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29195         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29196         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
29197         return ret_arr;
29198 }
29199
29200 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
29201         LDKChannelPublicKeys this_ptr_conv;
29202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29203         this_ptr_conv.is_owned = false;
29204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29205         LDKPublicKey val_ref;
29206         CHECK(val->arr_len == 33);
29207         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29208         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
29209 }
29210
29211 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) {
29212         LDKPublicKey funding_pubkey_arg_ref;
29213         CHECK(funding_pubkey_arg->arr_len == 33);
29214         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
29215         LDKPublicKey revocation_basepoint_arg_ref;
29216         CHECK(revocation_basepoint_arg->arr_len == 33);
29217         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
29218         LDKPublicKey payment_point_arg_ref;
29219         CHECK(payment_point_arg->arr_len == 33);
29220         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
29221         LDKPublicKey delayed_payment_basepoint_arg_ref;
29222         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
29223         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
29224         LDKPublicKey htlc_basepoint_arg_ref;
29225         CHECK(htlc_basepoint_arg->arr_len == 33);
29226         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
29227         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);
29228         uintptr_t ret_ref = 0;
29229         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29230         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29232         ret_ref = (uintptr_t)ret_var.inner;
29233         if (ret_var.is_owned) {
29234                 ret_ref |= 1;
29235         }
29236         return ret_ref;
29237 }
29238
29239 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
29240         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
29241 uintptr_t ret_ref = 0;
29242 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29243 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29244 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29245 ret_ref = (uintptr_t)ret_var.inner;
29246 if (ret_var.is_owned) {
29247         ret_ref |= 1;
29248 }
29249         return ret_ref;
29250 }
29251 intptr_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
29252         LDKChannelPublicKeys arg_conv;
29253         arg_conv.inner = (void*)(arg & (~1));
29254         arg_conv.is_owned = false;
29255         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29256         intptr_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
29257         return ret_val;
29258 }
29259
29260 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
29261         LDKChannelPublicKeys orig_conv;
29262         orig_conv.inner = (void*)(orig & (~1));
29263         orig_conv.is_owned = false;
29264         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29265         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
29266         uintptr_t ret_ref = 0;
29267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29270         ret_ref = (uintptr_t)ret_var.inner;
29271         if (ret_var.is_owned) {
29272                 ret_ref |= 1;
29273         }
29274         return ret_ref;
29275 }
29276
29277 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
29278         LDKChannelPublicKeys obj_conv;
29279         obj_conv.inner = (void*)(obj & (~1));
29280         obj_conv.is_owned = false;
29281         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29282         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
29283         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29284         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29285         CVec_u8Z_free(ret_var);
29286         return ret_arr;
29287 }
29288
29289 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
29290         LDKu8slice ser_ref;
29291         ser_ref.datalen = ser->arr_len;
29292         ser_ref.data = ser->elems /* XXX ser leaks */;
29293         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
29294         *ret_conv = ChannelPublicKeys_read(ser_ref);
29295         return (uintptr_t)ret_conv;
29296 }
29297
29298 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) {
29299         LDKPublicKey per_commitment_point_ref;
29300         CHECK(per_commitment_point->arr_len == 33);
29301         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
29302         LDKPublicKey broadcaster_delayed_payment_base_ref;
29303         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
29304         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
29305         LDKPublicKey broadcaster_htlc_base_ref;
29306         CHECK(broadcaster_htlc_base->arr_len == 33);
29307         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
29308         LDKPublicKey countersignatory_revocation_base_ref;
29309         CHECK(countersignatory_revocation_base->arr_len == 33);
29310         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
29311         LDKPublicKey countersignatory_htlc_base_ref;
29312         CHECK(countersignatory_htlc_base->arr_len == 33);
29313         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
29314         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
29315         *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);
29316         return (uintptr_t)ret_conv;
29317 }
29318
29319 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) {
29320         LDKPublicKey per_commitment_point_ref;
29321         CHECK(per_commitment_point->arr_len == 33);
29322         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
29323         LDKChannelPublicKeys broadcaster_keys_conv;
29324         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
29325         broadcaster_keys_conv.is_owned = false;
29326         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
29327         LDKChannelPublicKeys countersignatory_keys_conv;
29328         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
29329         countersignatory_keys_conv.is_owned = false;
29330         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
29331         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
29332         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
29333         return (uintptr_t)ret_conv;
29334 }
29335
29336 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) {
29337         LDKPublicKey revocation_key_ref;
29338         CHECK(revocation_key->arr_len == 33);
29339         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
29340         LDKPublicKey broadcaster_delayed_payment_key_ref;
29341         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
29342         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
29343         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
29344         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29345         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29346         CVec_u8Z_free(ret_var);
29347         return ret_arr;
29348 }
29349
29350 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
29351         LDKHTLCOutputInCommitment this_obj_conv;
29352         this_obj_conv.inner = (void*)(this_obj & (~1));
29353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29355         HTLCOutputInCommitment_free(this_obj_conv);
29356 }
29357
29358 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
29359         LDKHTLCOutputInCommitment this_ptr_conv;
29360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29361         this_ptr_conv.is_owned = false;
29362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29363         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
29364         return ret_val;
29365 }
29366
29367 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
29368         LDKHTLCOutputInCommitment this_ptr_conv;
29369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29370         this_ptr_conv.is_owned = false;
29371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29372         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
29373 }
29374
29375 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
29376         LDKHTLCOutputInCommitment this_ptr_conv;
29377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29378         this_ptr_conv.is_owned = false;
29379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29380         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
29381         return ret_val;
29382 }
29383
29384 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
29385         LDKHTLCOutputInCommitment this_ptr_conv;
29386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29387         this_ptr_conv.is_owned = false;
29388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29389         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
29390 }
29391
29392 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
29393         LDKHTLCOutputInCommitment this_ptr_conv;
29394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29395         this_ptr_conv.is_owned = false;
29396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29397         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
29398         return ret_val;
29399 }
29400
29401 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
29402         LDKHTLCOutputInCommitment this_ptr_conv;
29403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29404         this_ptr_conv.is_owned = false;
29405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29406         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
29407 }
29408
29409 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
29410         LDKHTLCOutputInCommitment this_ptr_conv;
29411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29412         this_ptr_conv.is_owned = false;
29413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29414         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29415         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
29416         return ret_arr;
29417 }
29418
29419 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
29420         LDKHTLCOutputInCommitment this_ptr_conv;
29421         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29422         this_ptr_conv.is_owned = false;
29423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29424         LDKThirtyTwoBytes val_ref;
29425         CHECK(val->arr_len == 32);
29426         memcpy(val_ref.data, val->elems, 32); FREE(val);
29427         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
29428 }
29429
29430 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
29431         LDKHTLCOutputInCommitment this_ptr_conv;
29432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29433         this_ptr_conv.is_owned = false;
29434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29435         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
29436         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
29437         uintptr_t ret_ref = (uintptr_t)ret_copy;
29438         return ret_ref;
29439 }
29440
29441 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
29442         LDKHTLCOutputInCommitment this_ptr_conv;
29443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29444         this_ptr_conv.is_owned = false;
29445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29446         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
29447         CHECK_ACCESS(val_ptr);
29448         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
29449         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
29450         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
29451 }
29452
29453 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) {
29454         LDKThirtyTwoBytes payment_hash_arg_ref;
29455         CHECK(payment_hash_arg->arr_len == 32);
29456         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
29457         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
29458         CHECK_ACCESS(transaction_output_index_arg_ptr);
29459         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
29460         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
29461         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
29462         uintptr_t ret_ref = 0;
29463         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29464         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29466         ret_ref = (uintptr_t)ret_var.inner;
29467         if (ret_var.is_owned) {
29468                 ret_ref |= 1;
29469         }
29470         return ret_ref;
29471 }
29472
29473 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
29474         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
29475 uintptr_t ret_ref = 0;
29476 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29477 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29478 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29479 ret_ref = (uintptr_t)ret_var.inner;
29480 if (ret_var.is_owned) {
29481         ret_ref |= 1;
29482 }
29483         return ret_ref;
29484 }
29485 intptr_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
29486         LDKHTLCOutputInCommitment arg_conv;
29487         arg_conv.inner = (void*)(arg & (~1));
29488         arg_conv.is_owned = false;
29489         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29490         intptr_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
29491         return ret_val;
29492 }
29493
29494 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
29495         LDKHTLCOutputInCommitment orig_conv;
29496         orig_conv.inner = (void*)(orig & (~1));
29497         orig_conv.is_owned = false;
29498         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29499         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
29500         uintptr_t ret_ref = 0;
29501         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29502         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29504         ret_ref = (uintptr_t)ret_var.inner;
29505         if (ret_var.is_owned) {
29506                 ret_ref |= 1;
29507         }
29508         return ret_ref;
29509 }
29510
29511 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
29512         LDKHTLCOutputInCommitment obj_conv;
29513         obj_conv.inner = (void*)(obj & (~1));
29514         obj_conv.is_owned = false;
29515         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29516         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
29517         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29518         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29519         CVec_u8Z_free(ret_var);
29520         return ret_arr;
29521 }
29522
29523 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
29524         LDKu8slice ser_ref;
29525         ser_ref.datalen = ser->arr_len;
29526         ser_ref.data = ser->elems /* XXX ser leaks */;
29527         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
29528         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
29529         return (uintptr_t)ret_conv;
29530 }
29531
29532 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
29533         LDKHTLCOutputInCommitment htlc_conv;
29534         htlc_conv.inner = (void*)(htlc & (~1));
29535         htlc_conv.is_owned = false;
29536         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
29537         LDKTxCreationKeys keys_conv;
29538         keys_conv.inner = (void*)(keys & (~1));
29539         keys_conv.is_owned = false;
29540         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
29541         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
29542         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29543         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29544         CVec_u8Z_free(ret_var);
29545         return ret_arr;
29546 }
29547
29548 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
29549         LDKPublicKey broadcaster_ref;
29550         CHECK(broadcaster->arr_len == 33);
29551         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
29552         LDKPublicKey countersignatory_ref;
29553         CHECK(countersignatory->arr_len == 33);
29554         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
29555         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
29556         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29557         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29558         CVec_u8Z_free(ret_var);
29559         return ret_arr;
29560 }
29561
29562 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) {
29563         unsigned char commitment_txid_arr[32];
29564         CHECK(commitment_txid->arr_len == 32);
29565         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
29566         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
29567         LDKHTLCOutputInCommitment htlc_conv;
29568         htlc_conv.inner = (void*)(htlc & (~1));
29569         htlc_conv.is_owned = false;
29570         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
29571         LDKPublicKey broadcaster_delayed_payment_key_ref;
29572         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
29573         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
29574         LDKPublicKey revocation_key_ref;
29575         CHECK(revocation_key->arr_len == 33);
29576         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
29577         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);
29578         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29579         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29580         Transaction_free(ret_var);
29581         return ret_arr;
29582 }
29583
29584 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
29585         LDKPublicKey funding_pubkey_ref;
29586         CHECK(funding_pubkey->arr_len == 33);
29587         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
29588         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
29589         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29590         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29591         CVec_u8Z_free(ret_var);
29592         return ret_arr;
29593 }
29594
29595 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
29596         LDKChannelTransactionParameters this_obj_conv;
29597         this_obj_conv.inner = (void*)(this_obj & (~1));
29598         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29600         ChannelTransactionParameters_free(this_obj_conv);
29601 }
29602
29603 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
29604         LDKChannelTransactionParameters this_ptr_conv;
29605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29606         this_ptr_conv.is_owned = false;
29607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29608         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
29609         uintptr_t ret_ref = 0;
29610         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29611         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29613         ret_ref = (uintptr_t)ret_var.inner;
29614         if (ret_var.is_owned) {
29615                 ret_ref |= 1;
29616         }
29617         return ret_ref;
29618 }
29619
29620 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
29621         LDKChannelTransactionParameters this_ptr_conv;
29622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29623         this_ptr_conv.is_owned = false;
29624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29625         LDKChannelPublicKeys val_conv;
29626         val_conv.inner = (void*)(val & (~1));
29627         val_conv.is_owned = (val & 1) || (val == 0);
29628         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29629         val_conv = ChannelPublicKeys_clone(&val_conv);
29630         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
29631 }
29632
29633 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
29634         LDKChannelTransactionParameters this_ptr_conv;
29635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29636         this_ptr_conv.is_owned = false;
29637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29638         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
29639         return ret_val;
29640 }
29641
29642 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) {
29643         LDKChannelTransactionParameters this_ptr_conv;
29644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29645         this_ptr_conv.is_owned = false;
29646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29647         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
29648 }
29649
29650 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
29651         LDKChannelTransactionParameters this_ptr_conv;
29652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29653         this_ptr_conv.is_owned = false;
29654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29655         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
29656         return ret_val;
29657 }
29658
29659 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
29660         LDKChannelTransactionParameters this_ptr_conv;
29661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29662         this_ptr_conv.is_owned = false;
29663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29664         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
29665 }
29666
29667 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
29668         LDKChannelTransactionParameters this_ptr_conv;
29669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29670         this_ptr_conv.is_owned = false;
29671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29672         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
29673         uintptr_t ret_ref = 0;
29674         if ((uintptr_t)ret_var.inner > 4096) {
29675                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29676                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29678                 ret_ref = (uintptr_t)ret_var.inner;
29679                 if (ret_var.is_owned) {
29680                         ret_ref |= 1;
29681                 }
29682         }
29683         return ret_ref;
29684 }
29685
29686 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
29687         LDKChannelTransactionParameters this_ptr_conv;
29688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29689         this_ptr_conv.is_owned = false;
29690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29691         LDKCounterpartyChannelTransactionParameters val_conv;
29692         val_conv.inner = (void*)(val & (~1));
29693         val_conv.is_owned = (val & 1) || (val == 0);
29694         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29695         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
29696         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
29697 }
29698
29699 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
29700         LDKChannelTransactionParameters this_ptr_conv;
29701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29702         this_ptr_conv.is_owned = false;
29703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29704         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
29705         uintptr_t ret_ref = 0;
29706         if ((uintptr_t)ret_var.inner > 4096) {
29707                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29708                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29710                 ret_ref = (uintptr_t)ret_var.inner;
29711                 if (ret_var.is_owned) {
29712                         ret_ref |= 1;
29713                 }
29714         }
29715         return ret_ref;
29716 }
29717
29718 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
29719         LDKChannelTransactionParameters this_ptr_conv;
29720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29721         this_ptr_conv.is_owned = false;
29722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29723         LDKOutPoint val_conv;
29724         val_conv.inner = (void*)(val & (~1));
29725         val_conv.is_owned = (val & 1) || (val == 0);
29726         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29727         val_conv = OutPoint_clone(&val_conv);
29728         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
29729 }
29730
29731 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
29732         LDKChannelTransactionParameters this_ptr_conv;
29733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29734         this_ptr_conv.is_owned = false;
29735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29736         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
29737         return ret_conv;
29738 }
29739
29740 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
29741         LDKChannelTransactionParameters this_ptr_conv;
29742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29743         this_ptr_conv.is_owned = false;
29744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29745         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
29746         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
29747 }
29748
29749 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) {
29750         LDKChannelPublicKeys holder_pubkeys_arg_conv;
29751         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
29752         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
29753         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
29754         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
29755         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
29756         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
29757         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
29758         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
29759         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
29760         LDKOutPoint funding_outpoint_arg_conv;
29761         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
29762         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
29763         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
29764         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
29765         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
29766         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);
29767         uintptr_t ret_ref = 0;
29768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29771         ret_ref = (uintptr_t)ret_var.inner;
29772         if (ret_var.is_owned) {
29773                 ret_ref |= 1;
29774         }
29775         return ret_ref;
29776 }
29777
29778 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
29779         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
29780 uintptr_t ret_ref = 0;
29781 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29782 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29783 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29784 ret_ref = (uintptr_t)ret_var.inner;
29785 if (ret_var.is_owned) {
29786         ret_ref |= 1;
29787 }
29788         return ret_ref;
29789 }
29790 intptr_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
29791         LDKChannelTransactionParameters arg_conv;
29792         arg_conv.inner = (void*)(arg & (~1));
29793         arg_conv.is_owned = false;
29794         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29795         intptr_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
29796         return ret_val;
29797 }
29798
29799 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
29800         LDKChannelTransactionParameters orig_conv;
29801         orig_conv.inner = (void*)(orig & (~1));
29802         orig_conv.is_owned = false;
29803         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29804         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
29805         uintptr_t ret_ref = 0;
29806         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29807         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29809         ret_ref = (uintptr_t)ret_var.inner;
29810         if (ret_var.is_owned) {
29811                 ret_ref |= 1;
29812         }
29813         return ret_ref;
29814 }
29815
29816 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
29817         LDKCounterpartyChannelTransactionParameters this_obj_conv;
29818         this_obj_conv.inner = (void*)(this_obj & (~1));
29819         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29821         CounterpartyChannelTransactionParameters_free(this_obj_conv);
29822 }
29823
29824 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
29825         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29827         this_ptr_conv.is_owned = false;
29828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29829         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
29830         uintptr_t ret_ref = 0;
29831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29834         ret_ref = (uintptr_t)ret_var.inner;
29835         if (ret_var.is_owned) {
29836                 ret_ref |= 1;
29837         }
29838         return ret_ref;
29839 }
29840
29841 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
29842         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29844         this_ptr_conv.is_owned = false;
29845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29846         LDKChannelPublicKeys val_conv;
29847         val_conv.inner = (void*)(val & (~1));
29848         val_conv.is_owned = (val & 1) || (val == 0);
29849         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29850         val_conv = ChannelPublicKeys_clone(&val_conv);
29851         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
29852 }
29853
29854 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
29855         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29857         this_ptr_conv.is_owned = false;
29858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29859         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
29860         return ret_val;
29861 }
29862
29863 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
29864         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
29865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29866         this_ptr_conv.is_owned = false;
29867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29868         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
29869 }
29870
29871 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
29872         LDKChannelPublicKeys pubkeys_arg_conv;
29873         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
29874         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
29875         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
29876         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
29877         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
29878         uintptr_t ret_ref = 0;
29879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29882         ret_ref = (uintptr_t)ret_var.inner;
29883         if (ret_var.is_owned) {
29884                 ret_ref |= 1;
29885         }
29886         return ret_ref;
29887 }
29888
29889 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
29890         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
29891 uintptr_t ret_ref = 0;
29892 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29893 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29894 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29895 ret_ref = (uintptr_t)ret_var.inner;
29896 if (ret_var.is_owned) {
29897         ret_ref |= 1;
29898 }
29899         return ret_ref;
29900 }
29901 intptr_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
29902         LDKCounterpartyChannelTransactionParameters arg_conv;
29903         arg_conv.inner = (void*)(arg & (~1));
29904         arg_conv.is_owned = false;
29905         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29906         intptr_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
29907         return ret_val;
29908 }
29909
29910 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
29911         LDKCounterpartyChannelTransactionParameters orig_conv;
29912         orig_conv.inner = (void*)(orig & (~1));
29913         orig_conv.is_owned = false;
29914         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29915         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
29916         uintptr_t ret_ref = 0;
29917         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29918         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29920         ret_ref = (uintptr_t)ret_var.inner;
29921         if (ret_var.is_owned) {
29922                 ret_ref |= 1;
29923         }
29924         return ret_ref;
29925 }
29926
29927 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
29928         LDKChannelTransactionParameters this_arg_conv;
29929         this_arg_conv.inner = (void*)(this_arg & (~1));
29930         this_arg_conv.is_owned = false;
29931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29932         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
29933         return ret_val;
29934 }
29935
29936 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
29937         LDKChannelTransactionParameters this_arg_conv;
29938         this_arg_conv.inner = (void*)(this_arg & (~1));
29939         this_arg_conv.is_owned = false;
29940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29941         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
29942         uintptr_t ret_ref = 0;
29943         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29944         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29946         ret_ref = (uintptr_t)ret_var.inner;
29947         if (ret_var.is_owned) {
29948                 ret_ref |= 1;
29949         }
29950         return ret_ref;
29951 }
29952
29953 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
29954         LDKChannelTransactionParameters this_arg_conv;
29955         this_arg_conv.inner = (void*)(this_arg & (~1));
29956         this_arg_conv.is_owned = false;
29957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29958         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
29959         uintptr_t ret_ref = 0;
29960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29963         ret_ref = (uintptr_t)ret_var.inner;
29964         if (ret_var.is_owned) {
29965                 ret_ref |= 1;
29966         }
29967         return ret_ref;
29968 }
29969
29970 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
29971         LDKCounterpartyChannelTransactionParameters obj_conv;
29972         obj_conv.inner = (void*)(obj & (~1));
29973         obj_conv.is_owned = false;
29974         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29975         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
29976         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29977         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29978         CVec_u8Z_free(ret_var);
29979         return ret_arr;
29980 }
29981
29982 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
29983         LDKu8slice ser_ref;
29984         ser_ref.datalen = ser->arr_len;
29985         ser_ref.data = ser->elems /* XXX ser leaks */;
29986         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
29987         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
29988         return (uintptr_t)ret_conv;
29989 }
29990
29991 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
29992         LDKChannelTransactionParameters obj_conv;
29993         obj_conv.inner = (void*)(obj & (~1));
29994         obj_conv.is_owned = false;
29995         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29996         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
29997         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29998         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29999         CVec_u8Z_free(ret_var);
30000         return ret_arr;
30001 }
30002
30003 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
30004         LDKu8slice ser_ref;
30005         ser_ref.datalen = ser->arr_len;
30006         ser_ref.data = ser->elems /* XXX ser leaks */;
30007         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
30008         *ret_conv = ChannelTransactionParameters_read(ser_ref);
30009         return (uintptr_t)ret_conv;
30010 }
30011
30012 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
30013         LDKDirectedChannelTransactionParameters this_obj_conv;
30014         this_obj_conv.inner = (void*)(this_obj & (~1));
30015         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30017         DirectedChannelTransactionParameters_free(this_obj_conv);
30018 }
30019
30020 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
30021         LDKDirectedChannelTransactionParameters this_arg_conv;
30022         this_arg_conv.inner = (void*)(this_arg & (~1));
30023         this_arg_conv.is_owned = false;
30024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30025         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
30026         uintptr_t ret_ref = 0;
30027         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30028         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30030         ret_ref = (uintptr_t)ret_var.inner;
30031         if (ret_var.is_owned) {
30032                 ret_ref |= 1;
30033         }
30034         return ret_ref;
30035 }
30036
30037 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
30038         LDKDirectedChannelTransactionParameters this_arg_conv;
30039         this_arg_conv.inner = (void*)(this_arg & (~1));
30040         this_arg_conv.is_owned = false;
30041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30042         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
30043         uintptr_t ret_ref = 0;
30044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30047         ret_ref = (uintptr_t)ret_var.inner;
30048         if (ret_var.is_owned) {
30049                 ret_ref |= 1;
30050         }
30051         return ret_ref;
30052 }
30053
30054 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
30055         LDKDirectedChannelTransactionParameters this_arg_conv;
30056         this_arg_conv.inner = (void*)(this_arg & (~1));
30057         this_arg_conv.is_owned = false;
30058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30059         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
30060         return ret_val;
30061 }
30062
30063 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
30064         LDKDirectedChannelTransactionParameters this_arg_conv;
30065         this_arg_conv.inner = (void*)(this_arg & (~1));
30066         this_arg_conv.is_owned = false;
30067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30068         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
30069         return ret_val;
30070 }
30071
30072 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
30073         LDKDirectedChannelTransactionParameters this_arg_conv;
30074         this_arg_conv.inner = (void*)(this_arg & (~1));
30075         this_arg_conv.is_owned = false;
30076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30077         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
30078         uintptr_t ret_ref = 0;
30079         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30080         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30082         ret_ref = (uintptr_t)ret_var.inner;
30083         if (ret_var.is_owned) {
30084                 ret_ref |= 1;
30085         }
30086         return ret_ref;
30087 }
30088
30089 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
30090         LDKDirectedChannelTransactionParameters this_arg_conv;
30091         this_arg_conv.inner = (void*)(this_arg & (~1));
30092         this_arg_conv.is_owned = false;
30093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30094         jboolean ret_val = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
30095         return ret_val;
30096 }
30097
30098 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
30099         LDKHolderCommitmentTransaction this_obj_conv;
30100         this_obj_conv.inner = (void*)(this_obj & (~1));
30101         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30103         HolderCommitmentTransaction_free(this_obj_conv);
30104 }
30105
30106 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
30107         LDKHolderCommitmentTransaction this_ptr_conv;
30108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30109         this_ptr_conv.is_owned = false;
30110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30111         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30112         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
30113         return ret_arr;
30114 }
30115
30116 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
30117         LDKHolderCommitmentTransaction this_ptr_conv;
30118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30119         this_ptr_conv.is_owned = false;
30120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30121         LDKSignature val_ref;
30122         CHECK(val->arr_len == 64);
30123         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30124         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
30125 }
30126
30127 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
30128         LDKHolderCommitmentTransaction this_ptr_conv;
30129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30130         this_ptr_conv.is_owned = false;
30131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30132         LDKCVec_SignatureZ val_constr;
30133         val_constr.datalen = val->arr_len;
30134         if (val_constr.datalen > 0)
30135                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30136         else
30137                 val_constr.data = NULL;
30138         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
30139         for (size_t m = 0; m < val_constr.datalen; m++) {
30140                 int8_tArray val_conv_12 = val_vals[m];
30141                 LDKSignature val_conv_12_ref;
30142                 CHECK(val_conv_12->arr_len == 64);
30143                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
30144                 val_constr.data[m] = val_conv_12_ref;
30145         }
30146         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
30147 }
30148
30149 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
30150         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
30151 uintptr_t ret_ref = 0;
30152 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30153 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30154 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30155 ret_ref = (uintptr_t)ret_var.inner;
30156 if (ret_var.is_owned) {
30157         ret_ref |= 1;
30158 }
30159         return ret_ref;
30160 }
30161 intptr_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
30162         LDKHolderCommitmentTransaction arg_conv;
30163         arg_conv.inner = (void*)(arg & (~1));
30164         arg_conv.is_owned = false;
30165         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30166         intptr_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
30167         return ret_val;
30168 }
30169
30170 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
30171         LDKHolderCommitmentTransaction orig_conv;
30172         orig_conv.inner = (void*)(orig & (~1));
30173         orig_conv.is_owned = false;
30174         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30175         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
30176         uintptr_t ret_ref = 0;
30177         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30178         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30180         ret_ref = (uintptr_t)ret_var.inner;
30181         if (ret_var.is_owned) {
30182                 ret_ref |= 1;
30183         }
30184         return ret_ref;
30185 }
30186
30187 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
30188         LDKHolderCommitmentTransaction obj_conv;
30189         obj_conv.inner = (void*)(obj & (~1));
30190         obj_conv.is_owned = false;
30191         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30192         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
30193         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30194         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30195         CVec_u8Z_free(ret_var);
30196         return ret_arr;
30197 }
30198
30199 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
30200         LDKu8slice ser_ref;
30201         ser_ref.datalen = ser->arr_len;
30202         ser_ref.data = ser->elems /* XXX ser leaks */;
30203         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
30204         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
30205         return (uintptr_t)ret_conv;
30206 }
30207
30208 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) {
30209         LDKCommitmentTransaction commitment_tx_conv;
30210         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
30211         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
30212         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
30213         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
30214         LDKSignature counterparty_sig_ref;
30215         CHECK(counterparty_sig->arr_len == 64);
30216         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
30217         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
30218         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
30219         if (counterparty_htlc_sigs_constr.datalen > 0)
30220                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
30221         else
30222                 counterparty_htlc_sigs_constr.data = NULL;
30223         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems /* XXX counterparty_htlc_sigs leaks */;
30224         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
30225                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
30226                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
30227                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
30228                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
30229                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
30230         }
30231         LDKPublicKey holder_funding_key_ref;
30232         CHECK(holder_funding_key->arr_len == 33);
30233         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
30234         LDKPublicKey counterparty_funding_key_ref;
30235         CHECK(counterparty_funding_key->arr_len == 33);
30236         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
30237         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
30238         uintptr_t ret_ref = 0;
30239         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30240         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30242         ret_ref = (uintptr_t)ret_var.inner;
30243         if (ret_var.is_owned) {
30244                 ret_ref |= 1;
30245         }
30246         return ret_ref;
30247 }
30248
30249 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
30250         LDKBuiltCommitmentTransaction this_obj_conv;
30251         this_obj_conv.inner = (void*)(this_obj & (~1));
30252         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30254         BuiltCommitmentTransaction_free(this_obj_conv);
30255 }
30256
30257 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
30258         LDKBuiltCommitmentTransaction this_ptr_conv;
30259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30260         this_ptr_conv.is_owned = false;
30261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30262         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
30263         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30264         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30265         Transaction_free(ret_var);
30266         return ret_arr;
30267 }
30268
30269 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
30270         LDKBuiltCommitmentTransaction this_ptr_conv;
30271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30272         this_ptr_conv.is_owned = false;
30273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30274         LDKTransaction val_ref;
30275         val_ref.datalen = val->arr_len;
30276         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
30277         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
30278         val_ref.data_is_owned = true;
30279         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
30280 }
30281
30282 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
30283         LDKBuiltCommitmentTransaction this_ptr_conv;
30284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30285         this_ptr_conv.is_owned = false;
30286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30287         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30288         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
30289         return ret_arr;
30290 }
30291
30292 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
30293         LDKBuiltCommitmentTransaction this_ptr_conv;
30294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30295         this_ptr_conv.is_owned = false;
30296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30297         LDKThirtyTwoBytes val_ref;
30298         CHECK(val->arr_len == 32);
30299         memcpy(val_ref.data, val->elems, 32); FREE(val);
30300         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
30301 }
30302
30303 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
30304         LDKTransaction transaction_arg_ref;
30305         transaction_arg_ref.datalen = transaction_arg->arr_len;
30306         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
30307         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
30308         transaction_arg_ref.data_is_owned = true;
30309         LDKThirtyTwoBytes txid_arg_ref;
30310         CHECK(txid_arg->arr_len == 32);
30311         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
30312         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
30313         uintptr_t ret_ref = 0;
30314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30317         ret_ref = (uintptr_t)ret_var.inner;
30318         if (ret_var.is_owned) {
30319                 ret_ref |= 1;
30320         }
30321         return ret_ref;
30322 }
30323
30324 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
30325         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
30326 uintptr_t ret_ref = 0;
30327 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30328 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30329 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30330 ret_ref = (uintptr_t)ret_var.inner;
30331 if (ret_var.is_owned) {
30332         ret_ref |= 1;
30333 }
30334         return ret_ref;
30335 }
30336 intptr_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
30337         LDKBuiltCommitmentTransaction arg_conv;
30338         arg_conv.inner = (void*)(arg & (~1));
30339         arg_conv.is_owned = false;
30340         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30341         intptr_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
30342         return ret_val;
30343 }
30344
30345 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
30346         LDKBuiltCommitmentTransaction orig_conv;
30347         orig_conv.inner = (void*)(orig & (~1));
30348         orig_conv.is_owned = false;
30349         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30350         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
30351         uintptr_t ret_ref = 0;
30352         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30353         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30355         ret_ref = (uintptr_t)ret_var.inner;
30356         if (ret_var.is_owned) {
30357                 ret_ref |= 1;
30358         }
30359         return ret_ref;
30360 }
30361
30362 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
30363         LDKBuiltCommitmentTransaction obj_conv;
30364         obj_conv.inner = (void*)(obj & (~1));
30365         obj_conv.is_owned = false;
30366         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30367         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
30368         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30369         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30370         CVec_u8Z_free(ret_var);
30371         return ret_arr;
30372 }
30373
30374 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
30375         LDKu8slice ser_ref;
30376         ser_ref.datalen = ser->arr_len;
30377         ser_ref.data = ser->elems /* XXX ser leaks */;
30378         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
30379         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
30380         return (uintptr_t)ret_conv;
30381 }
30382
30383 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) {
30384         LDKBuiltCommitmentTransaction this_arg_conv;
30385         this_arg_conv.inner = (void*)(this_arg & (~1));
30386         this_arg_conv.is_owned = false;
30387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30388         LDKu8slice funding_redeemscript_ref;
30389         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
30390         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
30391         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30392         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
30393         return ret_arr;
30394 }
30395
30396 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) {
30397         LDKBuiltCommitmentTransaction this_arg_conv;
30398         this_arg_conv.inner = (void*)(this_arg & (~1));
30399         this_arg_conv.is_owned = false;
30400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30401         unsigned char funding_key_arr[32];
30402         CHECK(funding_key->arr_len == 32);
30403         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
30404         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
30405         LDKu8slice funding_redeemscript_ref;
30406         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
30407         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
30408         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30409         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
30410         return ret_arr;
30411 }
30412
30413 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
30414         LDKClosingTransaction this_obj_conv;
30415         this_obj_conv.inner = (void*)(this_obj & (~1));
30416         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30418         ClosingTransaction_free(this_obj_conv);
30419 }
30420
30421 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
30422         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
30423 uintptr_t ret_ref = 0;
30424 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30425 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30426 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30427 ret_ref = (uintptr_t)ret_var.inner;
30428 if (ret_var.is_owned) {
30429         ret_ref |= 1;
30430 }
30431         return ret_ref;
30432 }
30433 intptr_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
30434         LDKClosingTransaction arg_conv;
30435         arg_conv.inner = (void*)(arg & (~1));
30436         arg_conv.is_owned = false;
30437         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30438         intptr_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
30439         return ret_val;
30440 }
30441
30442 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
30443         LDKClosingTransaction orig_conv;
30444         orig_conv.inner = (void*)(orig & (~1));
30445         orig_conv.is_owned = false;
30446         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30447         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
30448         uintptr_t ret_ref = 0;
30449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30452         ret_ref = (uintptr_t)ret_var.inner;
30453         if (ret_var.is_owned) {
30454                 ret_ref |= 1;
30455         }
30456         return ret_ref;
30457 }
30458
30459 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
30460         LDKClosingTransaction o_conv;
30461         o_conv.inner = (void*)(o & (~1));
30462         o_conv.is_owned = false;
30463         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
30464         int64_t ret_val = ClosingTransaction_hash(&o_conv);
30465         return ret_val;
30466 }
30467
30468 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) {
30469         LDKCVec_u8Z to_holder_script_ref;
30470         to_holder_script_ref.datalen = to_holder_script->arr_len;
30471         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
30472         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
30473         LDKCVec_u8Z to_counterparty_script_ref;
30474         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
30475         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
30476         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
30477         LDKOutPoint funding_outpoint_conv;
30478         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
30479         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
30480         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
30481         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
30482         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
30483         uintptr_t ret_ref = 0;
30484         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30485         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30487         ret_ref = (uintptr_t)ret_var.inner;
30488         if (ret_var.is_owned) {
30489                 ret_ref |= 1;
30490         }
30491         return ret_ref;
30492 }
30493
30494 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
30495         LDKClosingTransaction this_arg_conv;
30496         this_arg_conv.inner = (void*)(this_arg & (~1));
30497         this_arg_conv.is_owned = false;
30498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30499         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
30500         uintptr_t ret_ref = 0;
30501         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30502         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30504         ret_ref = (uintptr_t)ret_var.inner;
30505         if (ret_var.is_owned) {
30506                 ret_ref |= 1;
30507         }
30508         return ret_ref;
30509 }
30510
30511 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
30512         LDKClosingTransaction this_arg_conv;
30513         this_arg_conv.inner = (void*)(this_arg & (~1));
30514         this_arg_conv.is_owned = false;
30515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30516         LDKOutPoint funding_outpoint_conv;
30517         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
30518         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
30519         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
30520         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
30521         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
30522         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
30523         return (uintptr_t)ret_conv;
30524 }
30525
30526 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
30527         LDKClosingTransaction this_arg_conv;
30528         this_arg_conv.inner = (void*)(this_arg & (~1));
30529         this_arg_conv.is_owned = false;
30530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30531         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
30532         return ret_val;
30533 }
30534
30535 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
30536         LDKClosingTransaction this_arg_conv;
30537         this_arg_conv.inner = (void*)(this_arg & (~1));
30538         this_arg_conv.is_owned = false;
30539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30540         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
30541         return ret_val;
30542 }
30543
30544 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
30545         LDKClosingTransaction this_arg_conv;
30546         this_arg_conv.inner = (void*)(this_arg & (~1));
30547         this_arg_conv.is_owned = false;
30548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30549         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
30550         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30551         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30552         return ret_arr;
30553 }
30554
30555 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
30556         LDKClosingTransaction this_arg_conv;
30557         this_arg_conv.inner = (void*)(this_arg & (~1));
30558         this_arg_conv.is_owned = false;
30559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30560         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
30561         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30562         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30563         return ret_arr;
30564 }
30565
30566 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
30567         LDKTrustedClosingTransaction this_obj_conv;
30568         this_obj_conv.inner = (void*)(this_obj & (~1));
30569         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30571         TrustedClosingTransaction_free(this_obj_conv);
30572 }
30573
30574 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
30575         LDKTrustedClosingTransaction this_arg_conv;
30576         this_arg_conv.inner = (void*)(this_arg & (~1));
30577         this_arg_conv.is_owned = false;
30578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30579         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
30580         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30581         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30582         Transaction_free(ret_var);
30583         return ret_arr;
30584 }
30585
30586 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) {
30587         LDKTrustedClosingTransaction this_arg_conv;
30588         this_arg_conv.inner = (void*)(this_arg & (~1));
30589         this_arg_conv.is_owned = false;
30590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30591         LDKu8slice funding_redeemscript_ref;
30592         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
30593         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
30594         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30595         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
30596         return ret_arr;
30597 }
30598
30599 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) {
30600         LDKTrustedClosingTransaction this_arg_conv;
30601         this_arg_conv.inner = (void*)(this_arg & (~1));
30602         this_arg_conv.is_owned = false;
30603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30604         unsigned char funding_key_arr[32];
30605         CHECK(funding_key->arr_len == 32);
30606         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
30607         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
30608         LDKu8slice funding_redeemscript_ref;
30609         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
30610         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
30611         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30612         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
30613         return ret_arr;
30614 }
30615
30616 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
30617         LDKCommitmentTransaction this_obj_conv;
30618         this_obj_conv.inner = (void*)(this_obj & (~1));
30619         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30621         CommitmentTransaction_free(this_obj_conv);
30622 }
30623
30624 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
30625         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
30626 uintptr_t ret_ref = 0;
30627 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30628 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30629 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30630 ret_ref = (uintptr_t)ret_var.inner;
30631 if (ret_var.is_owned) {
30632         ret_ref |= 1;
30633 }
30634         return ret_ref;
30635 }
30636 intptr_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
30637         LDKCommitmentTransaction arg_conv;
30638         arg_conv.inner = (void*)(arg & (~1));
30639         arg_conv.is_owned = false;
30640         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30641         intptr_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
30642         return ret_val;
30643 }
30644
30645 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
30646         LDKCommitmentTransaction orig_conv;
30647         orig_conv.inner = (void*)(orig & (~1));
30648         orig_conv.is_owned = false;
30649         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30650         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
30651         uintptr_t ret_ref = 0;
30652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30655         ret_ref = (uintptr_t)ret_var.inner;
30656         if (ret_var.is_owned) {
30657                 ret_ref |= 1;
30658         }
30659         return ret_ref;
30660 }
30661
30662 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
30663         LDKCommitmentTransaction obj_conv;
30664         obj_conv.inner = (void*)(obj & (~1));
30665         obj_conv.is_owned = false;
30666         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30667         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
30668         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30669         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30670         CVec_u8Z_free(ret_var);
30671         return ret_arr;
30672 }
30673
30674 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
30675         LDKu8slice ser_ref;
30676         ser_ref.datalen = ser->arr_len;
30677         ser_ref.data = ser->elems /* XXX ser leaks */;
30678         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
30679         *ret_conv = CommitmentTransaction_read(ser_ref);
30680         return (uintptr_t)ret_conv;
30681 }
30682
30683 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
30684         LDKCommitmentTransaction this_arg_conv;
30685         this_arg_conv.inner = (void*)(this_arg & (~1));
30686         this_arg_conv.is_owned = false;
30687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30688         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
30689         return ret_val;
30690 }
30691
30692 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
30693         LDKCommitmentTransaction this_arg_conv;
30694         this_arg_conv.inner = (void*)(this_arg & (~1));
30695         this_arg_conv.is_owned = false;
30696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30697         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
30698         return ret_val;
30699 }
30700
30701 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
30702         LDKCommitmentTransaction this_arg_conv;
30703         this_arg_conv.inner = (void*)(this_arg & (~1));
30704         this_arg_conv.is_owned = false;
30705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30706         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
30707         return ret_val;
30708 }
30709
30710 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
30711         LDKCommitmentTransaction this_arg_conv;
30712         this_arg_conv.inner = (void*)(this_arg & (~1));
30713         this_arg_conv.is_owned = false;
30714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30715         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
30716         return ret_val;
30717 }
30718
30719 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
30720         LDKCommitmentTransaction this_arg_conv;
30721         this_arg_conv.inner = (void*)(this_arg & (~1));
30722         this_arg_conv.is_owned = false;
30723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30724         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
30725         uintptr_t ret_ref = 0;
30726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30729         ret_ref = (uintptr_t)ret_var.inner;
30730         if (ret_var.is_owned) {
30731                 ret_ref |= 1;
30732         }
30733         return ret_ref;
30734 }
30735
30736 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) {
30737         LDKCommitmentTransaction this_arg_conv;
30738         this_arg_conv.inner = (void*)(this_arg & (~1));
30739         this_arg_conv.is_owned = false;
30740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30741         LDKDirectedChannelTransactionParameters channel_parameters_conv;
30742         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
30743         channel_parameters_conv.is_owned = false;
30744         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
30745         LDKChannelPublicKeys broadcaster_keys_conv;
30746         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
30747         broadcaster_keys_conv.is_owned = false;
30748         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
30749         LDKChannelPublicKeys countersignatory_keys_conv;
30750         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
30751         countersignatory_keys_conv.is_owned = false;
30752         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
30753         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
30754         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
30755         return (uintptr_t)ret_conv;
30756 }
30757
30758 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
30759         LDKTrustedCommitmentTransaction this_obj_conv;
30760         this_obj_conv.inner = (void*)(this_obj & (~1));
30761         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30763         TrustedCommitmentTransaction_free(this_obj_conv);
30764 }
30765
30766 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
30767         LDKTrustedCommitmentTransaction this_arg_conv;
30768         this_arg_conv.inner = (void*)(this_arg & (~1));
30769         this_arg_conv.is_owned = false;
30770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30771         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30772         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
30773         return ret_arr;
30774 }
30775
30776 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
30777         LDKTrustedCommitmentTransaction this_arg_conv;
30778         this_arg_conv.inner = (void*)(this_arg & (~1));
30779         this_arg_conv.is_owned = false;
30780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30781         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
30782         uintptr_t ret_ref = 0;
30783         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30784         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30786         ret_ref = (uintptr_t)ret_var.inner;
30787         if (ret_var.is_owned) {
30788                 ret_ref |= 1;
30789         }
30790         return ret_ref;
30791 }
30792
30793 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
30794         LDKTrustedCommitmentTransaction this_arg_conv;
30795         this_arg_conv.inner = (void*)(this_arg & (~1));
30796         this_arg_conv.is_owned = false;
30797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30798         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
30799         uintptr_t ret_ref = 0;
30800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30803         ret_ref = (uintptr_t)ret_var.inner;
30804         if (ret_var.is_owned) {
30805                 ret_ref |= 1;
30806         }
30807         return ret_ref;
30808 }
30809
30810 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
30811         LDKTrustedCommitmentTransaction this_arg_conv;
30812         this_arg_conv.inner = (void*)(this_arg & (~1));
30813         this_arg_conv.is_owned = false;
30814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30815         jboolean ret_val = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
30816         return ret_val;
30817 }
30818
30819 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) {
30820         LDKTrustedCommitmentTransaction this_arg_conv;
30821         this_arg_conv.inner = (void*)(this_arg & (~1));
30822         this_arg_conv.is_owned = false;
30823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30824         unsigned char htlc_base_key_arr[32];
30825         CHECK(htlc_base_key->arr_len == 32);
30826         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
30827         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
30828         LDKDirectedChannelTransactionParameters channel_parameters_conv;
30829         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
30830         channel_parameters_conv.is_owned = false;
30831         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
30832         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
30833         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
30834         return (uintptr_t)ret_conv;
30835 }
30836
30837 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) {
30838         LDKPublicKey broadcaster_payment_basepoint_ref;
30839         CHECK(broadcaster_payment_basepoint->arr_len == 33);
30840         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
30841         LDKPublicKey countersignatory_payment_basepoint_ref;
30842         CHECK(countersignatory_payment_basepoint->arr_len == 33);
30843         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
30844         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
30845         return ret_val;
30846 }
30847
30848 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
30849         LDKInitFeatures a_conv;
30850         a_conv.inner = (void*)(a & (~1));
30851         a_conv.is_owned = false;
30852         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30853         LDKInitFeatures b_conv;
30854         b_conv.inner = (void*)(b & (~1));
30855         b_conv.is_owned = false;
30856         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30857         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
30858         return ret_val;
30859 }
30860
30861 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
30862         LDKNodeFeatures a_conv;
30863         a_conv.inner = (void*)(a & (~1));
30864         a_conv.is_owned = false;
30865         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30866         LDKNodeFeatures b_conv;
30867         b_conv.inner = (void*)(b & (~1));
30868         b_conv.is_owned = false;
30869         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30870         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
30871         return ret_val;
30872 }
30873
30874 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
30875         LDKChannelFeatures a_conv;
30876         a_conv.inner = (void*)(a & (~1));
30877         a_conv.is_owned = false;
30878         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30879         LDKChannelFeatures b_conv;
30880         b_conv.inner = (void*)(b & (~1));
30881         b_conv.is_owned = false;
30882         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30883         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
30884         return ret_val;
30885 }
30886
30887 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
30888         LDKInvoiceFeatures a_conv;
30889         a_conv.inner = (void*)(a & (~1));
30890         a_conv.is_owned = false;
30891         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30892         LDKInvoiceFeatures b_conv;
30893         b_conv.inner = (void*)(b & (~1));
30894         b_conv.is_owned = false;
30895         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30896         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
30897         return ret_val;
30898 }
30899
30900 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
30901         LDKChannelTypeFeatures a_conv;
30902         a_conv.inner = (void*)(a & (~1));
30903         a_conv.is_owned = false;
30904         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30905         LDKChannelTypeFeatures b_conv;
30906         b_conv.inner = (void*)(b & (~1));
30907         b_conv.is_owned = false;
30908         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30909         jboolean ret_val = ChannelTypeFeatures_eq(&a_conv, &b_conv);
30910         return ret_val;
30911 }
30912
30913 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
30914         LDKInitFeatures ret_var = InitFeatures_clone(arg);
30915 uintptr_t ret_ref = 0;
30916 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30917 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30918 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30919 ret_ref = (uintptr_t)ret_var.inner;
30920 if (ret_var.is_owned) {
30921         ret_ref |= 1;
30922 }
30923         return ret_ref;
30924 }
30925 intptr_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
30926         LDKInitFeatures arg_conv;
30927         arg_conv.inner = (void*)(arg & (~1));
30928         arg_conv.is_owned = false;
30929         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30930         intptr_t ret_val = InitFeatures_clone_ptr(&arg_conv);
30931         return ret_val;
30932 }
30933
30934 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
30935         LDKInitFeatures orig_conv;
30936         orig_conv.inner = (void*)(orig & (~1));
30937         orig_conv.is_owned = false;
30938         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30939         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
30940         uintptr_t ret_ref = 0;
30941         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30942         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30943         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30944         ret_ref = (uintptr_t)ret_var.inner;
30945         if (ret_var.is_owned) {
30946                 ret_ref |= 1;
30947         }
30948         return ret_ref;
30949 }
30950
30951 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
30952         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
30953 uintptr_t ret_ref = 0;
30954 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30955 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30956 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30957 ret_ref = (uintptr_t)ret_var.inner;
30958 if (ret_var.is_owned) {
30959         ret_ref |= 1;
30960 }
30961         return ret_ref;
30962 }
30963 intptr_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
30964         LDKNodeFeatures arg_conv;
30965         arg_conv.inner = (void*)(arg & (~1));
30966         arg_conv.is_owned = false;
30967         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30968         intptr_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
30969         return ret_val;
30970 }
30971
30972 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
30973         LDKNodeFeatures orig_conv;
30974         orig_conv.inner = (void*)(orig & (~1));
30975         orig_conv.is_owned = false;
30976         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30977         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
30978         uintptr_t ret_ref = 0;
30979         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30980         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30982         ret_ref = (uintptr_t)ret_var.inner;
30983         if (ret_var.is_owned) {
30984                 ret_ref |= 1;
30985         }
30986         return ret_ref;
30987 }
30988
30989 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
30990         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
30991 uintptr_t ret_ref = 0;
30992 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30993 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30994 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30995 ret_ref = (uintptr_t)ret_var.inner;
30996 if (ret_var.is_owned) {
30997         ret_ref |= 1;
30998 }
30999         return ret_ref;
31000 }
31001 intptr_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
31002         LDKChannelFeatures arg_conv;
31003         arg_conv.inner = (void*)(arg & (~1));
31004         arg_conv.is_owned = false;
31005         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31006         intptr_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
31007         return ret_val;
31008 }
31009
31010 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
31011         LDKChannelFeatures orig_conv;
31012         orig_conv.inner = (void*)(orig & (~1));
31013         orig_conv.is_owned = false;
31014         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31015         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
31016         uintptr_t ret_ref = 0;
31017         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31018         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31020         ret_ref = (uintptr_t)ret_var.inner;
31021         if (ret_var.is_owned) {
31022                 ret_ref |= 1;
31023         }
31024         return ret_ref;
31025 }
31026
31027 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
31028         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
31029 uintptr_t ret_ref = 0;
31030 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31031 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31032 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31033 ret_ref = (uintptr_t)ret_var.inner;
31034 if (ret_var.is_owned) {
31035         ret_ref |= 1;
31036 }
31037         return ret_ref;
31038 }
31039 intptr_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
31040         LDKInvoiceFeatures arg_conv;
31041         arg_conv.inner = (void*)(arg & (~1));
31042         arg_conv.is_owned = false;
31043         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31044         intptr_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
31045         return ret_val;
31046 }
31047
31048 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
31049         LDKInvoiceFeatures orig_conv;
31050         orig_conv.inner = (void*)(orig & (~1));
31051         orig_conv.is_owned = false;
31052         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31053         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
31054         uintptr_t ret_ref = 0;
31055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31058         ret_ref = (uintptr_t)ret_var.inner;
31059         if (ret_var.is_owned) {
31060                 ret_ref |= 1;
31061         }
31062         return ret_ref;
31063 }
31064
31065 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
31066         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
31067 uintptr_t ret_ref = 0;
31068 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31069 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31070 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31071 ret_ref = (uintptr_t)ret_var.inner;
31072 if (ret_var.is_owned) {
31073         ret_ref |= 1;
31074 }
31075         return ret_ref;
31076 }
31077 intptr_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
31078         LDKChannelTypeFeatures arg_conv;
31079         arg_conv.inner = (void*)(arg & (~1));
31080         arg_conv.is_owned = false;
31081         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31082         intptr_t ret_val = ChannelTypeFeatures_clone_ptr(&arg_conv);
31083         return ret_val;
31084 }
31085
31086 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
31087         LDKChannelTypeFeatures orig_conv;
31088         orig_conv.inner = (void*)(orig & (~1));
31089         orig_conv.is_owned = false;
31090         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31091         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
31092         uintptr_t ret_ref = 0;
31093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31096         ret_ref = (uintptr_t)ret_var.inner;
31097         if (ret_var.is_owned) {
31098                 ret_ref |= 1;
31099         }
31100         return ret_ref;
31101 }
31102
31103 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
31104         LDKInitFeatures this_obj_conv;
31105         this_obj_conv.inner = (void*)(this_obj & (~1));
31106         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31108         InitFeatures_free(this_obj_conv);
31109 }
31110
31111 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
31112         LDKNodeFeatures this_obj_conv;
31113         this_obj_conv.inner = (void*)(this_obj & (~1));
31114         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31116         NodeFeatures_free(this_obj_conv);
31117 }
31118
31119 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
31120         LDKChannelFeatures this_obj_conv;
31121         this_obj_conv.inner = (void*)(this_obj & (~1));
31122         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31124         ChannelFeatures_free(this_obj_conv);
31125 }
31126
31127 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
31128         LDKInvoiceFeatures this_obj_conv;
31129         this_obj_conv.inner = (void*)(this_obj & (~1));
31130         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31132         InvoiceFeatures_free(this_obj_conv);
31133 }
31134
31135 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
31136         LDKChannelTypeFeatures this_obj_conv;
31137         this_obj_conv.inner = (void*)(this_obj & (~1));
31138         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31140         ChannelTypeFeatures_free(this_obj_conv);
31141 }
31142
31143 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
31144         LDKInitFeatures ret_var = InitFeatures_empty();
31145         uintptr_t ret_ref = 0;
31146         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31147         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31149         ret_ref = (uintptr_t)ret_var.inner;
31150         if (ret_var.is_owned) {
31151                 ret_ref |= 1;
31152         }
31153         return ret_ref;
31154 }
31155
31156 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
31157         LDKInitFeatures ret_var = InitFeatures_known();
31158         uintptr_t ret_ref = 0;
31159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31162         ret_ref = (uintptr_t)ret_var.inner;
31163         if (ret_var.is_owned) {
31164                 ret_ref |= 1;
31165         }
31166         return ret_ref;
31167 }
31168
31169 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
31170         LDKInitFeatures this_arg_conv;
31171         this_arg_conv.inner = (void*)(this_arg & (~1));
31172         this_arg_conv.is_owned = false;
31173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31174         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
31175         return ret_val;
31176 }
31177
31178 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
31179         LDKNodeFeatures ret_var = NodeFeatures_empty();
31180         uintptr_t ret_ref = 0;
31181         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31182         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31184         ret_ref = (uintptr_t)ret_var.inner;
31185         if (ret_var.is_owned) {
31186                 ret_ref |= 1;
31187         }
31188         return ret_ref;
31189 }
31190
31191 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
31192         LDKNodeFeatures ret_var = NodeFeatures_known();
31193         uintptr_t ret_ref = 0;
31194         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31195         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31197         ret_ref = (uintptr_t)ret_var.inner;
31198         if (ret_var.is_owned) {
31199                 ret_ref |= 1;
31200         }
31201         return ret_ref;
31202 }
31203
31204 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
31205         LDKNodeFeatures this_arg_conv;
31206         this_arg_conv.inner = (void*)(this_arg & (~1));
31207         this_arg_conv.is_owned = false;
31208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31209         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
31210         return ret_val;
31211 }
31212
31213 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
31214         LDKChannelFeatures ret_var = ChannelFeatures_empty();
31215         uintptr_t ret_ref = 0;
31216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31219         ret_ref = (uintptr_t)ret_var.inner;
31220         if (ret_var.is_owned) {
31221                 ret_ref |= 1;
31222         }
31223         return ret_ref;
31224 }
31225
31226 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
31227         LDKChannelFeatures ret_var = ChannelFeatures_known();
31228         uintptr_t ret_ref = 0;
31229         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31230         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31232         ret_ref = (uintptr_t)ret_var.inner;
31233         if (ret_var.is_owned) {
31234                 ret_ref |= 1;
31235         }
31236         return ret_ref;
31237 }
31238
31239 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
31240         LDKChannelFeatures this_arg_conv;
31241         this_arg_conv.inner = (void*)(this_arg & (~1));
31242         this_arg_conv.is_owned = false;
31243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31244         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
31245         return ret_val;
31246 }
31247
31248 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
31249         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
31250         uintptr_t ret_ref = 0;
31251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31254         ret_ref = (uintptr_t)ret_var.inner;
31255         if (ret_var.is_owned) {
31256                 ret_ref |= 1;
31257         }
31258         return ret_ref;
31259 }
31260
31261 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
31262         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
31263         uintptr_t ret_ref = 0;
31264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31267         ret_ref = (uintptr_t)ret_var.inner;
31268         if (ret_var.is_owned) {
31269                 ret_ref |= 1;
31270         }
31271         return ret_ref;
31272 }
31273
31274 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
31275         LDKInvoiceFeatures this_arg_conv;
31276         this_arg_conv.inner = (void*)(this_arg & (~1));
31277         this_arg_conv.is_owned = false;
31278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31279         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
31280         return ret_val;
31281 }
31282
31283 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
31284         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
31285         uintptr_t ret_ref = 0;
31286         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31287         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31289         ret_ref = (uintptr_t)ret_var.inner;
31290         if (ret_var.is_owned) {
31291                 ret_ref |= 1;
31292         }
31293         return ret_ref;
31294 }
31295
31296 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
31297         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
31298         uintptr_t ret_ref = 0;
31299         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31300         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31302         ret_ref = (uintptr_t)ret_var.inner;
31303         if (ret_var.is_owned) {
31304                 ret_ref |= 1;
31305         }
31306         return ret_ref;
31307 }
31308
31309 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
31310         LDKChannelTypeFeatures this_arg_conv;
31311         this_arg_conv.inner = (void*)(this_arg & (~1));
31312         this_arg_conv.is_owned = false;
31313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31314         jboolean ret_val = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
31315         return ret_val;
31316 }
31317
31318 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
31319         LDKInitFeatures obj_conv;
31320         obj_conv.inner = (void*)(obj & (~1));
31321         obj_conv.is_owned = false;
31322         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31323         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
31324         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31325         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31326         CVec_u8Z_free(ret_var);
31327         return ret_arr;
31328 }
31329
31330 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
31331         LDKu8slice ser_ref;
31332         ser_ref.datalen = ser->arr_len;
31333         ser_ref.data = ser->elems /* XXX ser leaks */;
31334         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
31335         *ret_conv = InitFeatures_read(ser_ref);
31336         return (uintptr_t)ret_conv;
31337 }
31338
31339 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
31340         LDKChannelFeatures obj_conv;
31341         obj_conv.inner = (void*)(obj & (~1));
31342         obj_conv.is_owned = false;
31343         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31344         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
31345         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31346         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31347         CVec_u8Z_free(ret_var);
31348         return ret_arr;
31349 }
31350
31351 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
31352         LDKu8slice ser_ref;
31353         ser_ref.datalen = ser->arr_len;
31354         ser_ref.data = ser->elems /* XXX ser leaks */;
31355         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
31356         *ret_conv = ChannelFeatures_read(ser_ref);
31357         return (uintptr_t)ret_conv;
31358 }
31359
31360 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
31361         LDKNodeFeatures obj_conv;
31362         obj_conv.inner = (void*)(obj & (~1));
31363         obj_conv.is_owned = false;
31364         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31365         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
31366         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31367         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31368         CVec_u8Z_free(ret_var);
31369         return ret_arr;
31370 }
31371
31372 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
31373         LDKu8slice ser_ref;
31374         ser_ref.datalen = ser->arr_len;
31375         ser_ref.data = ser->elems /* XXX ser leaks */;
31376         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
31377         *ret_conv = NodeFeatures_read(ser_ref);
31378         return (uintptr_t)ret_conv;
31379 }
31380
31381 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
31382         LDKInvoiceFeatures obj_conv;
31383         obj_conv.inner = (void*)(obj & (~1));
31384         obj_conv.is_owned = false;
31385         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31386         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
31387         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31388         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31389         CVec_u8Z_free(ret_var);
31390         return ret_arr;
31391 }
31392
31393 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
31394         LDKu8slice ser_ref;
31395         ser_ref.datalen = ser->arr_len;
31396         ser_ref.data = ser->elems /* XXX ser leaks */;
31397         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
31398         *ret_conv = InvoiceFeatures_read(ser_ref);
31399         return (uintptr_t)ret_conv;
31400 }
31401
31402 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
31403         LDKChannelTypeFeatures obj_conv;
31404         obj_conv.inner = (void*)(obj & (~1));
31405         obj_conv.is_owned = false;
31406         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31407         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
31408         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31409         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31410         CVec_u8Z_free(ret_var);
31411         return ret_arr;
31412 }
31413
31414 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
31415         LDKu8slice ser_ref;
31416         ser_ref.datalen = ser->arr_len;
31417         ser_ref.data = ser->elems /* XXX ser leaks */;
31418         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
31419         *ret_conv = ChannelTypeFeatures_read(ser_ref);
31420         return (uintptr_t)ret_conv;
31421 }
31422
31423 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
31424         LDKShutdownScript this_obj_conv;
31425         this_obj_conv.inner = (void*)(this_obj & (~1));
31426         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31428         ShutdownScript_free(this_obj_conv);
31429 }
31430
31431 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
31432         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
31433 uintptr_t ret_ref = 0;
31434 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31435 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31436 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31437 ret_ref = (uintptr_t)ret_var.inner;
31438 if (ret_var.is_owned) {
31439         ret_ref |= 1;
31440 }
31441         return ret_ref;
31442 }
31443 intptr_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
31444         LDKShutdownScript arg_conv;
31445         arg_conv.inner = (void*)(arg & (~1));
31446         arg_conv.is_owned = false;
31447         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31448         intptr_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
31449         return ret_val;
31450 }
31451
31452 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
31453         LDKShutdownScript orig_conv;
31454         orig_conv.inner = (void*)(orig & (~1));
31455         orig_conv.is_owned = false;
31456         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31457         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
31458         uintptr_t ret_ref = 0;
31459         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31460         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31462         ret_ref = (uintptr_t)ret_var.inner;
31463         if (ret_var.is_owned) {
31464                 ret_ref |= 1;
31465         }
31466         return ret_ref;
31467 }
31468
31469 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
31470         LDKInvalidShutdownScript this_obj_conv;
31471         this_obj_conv.inner = (void*)(this_obj & (~1));
31472         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31474         InvalidShutdownScript_free(this_obj_conv);
31475 }
31476
31477 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
31478         LDKInvalidShutdownScript this_ptr_conv;
31479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31480         this_ptr_conv.is_owned = false;
31481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31482         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
31483         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31484         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31485         return ret_arr;
31486 }
31487
31488 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
31489         LDKInvalidShutdownScript this_ptr_conv;
31490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31491         this_ptr_conv.is_owned = false;
31492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31493         LDKCVec_u8Z val_ref;
31494         val_ref.datalen = val->arr_len;
31495         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
31496         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
31497         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
31498 }
31499
31500 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
31501         LDKCVec_u8Z script_arg_ref;
31502         script_arg_ref.datalen = script_arg->arr_len;
31503         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
31504         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
31505         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
31506         uintptr_t ret_ref = 0;
31507         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31508         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31510         ret_ref = (uintptr_t)ret_var.inner;
31511         if (ret_var.is_owned) {
31512                 ret_ref |= 1;
31513         }
31514         return ret_ref;
31515 }
31516
31517 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
31518         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
31519 uintptr_t ret_ref = 0;
31520 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31521 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31522 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31523 ret_ref = (uintptr_t)ret_var.inner;
31524 if (ret_var.is_owned) {
31525         ret_ref |= 1;
31526 }
31527         return ret_ref;
31528 }
31529 intptr_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
31530         LDKInvalidShutdownScript arg_conv;
31531         arg_conv.inner = (void*)(arg & (~1));
31532         arg_conv.is_owned = false;
31533         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31534         intptr_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
31535         return ret_val;
31536 }
31537
31538 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
31539         LDKInvalidShutdownScript orig_conv;
31540         orig_conv.inner = (void*)(orig & (~1));
31541         orig_conv.is_owned = false;
31542         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31543         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
31544         uintptr_t ret_ref = 0;
31545         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31546         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31548         ret_ref = (uintptr_t)ret_var.inner;
31549         if (ret_var.is_owned) {
31550                 ret_ref |= 1;
31551         }
31552         return ret_ref;
31553 }
31554
31555 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
31556         LDKShutdownScript obj_conv;
31557         obj_conv.inner = (void*)(obj & (~1));
31558         obj_conv.is_owned = false;
31559         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31560         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
31561         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31562         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31563         CVec_u8Z_free(ret_var);
31564         return ret_arr;
31565 }
31566
31567 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
31568         LDKu8slice ser_ref;
31569         ser_ref.datalen = ser->arr_len;
31570         ser_ref.data = ser->elems /* XXX ser leaks */;
31571         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
31572         *ret_conv = ShutdownScript_read(ser_ref);
31573         return (uintptr_t)ret_conv;
31574 }
31575
31576 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
31577         unsigned char pubkey_hash_arr[20];
31578         CHECK(pubkey_hash->arr_len == 20);
31579         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
31580         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
31581         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
31582         uintptr_t ret_ref = 0;
31583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31586         ret_ref = (uintptr_t)ret_var.inner;
31587         if (ret_var.is_owned) {
31588                 ret_ref |= 1;
31589         }
31590         return ret_ref;
31591 }
31592
31593 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
31594         unsigned char script_hash_arr[32];
31595         CHECK(script_hash->arr_len == 32);
31596         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
31597         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
31598         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
31599         uintptr_t ret_ref = 0;
31600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31603         ret_ref = (uintptr_t)ret_var.inner;
31604         if (ret_var.is_owned) {
31605                 ret_ref |= 1;
31606         }
31607         return ret_ref;
31608 }
31609
31610 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
31611         LDKu8slice program_ref;
31612         program_ref.datalen = program->arr_len;
31613         program_ref.data = program->elems /* XXX program leaks */;
31614         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
31615         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
31616         return (uintptr_t)ret_conv;
31617 }
31618
31619 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
31620         LDKShutdownScript this_arg_conv;
31621         this_arg_conv.inner = (void*)(this_arg & (~1));
31622         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
31623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31624         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
31625         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
31626         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31627         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31628         CVec_u8Z_free(ret_var);
31629         return ret_arr;
31630 }
31631
31632 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
31633         LDKShutdownScript this_arg_conv;
31634         this_arg_conv.inner = (void*)(this_arg & (~1));
31635         this_arg_conv.is_owned = false;
31636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31637         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
31638         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
31639         return ret_arr;
31640 }
31641
31642 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
31643         LDKShutdownScript this_arg_conv;
31644         this_arg_conv.inner = (void*)(this_arg & (~1));
31645         this_arg_conv.is_owned = false;
31646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31647         LDKInitFeatures features_conv;
31648         features_conv.inner = (void*)(features & (~1));
31649         features_conv.is_owned = false;
31650         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
31651         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
31652         return ret_val;
31653 }
31654
31655 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
31656         if ((this_ptr & 1) != 0) return;
31657         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31658         CHECK_ACCESS(this_ptr_ptr);
31659         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
31660         FREE((void*)this_ptr);
31661         CustomMessageReader_free(this_ptr_conv);
31662 }
31663
31664 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
31665         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
31666         *ret_ret = Type_clone(arg);
31667         return (uintptr_t)ret_ret;
31668 }
31669 intptr_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
31670         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
31671         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
31672         LDKType* arg_conv = (LDKType*)arg_ptr;
31673         intptr_t ret_val = Type_clone_ptr(arg_conv);
31674         return ret_val;
31675 }
31676
31677 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
31678         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
31679         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
31680         LDKType* orig_conv = (LDKType*)orig_ptr;
31681         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
31682         *ret_ret = Type_clone(orig_conv);
31683         return (uintptr_t)ret_ret;
31684 }
31685
31686 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
31687         if ((this_ptr & 1) != 0) return;
31688         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31689         CHECK_ACCESS(this_ptr_ptr);
31690         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
31691         FREE((void*)this_ptr);
31692         Type_free(this_ptr_conv);
31693 }
31694
31695 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
31696         LDKNodeId this_obj_conv;
31697         this_obj_conv.inner = (void*)(this_obj & (~1));
31698         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31700         NodeId_free(this_obj_conv);
31701 }
31702
31703 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
31704         LDKNodeId ret_var = NodeId_clone(arg);
31705 uintptr_t ret_ref = 0;
31706 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31707 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31708 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31709 ret_ref = (uintptr_t)ret_var.inner;
31710 if (ret_var.is_owned) {
31711         ret_ref |= 1;
31712 }
31713         return ret_ref;
31714 }
31715 intptr_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
31716         LDKNodeId arg_conv;
31717         arg_conv.inner = (void*)(arg & (~1));
31718         arg_conv.is_owned = false;
31719         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31720         intptr_t ret_val = NodeId_clone_ptr(&arg_conv);
31721         return ret_val;
31722 }
31723
31724 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
31725         LDKNodeId orig_conv;
31726         orig_conv.inner = (void*)(orig & (~1));
31727         orig_conv.is_owned = false;
31728         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31729         LDKNodeId ret_var = NodeId_clone(&orig_conv);
31730         uintptr_t ret_ref = 0;
31731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31734         ret_ref = (uintptr_t)ret_var.inner;
31735         if (ret_var.is_owned) {
31736                 ret_ref |= 1;
31737         }
31738         return ret_ref;
31739 }
31740
31741 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
31742         LDKPublicKey pubkey_ref;
31743         CHECK(pubkey->arr_len == 33);
31744         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
31745         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
31746         uintptr_t ret_ref = 0;
31747         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31748         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31750         ret_ref = (uintptr_t)ret_var.inner;
31751         if (ret_var.is_owned) {
31752                 ret_ref |= 1;
31753         }
31754         return ret_ref;
31755 }
31756
31757 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
31758         LDKNodeId this_arg_conv;
31759         this_arg_conv.inner = (void*)(this_arg & (~1));
31760         this_arg_conv.is_owned = false;
31761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31762         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
31763         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31764         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31765         return ret_arr;
31766 }
31767
31768 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
31769         LDKNodeId o_conv;
31770         o_conv.inner = (void*)(o & (~1));
31771         o_conv.is_owned = false;
31772         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
31773         int64_t ret_val = NodeId_hash(&o_conv);
31774         return ret_val;
31775 }
31776
31777 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
31778         LDKNodeId obj_conv;
31779         obj_conv.inner = (void*)(obj & (~1));
31780         obj_conv.is_owned = false;
31781         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31782         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
31783         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31784         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31785         CVec_u8Z_free(ret_var);
31786         return ret_arr;
31787 }
31788
31789 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
31790         LDKu8slice ser_ref;
31791         ser_ref.datalen = ser->arr_len;
31792         ser_ref.data = ser->elems /* XXX ser leaks */;
31793         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
31794         *ret_conv = NodeId_read(ser_ref);
31795         return (uintptr_t)ret_conv;
31796 }
31797
31798 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
31799         LDKNetworkGraph this_obj_conv;
31800         this_obj_conv.inner = (void*)(this_obj & (~1));
31801         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31803         NetworkGraph_free(this_obj_conv);
31804 }
31805
31806 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
31807         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
31808 uintptr_t ret_ref = 0;
31809 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31810 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31811 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31812 ret_ref = (uintptr_t)ret_var.inner;
31813 if (ret_var.is_owned) {
31814         ret_ref |= 1;
31815 }
31816         return ret_ref;
31817 }
31818 intptr_t  __attribute__((export_name("TS_NetworkGraph_clone_ptr"))) TS_NetworkGraph_clone_ptr(uint32_t arg) {
31819         LDKNetworkGraph arg_conv;
31820         arg_conv.inner = (void*)(arg & (~1));
31821         arg_conv.is_owned = false;
31822         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31823         intptr_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
31824         return ret_val;
31825 }
31826
31827 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone"))) TS_NetworkGraph_clone(uint32_t orig) {
31828         LDKNetworkGraph orig_conv;
31829         orig_conv.inner = (void*)(orig & (~1));
31830         orig_conv.is_owned = false;
31831         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31832         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
31833         uintptr_t ret_ref = 0;
31834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31837         ret_ref = (uintptr_t)ret_var.inner;
31838         if (ret_var.is_owned) {
31839                 ret_ref |= 1;
31840         }
31841         return ret_ref;
31842 }
31843
31844 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
31845         LDKReadOnlyNetworkGraph this_obj_conv;
31846         this_obj_conv.inner = (void*)(this_obj & (~1));
31847         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31849         ReadOnlyNetworkGraph_free(this_obj_conv);
31850 }
31851
31852 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
31853         if ((this_ptr & 1) != 0) return;
31854         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31855         CHECK_ACCESS(this_ptr_ptr);
31856         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
31857         FREE((void*)this_ptr);
31858         NetworkUpdate_free(this_ptr_conv);
31859 }
31860
31861 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
31862         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31863         *ret_copy = NetworkUpdate_clone(arg);
31864 uintptr_t ret_ref = (uintptr_t)ret_copy;
31865         return ret_ref;
31866 }
31867 intptr_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
31868         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
31869         intptr_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
31870         return ret_val;
31871 }
31872
31873 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
31874         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
31875         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31876         *ret_copy = NetworkUpdate_clone(orig_conv);
31877         uintptr_t ret_ref = (uintptr_t)ret_copy;
31878         return ret_ref;
31879 }
31880
31881 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
31882         LDKChannelUpdate msg_conv;
31883         msg_conv.inner = (void*)(msg & (~1));
31884         msg_conv.is_owned = (msg & 1) || (msg == 0);
31885         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31886         msg_conv = ChannelUpdate_clone(&msg_conv);
31887         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31888         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
31889         uintptr_t ret_ref = (uintptr_t)ret_copy;
31890         return ret_ref;
31891 }
31892
31893 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_closed"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
31894         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31895         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
31896         uintptr_t ret_ref = (uintptr_t)ret_copy;
31897         return ret_ref;
31898 }
31899
31900 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
31901         LDKPublicKey node_id_ref;
31902         CHECK(node_id->arr_len == 33);
31903         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
31904         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
31905         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
31906         uintptr_t ret_ref = (uintptr_t)ret_copy;
31907         return ret_ref;
31908 }
31909
31910 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
31911         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
31912         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
31913         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31914         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31915         CVec_u8Z_free(ret_var);
31916         return ret_arr;
31917 }
31918
31919 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
31920         LDKu8slice ser_ref;
31921         ser_ref.datalen = ser->arr_len;
31922         ser_ref.data = ser->elems /* XXX ser leaks */;
31923         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
31924         *ret_conv = NetworkUpdate_read(ser_ref);
31925         return (uintptr_t)ret_conv;
31926 }
31927
31928 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_EventHandler"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
31929         LDKNetGraphMsgHandler this_arg_conv;
31930         this_arg_conv.inner = (void*)(this_arg & (~1));
31931         this_arg_conv.is_owned = false;
31932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31933         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
31934         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
31935         return (uintptr_t)ret_ret;
31936 }
31937
31938 void  __attribute__((export_name("TS_NetGraphMsgHandler_free"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
31939         LDKNetGraphMsgHandler this_obj_conv;
31940         this_obj_conv.inner = (void*)(this_obj & (~1));
31941         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31943         NetGraphMsgHandler_free(this_obj_conv);
31944 }
31945
31946 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_new"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
31947         LDKNetworkGraph network_graph_conv;
31948         network_graph_conv.inner = (void*)(network_graph & (~1));
31949         network_graph_conv.is_owned = false;
31950         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
31951         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
31952         CHECK_ACCESS(chain_access_ptr);
31953         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
31954         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
31955         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
31956                 // Manually implement clone for Java trait instances
31957         }
31958         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
31959         CHECK_ACCESS(logger_ptr);
31960         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31961         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
31962         uintptr_t ret_ref = 0;
31963         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31964         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31966         ret_ref = (uintptr_t)ret_var.inner;
31967         if (ret_var.is_owned) {
31968                 ret_ref |= 1;
31969         }
31970         return ret_ref;
31971 }
31972
31973 void  __attribute__((export_name("TS_NetGraphMsgHandler_add_chain_access"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
31974         LDKNetGraphMsgHandler this_arg_conv;
31975         this_arg_conv.inner = (void*)(this_arg & (~1));
31976         this_arg_conv.is_owned = false;
31977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31978         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
31979         CHECK_ACCESS(chain_access_ptr);
31980         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
31981         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
31982         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
31983                 // Manually implement clone for Java trait instances
31984         }
31985         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
31986 }
31987
31988 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_RoutingMessageHandler"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
31989         LDKNetGraphMsgHandler this_arg_conv;
31990         this_arg_conv.inner = (void*)(this_arg & (~1));
31991         this_arg_conv.is_owned = false;
31992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31993         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
31994         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
31995         return (uintptr_t)ret_ret;
31996 }
31997
31998 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_MessageSendEventsProvider"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
31999         LDKNetGraphMsgHandler this_arg_conv;
32000         this_arg_conv.inner = (void*)(this_arg & (~1));
32001         this_arg_conv.is_owned = false;
32002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32003         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32004         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
32005         return (uintptr_t)ret_ret;
32006 }
32007
32008 void  __attribute__((export_name("TS_DirectionalChannelInfo_free"))) TS_DirectionalChannelInfo_free(uint32_t this_obj) {
32009         LDKDirectionalChannelInfo this_obj_conv;
32010         this_obj_conv.inner = (void*)(this_obj & (~1));
32011         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32013         DirectionalChannelInfo_free(this_obj_conv);
32014 }
32015
32016 int32_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_last_update"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
32017         LDKDirectionalChannelInfo this_ptr_conv;
32018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32019         this_ptr_conv.is_owned = false;
32020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32021         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
32022         return ret_val;
32023 }
32024
32025 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_last_update"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
32026         LDKDirectionalChannelInfo this_ptr_conv;
32027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32028         this_ptr_conv.is_owned = false;
32029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32030         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
32031 }
32032
32033 jboolean  __attribute__((export_name("TS_DirectionalChannelInfo_get_enabled"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
32034         LDKDirectionalChannelInfo this_ptr_conv;
32035         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32036         this_ptr_conv.is_owned = false;
32037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32038         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
32039         return ret_val;
32040 }
32041
32042 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_enabled"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
32043         LDKDirectionalChannelInfo this_ptr_conv;
32044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32045         this_ptr_conv.is_owned = false;
32046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32047         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
32048 }
32049
32050 int16_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_cltv_expiry_delta"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
32051         LDKDirectionalChannelInfo this_ptr_conv;
32052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32053         this_ptr_conv.is_owned = false;
32054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32055         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
32056         return ret_val;
32057 }
32058
32059 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_cltv_expiry_delta"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
32060         LDKDirectionalChannelInfo this_ptr_conv;
32061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32062         this_ptr_conv.is_owned = false;
32063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32064         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
32065 }
32066
32067 int64_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_htlc_minimum_msat"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
32068         LDKDirectionalChannelInfo this_ptr_conv;
32069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32070         this_ptr_conv.is_owned = false;
32071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32072         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
32073         return ret_val;
32074 }
32075
32076 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_htlc_minimum_msat"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
32077         LDKDirectionalChannelInfo this_ptr_conv;
32078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32079         this_ptr_conv.is_owned = false;
32080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32081         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
32082 }
32083
32084 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_htlc_maximum_msat"))) TS_DirectionalChannelInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
32085         LDKDirectionalChannelInfo this_ptr_conv;
32086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32087         this_ptr_conv.is_owned = false;
32088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32089         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32090         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
32091         uintptr_t ret_ref = (uintptr_t)ret_copy;
32092         return ret_ref;
32093 }
32094
32095 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_htlc_maximum_msat"))) TS_DirectionalChannelInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
32096         LDKDirectionalChannelInfo this_ptr_conv;
32097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32098         this_ptr_conv.is_owned = false;
32099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32100         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32101         CHECK_ACCESS(val_ptr);
32102         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32103         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
32104         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
32105 }
32106
32107 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_fees"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
32108         LDKDirectionalChannelInfo this_ptr_conv;
32109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32110         this_ptr_conv.is_owned = false;
32111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32112         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
32113         uintptr_t ret_ref = 0;
32114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32117         ret_ref = (uintptr_t)ret_var.inner;
32118         if (ret_var.is_owned) {
32119                 ret_ref |= 1;
32120         }
32121         return ret_ref;
32122 }
32123
32124 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_fees"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
32125         LDKDirectionalChannelInfo this_ptr_conv;
32126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32127         this_ptr_conv.is_owned = false;
32128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32129         LDKRoutingFees val_conv;
32130         val_conv.inner = (void*)(val & (~1));
32131         val_conv.is_owned = (val & 1) || (val == 0);
32132         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32133         val_conv = RoutingFees_clone(&val_conv);
32134         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
32135 }
32136
32137 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_get_last_update_message"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
32138         LDKDirectionalChannelInfo this_ptr_conv;
32139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32140         this_ptr_conv.is_owned = false;
32141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32142         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
32143         uintptr_t ret_ref = 0;
32144         if ((uintptr_t)ret_var.inner > 4096) {
32145                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32146                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32148                 ret_ref = (uintptr_t)ret_var.inner;
32149                 if (ret_var.is_owned) {
32150                         ret_ref |= 1;
32151                 }
32152         }
32153         return ret_ref;
32154 }
32155
32156 void  __attribute__((export_name("TS_DirectionalChannelInfo_set_last_update_message"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
32157         LDKDirectionalChannelInfo this_ptr_conv;
32158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32159         this_ptr_conv.is_owned = false;
32160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32161         LDKChannelUpdate val_conv;
32162         val_conv.inner = (void*)(val & (~1));
32163         val_conv.is_owned = (val & 1) || (val == 0);
32164         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32165         val_conv = ChannelUpdate_clone(&val_conv);
32166         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
32167 }
32168
32169 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) {
32170         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
32171         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
32172         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
32173         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
32174         LDKRoutingFees fees_arg_conv;
32175         fees_arg_conv.inner = (void*)(fees_arg & (~1));
32176         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
32177         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
32178         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
32179         LDKChannelUpdate last_update_message_arg_conv;
32180         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
32181         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
32182         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
32183         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
32184         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);
32185         uintptr_t ret_ref = 0;
32186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32189         ret_ref = (uintptr_t)ret_var.inner;
32190         if (ret_var.is_owned) {
32191                 ret_ref |= 1;
32192         }
32193         return ret_ref;
32194 }
32195
32196 static inline uintptr_t DirectionalChannelInfo_clone_ptr(LDKDirectionalChannelInfo *NONNULL_PTR arg) {
32197         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(arg);
32198 uintptr_t ret_ref = 0;
32199 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32200 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32201 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32202 ret_ref = (uintptr_t)ret_var.inner;
32203 if (ret_var.is_owned) {
32204         ret_ref |= 1;
32205 }
32206         return ret_ref;
32207 }
32208 intptr_t  __attribute__((export_name("TS_DirectionalChannelInfo_clone_ptr"))) TS_DirectionalChannelInfo_clone_ptr(uint32_t arg) {
32209         LDKDirectionalChannelInfo arg_conv;
32210         arg_conv.inner = (void*)(arg & (~1));
32211         arg_conv.is_owned = false;
32212         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32213         intptr_t ret_val = DirectionalChannelInfo_clone_ptr(&arg_conv);
32214         return ret_val;
32215 }
32216
32217 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_clone"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
32218         LDKDirectionalChannelInfo orig_conv;
32219         orig_conv.inner = (void*)(orig & (~1));
32220         orig_conv.is_owned = false;
32221         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32222         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
32223         uintptr_t ret_ref = 0;
32224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32227         ret_ref = (uintptr_t)ret_var.inner;
32228         if (ret_var.is_owned) {
32229                 ret_ref |= 1;
32230         }
32231         return ret_ref;
32232 }
32233
32234 int8_tArray  __attribute__((export_name("TS_DirectionalChannelInfo_write"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
32235         LDKDirectionalChannelInfo obj_conv;
32236         obj_conv.inner = (void*)(obj & (~1));
32237         obj_conv.is_owned = false;
32238         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32239         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
32240         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32241         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32242         CVec_u8Z_free(ret_var);
32243         return ret_arr;
32244 }
32245
32246 uint32_t  __attribute__((export_name("TS_DirectionalChannelInfo_read"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
32247         LDKu8slice ser_ref;
32248         ser_ref.datalen = ser->arr_len;
32249         ser_ref.data = ser->elems /* XXX ser leaks */;
32250         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
32251         *ret_conv = DirectionalChannelInfo_read(ser_ref);
32252         return (uintptr_t)ret_conv;
32253 }
32254
32255 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
32256         LDKChannelInfo this_obj_conv;
32257         this_obj_conv.inner = (void*)(this_obj & (~1));
32258         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32260         ChannelInfo_free(this_obj_conv);
32261 }
32262
32263 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
32264         LDKChannelInfo this_ptr_conv;
32265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32266         this_ptr_conv.is_owned = false;
32267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32268         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
32269         uintptr_t ret_ref = 0;
32270         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32271         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32273         ret_ref = (uintptr_t)ret_var.inner;
32274         if (ret_var.is_owned) {
32275                 ret_ref |= 1;
32276         }
32277         return ret_ref;
32278 }
32279
32280 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
32281         LDKChannelInfo this_ptr_conv;
32282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32283         this_ptr_conv.is_owned = false;
32284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32285         LDKChannelFeatures val_conv;
32286         val_conv.inner = (void*)(val & (~1));
32287         val_conv.is_owned = (val & 1) || (val == 0);
32288         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32289         val_conv = ChannelFeatures_clone(&val_conv);
32290         ChannelInfo_set_features(&this_ptr_conv, val_conv);
32291 }
32292
32293 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
32294         LDKChannelInfo this_ptr_conv;
32295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32296         this_ptr_conv.is_owned = false;
32297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32298         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
32299         uintptr_t ret_ref = 0;
32300         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32301         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32303         ret_ref = (uintptr_t)ret_var.inner;
32304         if (ret_var.is_owned) {
32305                 ret_ref |= 1;
32306         }
32307         return ret_ref;
32308 }
32309
32310 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
32311         LDKChannelInfo this_ptr_conv;
32312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32313         this_ptr_conv.is_owned = false;
32314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32315         LDKNodeId val_conv;
32316         val_conv.inner = (void*)(val & (~1));
32317         val_conv.is_owned = (val & 1) || (val == 0);
32318         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32319         val_conv = NodeId_clone(&val_conv);
32320         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
32321 }
32322
32323 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
32324         LDKChannelInfo this_ptr_conv;
32325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32326         this_ptr_conv.is_owned = false;
32327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32328         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
32329         uintptr_t ret_ref = 0;
32330         if ((uintptr_t)ret_var.inner > 4096) {
32331                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32332                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32334                 ret_ref = (uintptr_t)ret_var.inner;
32335                 if (ret_var.is_owned) {
32336                         ret_ref |= 1;
32337                 }
32338         }
32339         return ret_ref;
32340 }
32341
32342 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
32343         LDKChannelInfo this_ptr_conv;
32344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32345         this_ptr_conv.is_owned = false;
32346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32347         LDKDirectionalChannelInfo val_conv;
32348         val_conv.inner = (void*)(val & (~1));
32349         val_conv.is_owned = (val & 1) || (val == 0);
32350         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32351         val_conv = DirectionalChannelInfo_clone(&val_conv);
32352         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
32353 }
32354
32355 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
32356         LDKChannelInfo this_ptr_conv;
32357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32358         this_ptr_conv.is_owned = false;
32359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32360         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
32361         uintptr_t ret_ref = 0;
32362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32365         ret_ref = (uintptr_t)ret_var.inner;
32366         if (ret_var.is_owned) {
32367                 ret_ref |= 1;
32368         }
32369         return ret_ref;
32370 }
32371
32372 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
32373         LDKChannelInfo this_ptr_conv;
32374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32375         this_ptr_conv.is_owned = false;
32376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32377         LDKNodeId val_conv;
32378         val_conv.inner = (void*)(val & (~1));
32379         val_conv.is_owned = (val & 1) || (val == 0);
32380         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32381         val_conv = NodeId_clone(&val_conv);
32382         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
32383 }
32384
32385 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
32386         LDKChannelInfo this_ptr_conv;
32387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32388         this_ptr_conv.is_owned = false;
32389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32390         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
32391         uintptr_t ret_ref = 0;
32392         if ((uintptr_t)ret_var.inner > 4096) {
32393                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32394                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32396                 ret_ref = (uintptr_t)ret_var.inner;
32397                 if (ret_var.is_owned) {
32398                         ret_ref |= 1;
32399                 }
32400         }
32401         return ret_ref;
32402 }
32403
32404 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
32405         LDKChannelInfo this_ptr_conv;
32406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32407         this_ptr_conv.is_owned = false;
32408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32409         LDKDirectionalChannelInfo val_conv;
32410         val_conv.inner = (void*)(val & (~1));
32411         val_conv.is_owned = (val & 1) || (val == 0);
32412         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32413         val_conv = DirectionalChannelInfo_clone(&val_conv);
32414         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
32415 }
32416
32417 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
32418         LDKChannelInfo this_ptr_conv;
32419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32420         this_ptr_conv.is_owned = false;
32421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32422         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32423         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
32424         uintptr_t ret_ref = (uintptr_t)ret_copy;
32425         return ret_ref;
32426 }
32427
32428 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
32429         LDKChannelInfo this_ptr_conv;
32430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32431         this_ptr_conv.is_owned = false;
32432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32433         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32434         CHECK_ACCESS(val_ptr);
32435         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32436         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
32437         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
32438 }
32439
32440 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
32441         LDKChannelInfo this_ptr_conv;
32442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32443         this_ptr_conv.is_owned = false;
32444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32445         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
32446         uintptr_t ret_ref = 0;
32447         if ((uintptr_t)ret_var.inner > 4096) {
32448                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32449                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32451                 ret_ref = (uintptr_t)ret_var.inner;
32452                 if (ret_var.is_owned) {
32453                         ret_ref |= 1;
32454                 }
32455         }
32456         return ret_ref;
32457 }
32458
32459 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
32460         LDKChannelInfo this_ptr_conv;
32461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32462         this_ptr_conv.is_owned = false;
32463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32464         LDKChannelAnnouncement val_conv;
32465         val_conv.inner = (void*)(val & (~1));
32466         val_conv.is_owned = (val & 1) || (val == 0);
32467         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32468         val_conv = ChannelAnnouncement_clone(&val_conv);
32469         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
32470 }
32471
32472 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
32473         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
32474 uintptr_t ret_ref = 0;
32475 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32476 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32477 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32478 ret_ref = (uintptr_t)ret_var.inner;
32479 if (ret_var.is_owned) {
32480         ret_ref |= 1;
32481 }
32482         return ret_ref;
32483 }
32484 intptr_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
32485         LDKChannelInfo arg_conv;
32486         arg_conv.inner = (void*)(arg & (~1));
32487         arg_conv.is_owned = false;
32488         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32489         intptr_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
32490         return ret_val;
32491 }
32492
32493 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
32494         LDKChannelInfo orig_conv;
32495         orig_conv.inner = (void*)(orig & (~1));
32496         orig_conv.is_owned = false;
32497         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32498         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
32499         uintptr_t ret_ref = 0;
32500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32503         ret_ref = (uintptr_t)ret_var.inner;
32504         if (ret_var.is_owned) {
32505                 ret_ref |= 1;
32506         }
32507         return ret_ref;
32508 }
32509
32510 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
32511         LDKChannelInfo obj_conv;
32512         obj_conv.inner = (void*)(obj & (~1));
32513         obj_conv.is_owned = false;
32514         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32515         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
32516         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32517         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32518         CVec_u8Z_free(ret_var);
32519         return ret_arr;
32520 }
32521
32522 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
32523         LDKu8slice ser_ref;
32524         ser_ref.datalen = ser->arr_len;
32525         ser_ref.data = ser->elems /* XXX ser leaks */;
32526         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
32527         *ret_conv = ChannelInfo_read(ser_ref);
32528         return (uintptr_t)ret_conv;
32529 }
32530
32531 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
32532         LDKRoutingFees this_obj_conv;
32533         this_obj_conv.inner = (void*)(this_obj & (~1));
32534         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32536         RoutingFees_free(this_obj_conv);
32537 }
32538
32539 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
32540         LDKRoutingFees this_ptr_conv;
32541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32542         this_ptr_conv.is_owned = false;
32543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32544         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
32545         return ret_val;
32546 }
32547
32548 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
32549         LDKRoutingFees this_ptr_conv;
32550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32551         this_ptr_conv.is_owned = false;
32552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32553         RoutingFees_set_base_msat(&this_ptr_conv, val);
32554 }
32555
32556 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
32557         LDKRoutingFees this_ptr_conv;
32558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32559         this_ptr_conv.is_owned = false;
32560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32561         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
32562         return ret_val;
32563 }
32564
32565 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
32566         LDKRoutingFees this_ptr_conv;
32567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32568         this_ptr_conv.is_owned = false;
32569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32570         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
32571 }
32572
32573 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
32574         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
32575         uintptr_t ret_ref = 0;
32576         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32577         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32579         ret_ref = (uintptr_t)ret_var.inner;
32580         if (ret_var.is_owned) {
32581                 ret_ref |= 1;
32582         }
32583         return ret_ref;
32584 }
32585
32586 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
32587         LDKRoutingFees a_conv;
32588         a_conv.inner = (void*)(a & (~1));
32589         a_conv.is_owned = false;
32590         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
32591         LDKRoutingFees b_conv;
32592         b_conv.inner = (void*)(b & (~1));
32593         b_conv.is_owned = false;
32594         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
32595         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
32596         return ret_val;
32597 }
32598
32599 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
32600         LDKRoutingFees ret_var = RoutingFees_clone(arg);
32601 uintptr_t ret_ref = 0;
32602 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32603 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32604 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32605 ret_ref = (uintptr_t)ret_var.inner;
32606 if (ret_var.is_owned) {
32607         ret_ref |= 1;
32608 }
32609         return ret_ref;
32610 }
32611 intptr_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
32612         LDKRoutingFees arg_conv;
32613         arg_conv.inner = (void*)(arg & (~1));
32614         arg_conv.is_owned = false;
32615         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32616         intptr_t ret_val = RoutingFees_clone_ptr(&arg_conv);
32617         return ret_val;
32618 }
32619
32620 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
32621         LDKRoutingFees orig_conv;
32622         orig_conv.inner = (void*)(orig & (~1));
32623         orig_conv.is_owned = false;
32624         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32625         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
32626         uintptr_t ret_ref = 0;
32627         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32628         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32630         ret_ref = (uintptr_t)ret_var.inner;
32631         if (ret_var.is_owned) {
32632                 ret_ref |= 1;
32633         }
32634         return ret_ref;
32635 }
32636
32637 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
32638         LDKRoutingFees o_conv;
32639         o_conv.inner = (void*)(o & (~1));
32640         o_conv.is_owned = false;
32641         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
32642         int64_t ret_val = RoutingFees_hash(&o_conv);
32643         return ret_val;
32644 }
32645
32646 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
32647         LDKRoutingFees obj_conv;
32648         obj_conv.inner = (void*)(obj & (~1));
32649         obj_conv.is_owned = false;
32650         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32651         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
32652         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32653         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32654         CVec_u8Z_free(ret_var);
32655         return ret_arr;
32656 }
32657
32658 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
32659         LDKu8slice ser_ref;
32660         ser_ref.datalen = ser->arr_len;
32661         ser_ref.data = ser->elems /* XXX ser leaks */;
32662         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
32663         *ret_conv = RoutingFees_read(ser_ref);
32664         return (uintptr_t)ret_conv;
32665 }
32666
32667 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
32668         LDKNodeAnnouncementInfo this_obj_conv;
32669         this_obj_conv.inner = (void*)(this_obj & (~1));
32670         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32672         NodeAnnouncementInfo_free(this_obj_conv);
32673 }
32674
32675 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
32676         LDKNodeAnnouncementInfo this_ptr_conv;
32677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32678         this_ptr_conv.is_owned = false;
32679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32680         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
32681         uintptr_t ret_ref = 0;
32682         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32683         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32685         ret_ref = (uintptr_t)ret_var.inner;
32686         if (ret_var.is_owned) {
32687                 ret_ref |= 1;
32688         }
32689         return ret_ref;
32690 }
32691
32692 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
32693         LDKNodeAnnouncementInfo this_ptr_conv;
32694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32695         this_ptr_conv.is_owned = false;
32696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32697         LDKNodeFeatures val_conv;
32698         val_conv.inner = (void*)(val & (~1));
32699         val_conv.is_owned = (val & 1) || (val == 0);
32700         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32701         val_conv = NodeFeatures_clone(&val_conv);
32702         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
32703 }
32704
32705 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
32706         LDKNodeAnnouncementInfo this_ptr_conv;
32707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32708         this_ptr_conv.is_owned = false;
32709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32710         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
32711         return ret_val;
32712 }
32713
32714 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
32715         LDKNodeAnnouncementInfo this_ptr_conv;
32716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32717         this_ptr_conv.is_owned = false;
32718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32719         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
32720 }
32721
32722 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
32723         LDKNodeAnnouncementInfo this_ptr_conv;
32724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32725         this_ptr_conv.is_owned = false;
32726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32727         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
32728         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
32729         return ret_arr;
32730 }
32731
32732 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
32733         LDKNodeAnnouncementInfo this_ptr_conv;
32734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32735         this_ptr_conv.is_owned = false;
32736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32737         LDKThreeBytes val_ref;
32738         CHECK(val->arr_len == 3);
32739         memcpy(val_ref.data, val->elems, 3); FREE(val);
32740         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
32741 }
32742
32743 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
32744         LDKNodeAnnouncementInfo this_ptr_conv;
32745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32746         this_ptr_conv.is_owned = false;
32747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32748         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32749         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
32750         return ret_arr;
32751 }
32752
32753 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
32754         LDKNodeAnnouncementInfo this_ptr_conv;
32755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32756         this_ptr_conv.is_owned = false;
32757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32758         LDKThirtyTwoBytes val_ref;
32759         CHECK(val->arr_len == 32);
32760         memcpy(val_ref.data, val->elems, 32); FREE(val);
32761         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
32762 }
32763
32764 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
32765         LDKNodeAnnouncementInfo this_ptr_conv;
32766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32767         this_ptr_conv.is_owned = false;
32768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32769         LDKCVec_NetAddressZ val_constr;
32770         val_constr.datalen = val->arr_len;
32771         if (val_constr.datalen > 0)
32772                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
32773         else
32774                 val_constr.data = NULL;
32775         uint32_t* val_vals = val->elems /* XXX val leaks */;
32776         for (size_t m = 0; m < val_constr.datalen; m++) {
32777                 uint32_t val_conv_12 = val_vals[m];
32778                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
32779                 CHECK_ACCESS(val_conv_12_ptr);
32780                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
32781                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
32782                 val_constr.data[m] = val_conv_12_conv;
32783         }
32784         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
32785 }
32786
32787 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
32788         LDKNodeAnnouncementInfo this_ptr_conv;
32789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32790         this_ptr_conv.is_owned = false;
32791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32792         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
32793         uintptr_t ret_ref = 0;
32794         if ((uintptr_t)ret_var.inner > 4096) {
32795                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32796                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32798                 ret_ref = (uintptr_t)ret_var.inner;
32799                 if (ret_var.is_owned) {
32800                         ret_ref |= 1;
32801                 }
32802         }
32803         return ret_ref;
32804 }
32805
32806 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
32807         LDKNodeAnnouncementInfo this_ptr_conv;
32808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32809         this_ptr_conv.is_owned = false;
32810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32811         LDKNodeAnnouncement val_conv;
32812         val_conv.inner = (void*)(val & (~1));
32813         val_conv.is_owned = (val & 1) || (val == 0);
32814         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32815         val_conv = NodeAnnouncement_clone(&val_conv);
32816         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
32817 }
32818
32819 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) {
32820         LDKNodeFeatures features_arg_conv;
32821         features_arg_conv.inner = (void*)(features_arg & (~1));
32822         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
32823         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
32824         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
32825         LDKThreeBytes rgb_arg_ref;
32826         CHECK(rgb_arg->arr_len == 3);
32827         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
32828         LDKThirtyTwoBytes alias_arg_ref;
32829         CHECK(alias_arg->arr_len == 32);
32830         memcpy(alias_arg_ref.data, alias_arg->elems, 32); FREE(alias_arg);
32831         LDKCVec_NetAddressZ addresses_arg_constr;
32832         addresses_arg_constr.datalen = addresses_arg->arr_len;
32833         if (addresses_arg_constr.datalen > 0)
32834                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
32835         else
32836                 addresses_arg_constr.data = NULL;
32837         uint32_t* addresses_arg_vals = addresses_arg->elems /* XXX addresses_arg leaks */;
32838         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
32839                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
32840                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
32841                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
32842                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
32843                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
32844         }
32845         LDKNodeAnnouncement announcement_message_arg_conv;
32846         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
32847         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
32848         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
32849         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
32850         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
32851         uintptr_t ret_ref = 0;
32852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32855         ret_ref = (uintptr_t)ret_var.inner;
32856         if (ret_var.is_owned) {
32857                 ret_ref |= 1;
32858         }
32859         return ret_ref;
32860 }
32861
32862 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
32863         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
32864 uintptr_t ret_ref = 0;
32865 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32866 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32867 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32868 ret_ref = (uintptr_t)ret_var.inner;
32869 if (ret_var.is_owned) {
32870         ret_ref |= 1;
32871 }
32872         return ret_ref;
32873 }
32874 intptr_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
32875         LDKNodeAnnouncementInfo arg_conv;
32876         arg_conv.inner = (void*)(arg & (~1));
32877         arg_conv.is_owned = false;
32878         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32879         intptr_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
32880         return ret_val;
32881 }
32882
32883 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
32884         LDKNodeAnnouncementInfo orig_conv;
32885         orig_conv.inner = (void*)(orig & (~1));
32886         orig_conv.is_owned = false;
32887         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32888         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
32889         uintptr_t ret_ref = 0;
32890         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32891         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32893         ret_ref = (uintptr_t)ret_var.inner;
32894         if (ret_var.is_owned) {
32895                 ret_ref |= 1;
32896         }
32897         return ret_ref;
32898 }
32899
32900 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
32901         LDKNodeAnnouncementInfo obj_conv;
32902         obj_conv.inner = (void*)(obj & (~1));
32903         obj_conv.is_owned = false;
32904         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32905         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
32906         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32907         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32908         CVec_u8Z_free(ret_var);
32909         return ret_arr;
32910 }
32911
32912 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
32913         LDKu8slice ser_ref;
32914         ser_ref.datalen = ser->arr_len;
32915         ser_ref.data = ser->elems /* XXX ser leaks */;
32916         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
32917         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
32918         return (uintptr_t)ret_conv;
32919 }
32920
32921 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
32922         LDKNodeInfo this_obj_conv;
32923         this_obj_conv.inner = (void*)(this_obj & (~1));
32924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32926         NodeInfo_free(this_obj_conv);
32927 }
32928
32929 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
32930         LDKNodeInfo this_ptr_conv;
32931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32932         this_ptr_conv.is_owned = false;
32933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32934         LDKCVec_u64Z val_constr;
32935         val_constr.datalen = val->arr_len;
32936         if (val_constr.datalen > 0)
32937                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
32938         else
32939                 val_constr.data = NULL;
32940         int64_t* val_vals = val->elems /* XXX val leaks */;
32941         for (size_t i = 0; i < val_constr.datalen; i++) {
32942                 int64_t val_conv_8 = val_vals[i];
32943                 val_constr.data[i] = val_conv_8;
32944         }
32945         NodeInfo_set_channels(&this_ptr_conv, val_constr);
32946 }
32947
32948 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
32949         LDKNodeInfo this_ptr_conv;
32950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32951         this_ptr_conv.is_owned = false;
32952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32953         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
32954         uintptr_t ret_ref = 0;
32955         if ((uintptr_t)ret_var.inner > 4096) {
32956                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32957                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32959                 ret_ref = (uintptr_t)ret_var.inner;
32960                 if (ret_var.is_owned) {
32961                         ret_ref |= 1;
32962                 }
32963         }
32964         return ret_ref;
32965 }
32966
32967 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) {
32968         LDKNodeInfo this_ptr_conv;
32969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32970         this_ptr_conv.is_owned = false;
32971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32972         LDKRoutingFees val_conv;
32973         val_conv.inner = (void*)(val & (~1));
32974         val_conv.is_owned = (val & 1) || (val == 0);
32975         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32976         val_conv = RoutingFees_clone(&val_conv);
32977         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
32978 }
32979
32980 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
32981         LDKNodeInfo this_ptr_conv;
32982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32983         this_ptr_conv.is_owned = false;
32984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32985         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
32986         uintptr_t ret_ref = 0;
32987         if ((uintptr_t)ret_var.inner > 4096) {
32988                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32989                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32991                 ret_ref = (uintptr_t)ret_var.inner;
32992                 if (ret_var.is_owned) {
32993                         ret_ref |= 1;
32994                 }
32995         }
32996         return ret_ref;
32997 }
32998
32999 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
33000         LDKNodeInfo this_ptr_conv;
33001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33002         this_ptr_conv.is_owned = false;
33003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33004         LDKNodeAnnouncementInfo val_conv;
33005         val_conv.inner = (void*)(val & (~1));
33006         val_conv.is_owned = (val & 1) || (val == 0);
33007         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33008         val_conv = NodeAnnouncementInfo_clone(&val_conv);
33009         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
33010 }
33011
33012 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) {
33013         LDKCVec_u64Z channels_arg_constr;
33014         channels_arg_constr.datalen = channels_arg->arr_len;
33015         if (channels_arg_constr.datalen > 0)
33016                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
33017         else
33018                 channels_arg_constr.data = NULL;
33019         int64_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
33020         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
33021                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
33022                 channels_arg_constr.data[i] = channels_arg_conv_8;
33023         }
33024         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
33025         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
33026         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
33027         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
33028         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
33029         LDKNodeAnnouncementInfo announcement_info_arg_conv;
33030         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
33031         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
33032         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
33033         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
33034         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
33035         uintptr_t ret_ref = 0;
33036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33039         ret_ref = (uintptr_t)ret_var.inner;
33040         if (ret_var.is_owned) {
33041                 ret_ref |= 1;
33042         }
33043         return ret_ref;
33044 }
33045
33046 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
33047         LDKNodeInfo ret_var = NodeInfo_clone(arg);
33048 uintptr_t ret_ref = 0;
33049 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33050 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33051 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33052 ret_ref = (uintptr_t)ret_var.inner;
33053 if (ret_var.is_owned) {
33054         ret_ref |= 1;
33055 }
33056         return ret_ref;
33057 }
33058 intptr_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
33059         LDKNodeInfo arg_conv;
33060         arg_conv.inner = (void*)(arg & (~1));
33061         arg_conv.is_owned = false;
33062         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33063         intptr_t ret_val = NodeInfo_clone_ptr(&arg_conv);
33064         return ret_val;
33065 }
33066
33067 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
33068         LDKNodeInfo orig_conv;
33069         orig_conv.inner = (void*)(orig & (~1));
33070         orig_conv.is_owned = false;
33071         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33072         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
33073         uintptr_t ret_ref = 0;
33074         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33075         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33077         ret_ref = (uintptr_t)ret_var.inner;
33078         if (ret_var.is_owned) {
33079                 ret_ref |= 1;
33080         }
33081         return ret_ref;
33082 }
33083
33084 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
33085         LDKNodeInfo obj_conv;
33086         obj_conv.inner = (void*)(obj & (~1));
33087         obj_conv.is_owned = false;
33088         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33089         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
33090         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33091         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33092         CVec_u8Z_free(ret_var);
33093         return ret_arr;
33094 }
33095
33096 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
33097         LDKu8slice ser_ref;
33098         ser_ref.datalen = ser->arr_len;
33099         ser_ref.data = ser->elems /* XXX ser leaks */;
33100         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
33101         *ret_conv = NodeInfo_read(ser_ref);
33102         return (uintptr_t)ret_conv;
33103 }
33104
33105 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
33106         LDKNetworkGraph obj_conv;
33107         obj_conv.inner = (void*)(obj & (~1));
33108         obj_conv.is_owned = false;
33109         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33110         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
33111         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33112         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33113         CVec_u8Z_free(ret_var);
33114         return ret_arr;
33115 }
33116
33117 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser) {
33118         LDKu8slice ser_ref;
33119         ser_ref.datalen = ser->arr_len;
33120         ser_ref.data = ser->elems /* XXX ser leaks */;
33121         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
33122         *ret_conv = NetworkGraph_read(ser_ref);
33123         return (uintptr_t)ret_conv;
33124 }
33125
33126 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
33127         LDKThirtyTwoBytes genesis_hash_ref;
33128         CHECK(genesis_hash->arr_len == 32);
33129         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
33130         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
33131         uintptr_t ret_ref = 0;
33132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33135         ret_ref = (uintptr_t)ret_var.inner;
33136         if (ret_var.is_owned) {
33137                 ret_ref |= 1;
33138         }
33139         return ret_ref;
33140 }
33141
33142 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
33143         LDKNetworkGraph this_arg_conv;
33144         this_arg_conv.inner = (void*)(this_arg & (~1));
33145         this_arg_conv.is_owned = false;
33146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33147         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
33148         uintptr_t ret_ref = 0;
33149         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33150         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33152         ret_ref = (uintptr_t)ret_var.inner;
33153         if (ret_var.is_owned) {
33154                 ret_ref |= 1;
33155         }
33156         return ret_ref;
33157 }
33158
33159 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
33160         LDKNetworkGraph this_arg_conv;
33161         this_arg_conv.inner = (void*)(this_arg & (~1));
33162         this_arg_conv.is_owned = false;
33163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33164         LDKNodeAnnouncement msg_conv;
33165         msg_conv.inner = (void*)(msg & (~1));
33166         msg_conv.is_owned = false;
33167         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33168         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33169         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
33170         return (uintptr_t)ret_conv;
33171 }
33172
33173 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) {
33174         LDKNetworkGraph this_arg_conv;
33175         this_arg_conv.inner = (void*)(this_arg & (~1));
33176         this_arg_conv.is_owned = false;
33177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33178         LDKUnsignedNodeAnnouncement msg_conv;
33179         msg_conv.inner = (void*)(msg & (~1));
33180         msg_conv.is_owned = false;
33181         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33182         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33183         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
33184         return (uintptr_t)ret_conv;
33185 }
33186
33187 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) {
33188         LDKNetworkGraph this_arg_conv;
33189         this_arg_conv.inner = (void*)(this_arg & (~1));
33190         this_arg_conv.is_owned = false;
33191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33192         LDKChannelAnnouncement msg_conv;
33193         msg_conv.inner = (void*)(msg & (~1));
33194         msg_conv.is_owned = false;
33195         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33196         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
33197         CHECK_ACCESS(chain_access_ptr);
33198         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
33199         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
33200         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
33201                 // Manually implement clone for Java trait instances
33202         }
33203         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33204         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
33205         return (uintptr_t)ret_conv;
33206 }
33207
33208 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) {
33209         LDKNetworkGraph this_arg_conv;
33210         this_arg_conv.inner = (void*)(this_arg & (~1));
33211         this_arg_conv.is_owned = false;
33212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33213         LDKUnsignedChannelAnnouncement msg_conv;
33214         msg_conv.inner = (void*)(msg & (~1));
33215         msg_conv.is_owned = false;
33216         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33217         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
33218         CHECK_ACCESS(chain_access_ptr);
33219         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
33220         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
33221         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
33222                 // Manually implement clone for Java trait instances
33223         }
33224         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33225         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
33226         return (uintptr_t)ret_conv;
33227 }
33228
33229 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) {
33230         LDKNetworkGraph this_arg_conv;
33231         this_arg_conv.inner = (void*)(this_arg & (~1));
33232         this_arg_conv.is_owned = false;
33233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33234         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
33235 }
33236
33237 void  __attribute__((export_name("TS_NetworkGraph_fail_node"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
33238         LDKNetworkGraph this_arg_conv;
33239         this_arg_conv.inner = (void*)(this_arg & (~1));
33240         this_arg_conv.is_owned = false;
33241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33242         LDKPublicKey _node_id_ref;
33243         CHECK(_node_id->arr_len == 33);
33244         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
33245         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
33246 }
33247
33248 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) {
33249         LDKNetworkGraph this_arg_conv;
33250         this_arg_conv.inner = (void*)(this_arg & (~1));
33251         this_arg_conv.is_owned = false;
33252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33253         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
33254 }
33255
33256 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
33257         LDKNetworkGraph this_arg_conv;
33258         this_arg_conv.inner = (void*)(this_arg & (~1));
33259         this_arg_conv.is_owned = false;
33260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33261         LDKChannelUpdate msg_conv;
33262         msg_conv.inner = (void*)(msg & (~1));
33263         msg_conv.is_owned = false;
33264         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33265         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33266         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
33267         return (uintptr_t)ret_conv;
33268 }
33269
33270 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
33271         LDKNetworkGraph this_arg_conv;
33272         this_arg_conv.inner = (void*)(this_arg & (~1));
33273         this_arg_conv.is_owned = false;
33274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33275         LDKUnsignedChannelUpdate msg_conv;
33276         msg_conv.inner = (void*)(msg & (~1));
33277         msg_conv.is_owned = false;
33278         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
33279         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
33280         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
33281         return (uintptr_t)ret_conv;
33282 }
33283
33284 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
33285         LDKReadOnlyNetworkGraph this_arg_conv;
33286         this_arg_conv.inner = (void*)(this_arg & (~1));
33287         this_arg_conv.is_owned = false;
33288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33289         LDKPublicKey pubkey_ref;
33290         CHECK(pubkey->arr_len == 33);
33291         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
33292         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
33293         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
33294         uintptr_t ret_ref = (uintptr_t)ret_copy;
33295         return ret_ref;
33296 }
33297
33298 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
33299         LDKRouteHop this_obj_conv;
33300         this_obj_conv.inner = (void*)(this_obj & (~1));
33301         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33303         RouteHop_free(this_obj_conv);
33304 }
33305
33306 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
33307         LDKRouteHop this_ptr_conv;
33308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33309         this_ptr_conv.is_owned = false;
33310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33311         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33312         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
33313         return ret_arr;
33314 }
33315
33316 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
33317         LDKRouteHop this_ptr_conv;
33318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33319         this_ptr_conv.is_owned = false;
33320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33321         LDKPublicKey val_ref;
33322         CHECK(val->arr_len == 33);
33323         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33324         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
33325 }
33326
33327 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
33328         LDKRouteHop this_ptr_conv;
33329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33330         this_ptr_conv.is_owned = false;
33331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33332         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
33333         uintptr_t ret_ref = 0;
33334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33337         ret_ref = (uintptr_t)ret_var.inner;
33338         if (ret_var.is_owned) {
33339                 ret_ref |= 1;
33340         }
33341         return ret_ref;
33342 }
33343
33344 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
33345         LDKRouteHop this_ptr_conv;
33346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33347         this_ptr_conv.is_owned = false;
33348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33349         LDKNodeFeatures val_conv;
33350         val_conv.inner = (void*)(val & (~1));
33351         val_conv.is_owned = (val & 1) || (val == 0);
33352         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33353         val_conv = NodeFeatures_clone(&val_conv);
33354         RouteHop_set_node_features(&this_ptr_conv, val_conv);
33355 }
33356
33357 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
33358         LDKRouteHop this_ptr_conv;
33359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33360         this_ptr_conv.is_owned = false;
33361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33362         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
33363         return ret_val;
33364 }
33365
33366 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
33367         LDKRouteHop this_ptr_conv;
33368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33369         this_ptr_conv.is_owned = false;
33370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33371         RouteHop_set_short_channel_id(&this_ptr_conv, val);
33372 }
33373
33374 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
33375         LDKRouteHop this_ptr_conv;
33376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33377         this_ptr_conv.is_owned = false;
33378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33379         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
33380         uintptr_t ret_ref = 0;
33381         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33382         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33384         ret_ref = (uintptr_t)ret_var.inner;
33385         if (ret_var.is_owned) {
33386                 ret_ref |= 1;
33387         }
33388         return ret_ref;
33389 }
33390
33391 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
33392         LDKRouteHop this_ptr_conv;
33393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33394         this_ptr_conv.is_owned = false;
33395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33396         LDKChannelFeatures val_conv;
33397         val_conv.inner = (void*)(val & (~1));
33398         val_conv.is_owned = (val & 1) || (val == 0);
33399         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33400         val_conv = ChannelFeatures_clone(&val_conv);
33401         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
33402 }
33403
33404 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
33405         LDKRouteHop this_ptr_conv;
33406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33407         this_ptr_conv.is_owned = false;
33408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33409         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
33410         return ret_val;
33411 }
33412
33413 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
33414         LDKRouteHop this_ptr_conv;
33415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33416         this_ptr_conv.is_owned = false;
33417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33418         RouteHop_set_fee_msat(&this_ptr_conv, val);
33419 }
33420
33421 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
33422         LDKRouteHop this_ptr_conv;
33423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33424         this_ptr_conv.is_owned = false;
33425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33426         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
33427         return ret_val;
33428 }
33429
33430 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
33431         LDKRouteHop this_ptr_conv;
33432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33433         this_ptr_conv.is_owned = false;
33434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33435         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
33436 }
33437
33438 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) {
33439         LDKPublicKey pubkey_arg_ref;
33440         CHECK(pubkey_arg->arr_len == 33);
33441         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
33442         LDKNodeFeatures node_features_arg_conv;
33443         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
33444         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
33445         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
33446         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
33447         LDKChannelFeatures channel_features_arg_conv;
33448         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
33449         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
33450         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
33451         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
33452         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);
33453         uintptr_t ret_ref = 0;
33454         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33455         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33456         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33457         ret_ref = (uintptr_t)ret_var.inner;
33458         if (ret_var.is_owned) {
33459                 ret_ref |= 1;
33460         }
33461         return ret_ref;
33462 }
33463
33464 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
33465         LDKRouteHop ret_var = RouteHop_clone(arg);
33466 uintptr_t ret_ref = 0;
33467 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33468 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33469 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33470 ret_ref = (uintptr_t)ret_var.inner;
33471 if (ret_var.is_owned) {
33472         ret_ref |= 1;
33473 }
33474         return ret_ref;
33475 }
33476 intptr_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
33477         LDKRouteHop arg_conv;
33478         arg_conv.inner = (void*)(arg & (~1));
33479         arg_conv.is_owned = false;
33480         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33481         intptr_t ret_val = RouteHop_clone_ptr(&arg_conv);
33482         return ret_val;
33483 }
33484
33485 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
33486         LDKRouteHop orig_conv;
33487         orig_conv.inner = (void*)(orig & (~1));
33488         orig_conv.is_owned = false;
33489         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33490         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
33491         uintptr_t ret_ref = 0;
33492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33495         ret_ref = (uintptr_t)ret_var.inner;
33496         if (ret_var.is_owned) {
33497                 ret_ref |= 1;
33498         }
33499         return ret_ref;
33500 }
33501
33502 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
33503         LDKRouteHop o_conv;
33504         o_conv.inner = (void*)(o & (~1));
33505         o_conv.is_owned = false;
33506         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33507         int64_t ret_val = RouteHop_hash(&o_conv);
33508         return ret_val;
33509 }
33510
33511 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
33512         LDKRouteHop a_conv;
33513         a_conv.inner = (void*)(a & (~1));
33514         a_conv.is_owned = false;
33515         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33516         LDKRouteHop b_conv;
33517         b_conv.inner = (void*)(b & (~1));
33518         b_conv.is_owned = false;
33519         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33520         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
33521         return ret_val;
33522 }
33523
33524 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
33525         LDKRouteHop obj_conv;
33526         obj_conv.inner = (void*)(obj & (~1));
33527         obj_conv.is_owned = false;
33528         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33529         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
33530         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33531         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33532         CVec_u8Z_free(ret_var);
33533         return ret_arr;
33534 }
33535
33536 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
33537         LDKu8slice ser_ref;
33538         ser_ref.datalen = ser->arr_len;
33539         ser_ref.data = ser->elems /* XXX ser leaks */;
33540         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
33541         *ret_conv = RouteHop_read(ser_ref);
33542         return (uintptr_t)ret_conv;
33543 }
33544
33545 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
33546         LDKRoute this_obj_conv;
33547         this_obj_conv.inner = (void*)(this_obj & (~1));
33548         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33550         Route_free(this_obj_conv);
33551 }
33552
33553 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
33554         LDKRoute this_ptr_conv;
33555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33556         this_ptr_conv.is_owned = false;
33557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33558         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
33559         ptrArray ret_arr = NULL;
33560         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
33561         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
33562         for (size_t m = 0; m < ret_var.datalen; m++) {
33563                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
33564                 uint32_tArray ret_conv_12_arr = NULL;
33565                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
33566                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
33567                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
33568                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
33569                         uintptr_t ret_conv_12_conv_10_ref = 0;
33570                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33571                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33572                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
33573                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
33574                         if (ret_conv_12_conv_10_var.is_owned) {
33575                                 ret_conv_12_conv_10_ref |= 1;
33576                         }
33577                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
33578                 }
33579                 
33580                 FREE(ret_conv_12_var.data);
33581                 ret_arr_ptr[m] = ret_conv_12_arr;
33582         }
33583         
33584         FREE(ret_var.data);
33585         return ret_arr;
33586 }
33587
33588 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
33589         LDKRoute this_ptr_conv;
33590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33591         this_ptr_conv.is_owned = false;
33592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33593         LDKCVec_CVec_RouteHopZZ val_constr;
33594         val_constr.datalen = val->arr_len;
33595         if (val_constr.datalen > 0)
33596                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
33597         else
33598                 val_constr.data = NULL;
33599         uint32_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
33600         for (size_t m = 0; m < val_constr.datalen; m++) {
33601                 uint32_tArray val_conv_12 = val_vals[m];
33602                 LDKCVec_RouteHopZ val_conv_12_constr;
33603                 val_conv_12_constr.datalen = val_conv_12->arr_len;
33604                 if (val_conv_12_constr.datalen > 0)
33605                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
33606                 else
33607                         val_conv_12_constr.data = NULL;
33608                 uint32_t* val_conv_12_vals = val_conv_12->elems /* XXX val_conv_12 leaks */;
33609                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
33610                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
33611                         LDKRouteHop val_conv_12_conv_10_conv;
33612                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
33613                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
33614                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
33615                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
33616                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
33617                 }
33618                 val_constr.data[m] = val_conv_12_constr;
33619         }
33620         Route_set_paths(&this_ptr_conv, val_constr);
33621 }
33622
33623 uint32_t  __attribute__((export_name("TS_Route_get_payee"))) TS_Route_get_payee(uint32_t this_ptr) {
33624         LDKRoute this_ptr_conv;
33625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33626         this_ptr_conv.is_owned = false;
33627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33628         LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
33629         uintptr_t ret_ref = 0;
33630         if ((uintptr_t)ret_var.inner > 4096) {
33631                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33632                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33634                 ret_ref = (uintptr_t)ret_var.inner;
33635                 if (ret_var.is_owned) {
33636                         ret_ref |= 1;
33637                 }
33638         }
33639         return ret_ref;
33640 }
33641
33642 void  __attribute__((export_name("TS_Route_set_payee"))) TS_Route_set_payee(uint32_t this_ptr, uint32_t val) {
33643         LDKRoute this_ptr_conv;
33644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33645         this_ptr_conv.is_owned = false;
33646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33647         LDKPayee val_conv;
33648         val_conv.inner = (void*)(val & (~1));
33649         val_conv.is_owned = (val & 1) || (val == 0);
33650         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33651         val_conv = Payee_clone(&val_conv);
33652         Route_set_payee(&this_ptr_conv, val_conv);
33653 }
33654
33655 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payee_arg) {
33656         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
33657         paths_arg_constr.datalen = paths_arg->arr_len;
33658         if (paths_arg_constr.datalen > 0)
33659                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
33660         else
33661                 paths_arg_constr.data = NULL;
33662         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems /* XXX paths_arg leaks */;
33663         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
33664                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
33665                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
33666                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
33667                 if (paths_arg_conv_12_constr.datalen > 0)
33668                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
33669                 else
33670                         paths_arg_conv_12_constr.data = NULL;
33671                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems /* XXX paths_arg_conv_12 leaks */;
33672                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
33673                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
33674                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
33675                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
33676                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
33677                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
33678                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
33679                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
33680                 }
33681                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
33682         }
33683         LDKPayee payee_arg_conv;
33684         payee_arg_conv.inner = (void*)(payee_arg & (~1));
33685         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
33686         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
33687         payee_arg_conv = Payee_clone(&payee_arg_conv);
33688         LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
33689         uintptr_t ret_ref = 0;
33690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33693         ret_ref = (uintptr_t)ret_var.inner;
33694         if (ret_var.is_owned) {
33695                 ret_ref |= 1;
33696         }
33697         return ret_ref;
33698 }
33699
33700 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
33701         LDKRoute ret_var = Route_clone(arg);
33702 uintptr_t ret_ref = 0;
33703 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33704 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33705 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33706 ret_ref = (uintptr_t)ret_var.inner;
33707 if (ret_var.is_owned) {
33708         ret_ref |= 1;
33709 }
33710         return ret_ref;
33711 }
33712 intptr_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
33713         LDKRoute arg_conv;
33714         arg_conv.inner = (void*)(arg & (~1));
33715         arg_conv.is_owned = false;
33716         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33717         intptr_t ret_val = Route_clone_ptr(&arg_conv);
33718         return ret_val;
33719 }
33720
33721 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
33722         LDKRoute orig_conv;
33723         orig_conv.inner = (void*)(orig & (~1));
33724         orig_conv.is_owned = false;
33725         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33726         LDKRoute ret_var = Route_clone(&orig_conv);
33727         uintptr_t ret_ref = 0;
33728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33731         ret_ref = (uintptr_t)ret_var.inner;
33732         if (ret_var.is_owned) {
33733                 ret_ref |= 1;
33734         }
33735         return ret_ref;
33736 }
33737
33738 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
33739         LDKRoute o_conv;
33740         o_conv.inner = (void*)(o & (~1));
33741         o_conv.is_owned = false;
33742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33743         int64_t ret_val = Route_hash(&o_conv);
33744         return ret_val;
33745 }
33746
33747 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
33748         LDKRoute a_conv;
33749         a_conv.inner = (void*)(a & (~1));
33750         a_conv.is_owned = false;
33751         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33752         LDKRoute b_conv;
33753         b_conv.inner = (void*)(b & (~1));
33754         b_conv.is_owned = false;
33755         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33756         jboolean ret_val = Route_eq(&a_conv, &b_conv);
33757         return ret_val;
33758 }
33759
33760 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
33761         LDKRoute this_arg_conv;
33762         this_arg_conv.inner = (void*)(this_arg & (~1));
33763         this_arg_conv.is_owned = false;
33764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33765         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
33766         return ret_val;
33767 }
33768
33769 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
33770         LDKRoute this_arg_conv;
33771         this_arg_conv.inner = (void*)(this_arg & (~1));
33772         this_arg_conv.is_owned = false;
33773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33774         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
33775         return ret_val;
33776 }
33777
33778 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
33779         LDKRoute obj_conv;
33780         obj_conv.inner = (void*)(obj & (~1));
33781         obj_conv.is_owned = false;
33782         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33783         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
33784         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33785         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33786         CVec_u8Z_free(ret_var);
33787         return ret_arr;
33788 }
33789
33790 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
33791         LDKu8slice ser_ref;
33792         ser_ref.datalen = ser->arr_len;
33793         ser_ref.data = ser->elems /* XXX ser leaks */;
33794         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
33795         *ret_conv = Route_read(ser_ref);
33796         return (uintptr_t)ret_conv;
33797 }
33798
33799 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
33800         LDKRouteParameters this_obj_conv;
33801         this_obj_conv.inner = (void*)(this_obj & (~1));
33802         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33804         RouteParameters_free(this_obj_conv);
33805 }
33806
33807 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payee"))) TS_RouteParameters_get_payee(uint32_t this_ptr) {
33808         LDKRouteParameters this_ptr_conv;
33809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33810         this_ptr_conv.is_owned = false;
33811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33812         LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
33813         uintptr_t ret_ref = 0;
33814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33817         ret_ref = (uintptr_t)ret_var.inner;
33818         if (ret_var.is_owned) {
33819                 ret_ref |= 1;
33820         }
33821         return ret_ref;
33822 }
33823
33824 void  __attribute__((export_name("TS_RouteParameters_set_payee"))) TS_RouteParameters_set_payee(uint32_t this_ptr, uint32_t val) {
33825         LDKRouteParameters this_ptr_conv;
33826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33827         this_ptr_conv.is_owned = false;
33828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33829         LDKPayee val_conv;
33830         val_conv.inner = (void*)(val & (~1));
33831         val_conv.is_owned = (val & 1) || (val == 0);
33832         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33833         val_conv = Payee_clone(&val_conv);
33834         RouteParameters_set_payee(&this_ptr_conv, val_conv);
33835 }
33836
33837 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
33838         LDKRouteParameters this_ptr_conv;
33839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33840         this_ptr_conv.is_owned = false;
33841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33842         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
33843         return ret_val;
33844 }
33845
33846 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
33847         LDKRouteParameters this_ptr_conv;
33848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33849         this_ptr_conv.is_owned = false;
33850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33851         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
33852 }
33853
33854 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
33855         LDKRouteParameters this_ptr_conv;
33856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33857         this_ptr_conv.is_owned = false;
33858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33859         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
33860         return ret_val;
33861 }
33862
33863 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) {
33864         LDKRouteParameters this_ptr_conv;
33865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33866         this_ptr_conv.is_owned = false;
33867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33868         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
33869 }
33870
33871 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) {
33872         LDKPayee payee_arg_conv;
33873         payee_arg_conv.inner = (void*)(payee_arg & (~1));
33874         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
33875         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
33876         payee_arg_conv = Payee_clone(&payee_arg_conv);
33877         LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
33878         uintptr_t ret_ref = 0;
33879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33882         ret_ref = (uintptr_t)ret_var.inner;
33883         if (ret_var.is_owned) {
33884                 ret_ref |= 1;
33885         }
33886         return ret_ref;
33887 }
33888
33889 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
33890         LDKRouteParameters ret_var = RouteParameters_clone(arg);
33891 uintptr_t ret_ref = 0;
33892 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33893 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33894 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33895 ret_ref = (uintptr_t)ret_var.inner;
33896 if (ret_var.is_owned) {
33897         ret_ref |= 1;
33898 }
33899         return ret_ref;
33900 }
33901 intptr_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
33902         LDKRouteParameters arg_conv;
33903         arg_conv.inner = (void*)(arg & (~1));
33904         arg_conv.is_owned = false;
33905         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33906         intptr_t ret_val = RouteParameters_clone_ptr(&arg_conv);
33907         return ret_val;
33908 }
33909
33910 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
33911         LDKRouteParameters orig_conv;
33912         orig_conv.inner = (void*)(orig & (~1));
33913         orig_conv.is_owned = false;
33914         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33915         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
33916         uintptr_t ret_ref = 0;
33917         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33918         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33920         ret_ref = (uintptr_t)ret_var.inner;
33921         if (ret_var.is_owned) {
33922                 ret_ref |= 1;
33923         }
33924         return ret_ref;
33925 }
33926
33927 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
33928         LDKRouteParameters obj_conv;
33929         obj_conv.inner = (void*)(obj & (~1));
33930         obj_conv.is_owned = false;
33931         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33932         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
33933         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33934         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33935         CVec_u8Z_free(ret_var);
33936         return ret_arr;
33937 }
33938
33939 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
33940         LDKu8slice ser_ref;
33941         ser_ref.datalen = ser->arr_len;
33942         ser_ref.data = ser->elems /* XXX ser leaks */;
33943         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
33944         *ret_conv = RouteParameters_read(ser_ref);
33945         return (uintptr_t)ret_conv;
33946 }
33947
33948 void  __attribute__((export_name("TS_Payee_free"))) TS_Payee_free(uint32_t this_obj) {
33949         LDKPayee this_obj_conv;
33950         this_obj_conv.inner = (void*)(this_obj & (~1));
33951         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33953         Payee_free(this_obj_conv);
33954 }
33955
33956 int8_tArray  __attribute__((export_name("TS_Payee_get_pubkey"))) TS_Payee_get_pubkey(uint32_t this_ptr) {
33957         LDKPayee this_ptr_conv;
33958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33959         this_ptr_conv.is_owned = false;
33960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33961         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33962         memcpy(ret_arr->elems, Payee_get_pubkey(&this_ptr_conv).compressed_form, 33);
33963         return ret_arr;
33964 }
33965
33966 void  __attribute__((export_name("TS_Payee_set_pubkey"))) TS_Payee_set_pubkey(uint32_t this_ptr, int8_tArray val) {
33967         LDKPayee this_ptr_conv;
33968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33969         this_ptr_conv.is_owned = false;
33970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33971         LDKPublicKey val_ref;
33972         CHECK(val->arr_len == 33);
33973         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33974         Payee_set_pubkey(&this_ptr_conv, val_ref);
33975 }
33976
33977 uint32_t  __attribute__((export_name("TS_Payee_get_features"))) TS_Payee_get_features(uint32_t this_ptr) {
33978         LDKPayee this_ptr_conv;
33979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33980         this_ptr_conv.is_owned = false;
33981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33982         LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
33983         uintptr_t ret_ref = 0;
33984         if ((uintptr_t)ret_var.inner > 4096) {
33985                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33986                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33988                 ret_ref = (uintptr_t)ret_var.inner;
33989                 if (ret_var.is_owned) {
33990                         ret_ref |= 1;
33991                 }
33992         }
33993         return ret_ref;
33994 }
33995
33996 void  __attribute__((export_name("TS_Payee_set_features"))) TS_Payee_set_features(uint32_t this_ptr, uint32_t val) {
33997         LDKPayee this_ptr_conv;
33998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33999         this_ptr_conv.is_owned = false;
34000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34001         LDKInvoiceFeatures val_conv;
34002         val_conv.inner = (void*)(val & (~1));
34003         val_conv.is_owned = (val & 1) || (val == 0);
34004         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34005         val_conv = InvoiceFeatures_clone(&val_conv);
34006         Payee_set_features(&this_ptr_conv, val_conv);
34007 }
34008
34009 uint32_tArray  __attribute__((export_name("TS_Payee_get_route_hints"))) TS_Payee_get_route_hints(uint32_t this_ptr) {
34010         LDKPayee this_ptr_conv;
34011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34012         this_ptr_conv.is_owned = false;
34013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34014         LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
34015         uint32_tArray ret_arr = NULL;
34016         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
34017         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
34018         for (size_t l = 0; l < ret_var.datalen; l++) {
34019                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
34020                 uintptr_t ret_conv_11_ref = 0;
34021                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34022                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34023                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
34024                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
34025                 if (ret_conv_11_var.is_owned) {
34026                         ret_conv_11_ref |= 1;
34027                 }
34028                 ret_arr_ptr[l] = ret_conv_11_ref;
34029         }
34030         
34031         FREE(ret_var.data);
34032         return ret_arr;
34033 }
34034
34035 void  __attribute__((export_name("TS_Payee_set_route_hints"))) TS_Payee_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
34036         LDKPayee this_ptr_conv;
34037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34038         this_ptr_conv.is_owned = false;
34039         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34040         LDKCVec_RouteHintZ val_constr;
34041         val_constr.datalen = val->arr_len;
34042         if (val_constr.datalen > 0)
34043                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
34044         else
34045                 val_constr.data = NULL;
34046         uint32_t* val_vals = val->elems /* XXX val leaks */;
34047         for (size_t l = 0; l < val_constr.datalen; l++) {
34048                 uint32_t val_conv_11 = val_vals[l];
34049                 LDKRouteHint val_conv_11_conv;
34050                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
34051                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
34052                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
34053                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
34054                 val_constr.data[l] = val_conv_11_conv;
34055         }
34056         Payee_set_route_hints(&this_ptr_conv, val_constr);
34057 }
34058
34059 uint32_t  __attribute__((export_name("TS_Payee_get_expiry_time"))) TS_Payee_get_expiry_time(uint32_t this_ptr) {
34060         LDKPayee this_ptr_conv;
34061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34062         this_ptr_conv.is_owned = false;
34063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34064         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34065         *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
34066         uintptr_t ret_ref = (uintptr_t)ret_copy;
34067         return ret_ref;
34068 }
34069
34070 void  __attribute__((export_name("TS_Payee_set_expiry_time"))) TS_Payee_set_expiry_time(uint32_t this_ptr, uint32_t val) {
34071         LDKPayee this_ptr_conv;
34072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34073         this_ptr_conv.is_owned = false;
34074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34075         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34076         CHECK_ACCESS(val_ptr);
34077         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34078         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
34079         Payee_set_expiry_time(&this_ptr_conv, val_conv);
34080 }
34081
34082 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) {
34083         LDKPublicKey pubkey_arg_ref;
34084         CHECK(pubkey_arg->arr_len == 33);
34085         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
34086         LDKInvoiceFeatures features_arg_conv;
34087         features_arg_conv.inner = (void*)(features_arg & (~1));
34088         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
34089         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
34090         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
34091         LDKCVec_RouteHintZ route_hints_arg_constr;
34092         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
34093         if (route_hints_arg_constr.datalen > 0)
34094                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
34095         else
34096                 route_hints_arg_constr.data = NULL;
34097         uint32_t* route_hints_arg_vals = route_hints_arg->elems /* XXX route_hints_arg leaks */;
34098         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
34099                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
34100                 LDKRouteHint route_hints_arg_conv_11_conv;
34101                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
34102                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
34103                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
34104                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
34105                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
34106         }
34107         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
34108         CHECK_ACCESS(expiry_time_arg_ptr);
34109         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
34110         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
34111         LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
34112         uintptr_t ret_ref = 0;
34113         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34114         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34116         ret_ref = (uintptr_t)ret_var.inner;
34117         if (ret_var.is_owned) {
34118                 ret_ref |= 1;
34119         }
34120         return ret_ref;
34121 }
34122
34123 static inline uintptr_t Payee_clone_ptr(LDKPayee *NONNULL_PTR arg) {
34124         LDKPayee ret_var = Payee_clone(arg);
34125 uintptr_t ret_ref = 0;
34126 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34127 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34128 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34129 ret_ref = (uintptr_t)ret_var.inner;
34130 if (ret_var.is_owned) {
34131         ret_ref |= 1;
34132 }
34133         return ret_ref;
34134 }
34135 intptr_t  __attribute__((export_name("TS_Payee_clone_ptr"))) TS_Payee_clone_ptr(uint32_t arg) {
34136         LDKPayee arg_conv;
34137         arg_conv.inner = (void*)(arg & (~1));
34138         arg_conv.is_owned = false;
34139         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34140         intptr_t ret_val = Payee_clone_ptr(&arg_conv);
34141         return ret_val;
34142 }
34143
34144 uint32_t  __attribute__((export_name("TS_Payee_clone"))) TS_Payee_clone(uint32_t orig) {
34145         LDKPayee orig_conv;
34146         orig_conv.inner = (void*)(orig & (~1));
34147         orig_conv.is_owned = false;
34148         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34149         LDKPayee ret_var = Payee_clone(&orig_conv);
34150         uintptr_t ret_ref = 0;
34151         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34152         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34154         ret_ref = (uintptr_t)ret_var.inner;
34155         if (ret_var.is_owned) {
34156                 ret_ref |= 1;
34157         }
34158         return ret_ref;
34159 }
34160
34161 int64_t  __attribute__((export_name("TS_Payee_hash"))) TS_Payee_hash(uint32_t o) {
34162         LDKPayee o_conv;
34163         o_conv.inner = (void*)(o & (~1));
34164         o_conv.is_owned = false;
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34166         int64_t ret_val = Payee_hash(&o_conv);
34167         return ret_val;
34168 }
34169
34170 jboolean  __attribute__((export_name("TS_Payee_eq"))) TS_Payee_eq(uint32_t a, uint32_t b) {
34171         LDKPayee a_conv;
34172         a_conv.inner = (void*)(a & (~1));
34173         a_conv.is_owned = false;
34174         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34175         LDKPayee b_conv;
34176         b_conv.inner = (void*)(b & (~1));
34177         b_conv.is_owned = false;
34178         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34179         jboolean ret_val = Payee_eq(&a_conv, &b_conv);
34180         return ret_val;
34181 }
34182
34183 int8_tArray  __attribute__((export_name("TS_Payee_write"))) TS_Payee_write(uint32_t obj) {
34184         LDKPayee obj_conv;
34185         obj_conv.inner = (void*)(obj & (~1));
34186         obj_conv.is_owned = false;
34187         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34188         LDKCVec_u8Z ret_var = Payee_write(&obj_conv);
34189         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34190         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34191         CVec_u8Z_free(ret_var);
34192         return ret_arr;
34193 }
34194
34195 uint32_t  __attribute__((export_name("TS_Payee_read"))) TS_Payee_read(int8_tArray ser) {
34196         LDKu8slice ser_ref;
34197         ser_ref.datalen = ser->arr_len;
34198         ser_ref.data = ser->elems /* XXX ser leaks */;
34199         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
34200         *ret_conv = Payee_read(ser_ref);
34201         return (uintptr_t)ret_conv;
34202 }
34203
34204 uint32_t  __attribute__((export_name("TS_Payee_from_node_id"))) TS_Payee_from_node_id(int8_tArray pubkey) {
34205         LDKPublicKey pubkey_ref;
34206         CHECK(pubkey->arr_len == 33);
34207         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
34208         LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
34209         uintptr_t ret_ref = 0;
34210         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34211         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34212         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34213         ret_ref = (uintptr_t)ret_var.inner;
34214         if (ret_var.is_owned) {
34215                 ret_ref |= 1;
34216         }
34217         return ret_ref;
34218 }
34219
34220 uint32_t  __attribute__((export_name("TS_Payee_for_keysend"))) TS_Payee_for_keysend(int8_tArray pubkey) {
34221         LDKPublicKey pubkey_ref;
34222         CHECK(pubkey->arr_len == 33);
34223         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
34224         LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
34225         uintptr_t ret_ref = 0;
34226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34229         ret_ref = (uintptr_t)ret_var.inner;
34230         if (ret_var.is_owned) {
34231                 ret_ref |= 1;
34232         }
34233         return ret_ref;
34234 }
34235
34236 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
34237         LDKRouteHint this_obj_conv;
34238         this_obj_conv.inner = (void*)(this_obj & (~1));
34239         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34241         RouteHint_free(this_obj_conv);
34242 }
34243
34244 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
34245         LDKRouteHint this_ptr_conv;
34246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34247         this_ptr_conv.is_owned = false;
34248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34249         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
34250         uint32_tArray ret_arr = NULL;
34251         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
34252         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
34253         for (size_t o = 0; o < ret_var.datalen; o++) {
34254                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
34255                 uintptr_t ret_conv_14_ref = 0;
34256                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34257                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34258                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
34259                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
34260                 if (ret_conv_14_var.is_owned) {
34261                         ret_conv_14_ref |= 1;
34262                 }
34263                 ret_arr_ptr[o] = ret_conv_14_ref;
34264         }
34265         
34266         FREE(ret_var.data);
34267         return ret_arr;
34268 }
34269
34270 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
34271         LDKRouteHint this_ptr_conv;
34272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34273         this_ptr_conv.is_owned = false;
34274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34275         LDKCVec_RouteHintHopZ val_constr;
34276         val_constr.datalen = val->arr_len;
34277         if (val_constr.datalen > 0)
34278                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
34279         else
34280                 val_constr.data = NULL;
34281         uint32_t* val_vals = val->elems /* XXX val leaks */;
34282         for (size_t o = 0; o < val_constr.datalen; o++) {
34283                 uint32_t val_conv_14 = val_vals[o];
34284                 LDKRouteHintHop val_conv_14_conv;
34285                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
34286                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
34287                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
34288                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
34289                 val_constr.data[o] = val_conv_14_conv;
34290         }
34291         RouteHint_set_a(&this_ptr_conv, val_constr);
34292 }
34293
34294 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
34295         LDKCVec_RouteHintHopZ a_arg_constr;
34296         a_arg_constr.datalen = a_arg->arr_len;
34297         if (a_arg_constr.datalen > 0)
34298                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
34299         else
34300                 a_arg_constr.data = NULL;
34301         uint32_t* a_arg_vals = a_arg->elems /* XXX a_arg leaks */;
34302         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
34303                 uint32_t a_arg_conv_14 = a_arg_vals[o];
34304                 LDKRouteHintHop a_arg_conv_14_conv;
34305                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
34306                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
34307                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
34308                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
34309                 a_arg_constr.data[o] = a_arg_conv_14_conv;
34310         }
34311         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
34312         uintptr_t ret_ref = 0;
34313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34316         ret_ref = (uintptr_t)ret_var.inner;
34317         if (ret_var.is_owned) {
34318                 ret_ref |= 1;
34319         }
34320         return ret_ref;
34321 }
34322
34323 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
34324         LDKRouteHint ret_var = RouteHint_clone(arg);
34325 uintptr_t ret_ref = 0;
34326 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34327 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34328 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34329 ret_ref = (uintptr_t)ret_var.inner;
34330 if (ret_var.is_owned) {
34331         ret_ref |= 1;
34332 }
34333         return ret_ref;
34334 }
34335 intptr_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
34336         LDKRouteHint arg_conv;
34337         arg_conv.inner = (void*)(arg & (~1));
34338         arg_conv.is_owned = false;
34339         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34340         intptr_t ret_val = RouteHint_clone_ptr(&arg_conv);
34341         return ret_val;
34342 }
34343
34344 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
34345         LDKRouteHint orig_conv;
34346         orig_conv.inner = (void*)(orig & (~1));
34347         orig_conv.is_owned = false;
34348         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34349         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
34350         uintptr_t ret_ref = 0;
34351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34354         ret_ref = (uintptr_t)ret_var.inner;
34355         if (ret_var.is_owned) {
34356                 ret_ref |= 1;
34357         }
34358         return ret_ref;
34359 }
34360
34361 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
34362         LDKRouteHint o_conv;
34363         o_conv.inner = (void*)(o & (~1));
34364         o_conv.is_owned = false;
34365         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34366         int64_t ret_val = RouteHint_hash(&o_conv);
34367         return ret_val;
34368 }
34369
34370 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
34371         LDKRouteHint a_conv;
34372         a_conv.inner = (void*)(a & (~1));
34373         a_conv.is_owned = false;
34374         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34375         LDKRouteHint b_conv;
34376         b_conv.inner = (void*)(b & (~1));
34377         b_conv.is_owned = false;
34378         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34379         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
34380         return ret_val;
34381 }
34382
34383 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
34384         LDKRouteHint obj_conv;
34385         obj_conv.inner = (void*)(obj & (~1));
34386         obj_conv.is_owned = false;
34387         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34388         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
34389         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34390         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34391         CVec_u8Z_free(ret_var);
34392         return ret_arr;
34393 }
34394
34395 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
34396         LDKu8slice ser_ref;
34397         ser_ref.datalen = ser->arr_len;
34398         ser_ref.data = ser->elems /* XXX ser leaks */;
34399         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
34400         *ret_conv = RouteHint_read(ser_ref);
34401         return (uintptr_t)ret_conv;
34402 }
34403
34404 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
34405         LDKRouteHintHop this_obj_conv;
34406         this_obj_conv.inner = (void*)(this_obj & (~1));
34407         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34409         RouteHintHop_free(this_obj_conv);
34410 }
34411
34412 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
34413         LDKRouteHintHop this_ptr_conv;
34414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34415         this_ptr_conv.is_owned = false;
34416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34417         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34418         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
34419         return ret_arr;
34420 }
34421
34422 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
34423         LDKRouteHintHop this_ptr_conv;
34424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34425         this_ptr_conv.is_owned = false;
34426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34427         LDKPublicKey val_ref;
34428         CHECK(val->arr_len == 33);
34429         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34430         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
34431 }
34432
34433 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
34434         LDKRouteHintHop this_ptr_conv;
34435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34436         this_ptr_conv.is_owned = false;
34437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34438         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
34439         return ret_val;
34440 }
34441
34442 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
34443         LDKRouteHintHop this_ptr_conv;
34444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34445         this_ptr_conv.is_owned = false;
34446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34447         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
34448 }
34449
34450 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
34451         LDKRouteHintHop this_ptr_conv;
34452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34453         this_ptr_conv.is_owned = false;
34454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34455         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
34456         uintptr_t ret_ref = 0;
34457         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34458         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34460         ret_ref = (uintptr_t)ret_var.inner;
34461         if (ret_var.is_owned) {
34462                 ret_ref |= 1;
34463         }
34464         return ret_ref;
34465 }
34466
34467 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
34468         LDKRouteHintHop this_ptr_conv;
34469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34470         this_ptr_conv.is_owned = false;
34471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34472         LDKRoutingFees val_conv;
34473         val_conv.inner = (void*)(val & (~1));
34474         val_conv.is_owned = (val & 1) || (val == 0);
34475         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34476         val_conv = RoutingFees_clone(&val_conv);
34477         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
34478 }
34479
34480 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
34481         LDKRouteHintHop this_ptr_conv;
34482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34483         this_ptr_conv.is_owned = false;
34484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34485         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
34486         return ret_val;
34487 }
34488
34489 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
34490         LDKRouteHintHop this_ptr_conv;
34491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34492         this_ptr_conv.is_owned = false;
34493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34494         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
34495 }
34496
34497 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
34498         LDKRouteHintHop this_ptr_conv;
34499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34500         this_ptr_conv.is_owned = false;
34501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34502         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34503         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
34504         uintptr_t ret_ref = (uintptr_t)ret_copy;
34505         return ret_ref;
34506 }
34507
34508 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
34509         LDKRouteHintHop this_ptr_conv;
34510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34511         this_ptr_conv.is_owned = false;
34512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34513         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34514         CHECK_ACCESS(val_ptr);
34515         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34516         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
34517         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
34518 }
34519
34520 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
34521         LDKRouteHintHop this_ptr_conv;
34522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34523         this_ptr_conv.is_owned = false;
34524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34525         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34526         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
34527         uintptr_t ret_ref = (uintptr_t)ret_copy;
34528         return ret_ref;
34529 }
34530
34531 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
34532         LDKRouteHintHop this_ptr_conv;
34533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34534         this_ptr_conv.is_owned = false;
34535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34536         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34537         CHECK_ACCESS(val_ptr);
34538         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34539         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
34540         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
34541 }
34542
34543 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) {
34544         LDKPublicKey src_node_id_arg_ref;
34545         CHECK(src_node_id_arg->arr_len == 33);
34546         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
34547         LDKRoutingFees fees_arg_conv;
34548         fees_arg_conv.inner = (void*)(fees_arg & (~1));
34549         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
34550         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
34551         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
34552         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
34553         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
34554         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
34555         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
34556         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
34557         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
34558         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
34559         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
34560         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);
34561         uintptr_t ret_ref = 0;
34562         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34563         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34565         ret_ref = (uintptr_t)ret_var.inner;
34566         if (ret_var.is_owned) {
34567                 ret_ref |= 1;
34568         }
34569         return ret_ref;
34570 }
34571
34572 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
34573         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
34574 uintptr_t ret_ref = 0;
34575 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34576 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34577 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34578 ret_ref = (uintptr_t)ret_var.inner;
34579 if (ret_var.is_owned) {
34580         ret_ref |= 1;
34581 }
34582         return ret_ref;
34583 }
34584 intptr_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
34585         LDKRouteHintHop arg_conv;
34586         arg_conv.inner = (void*)(arg & (~1));
34587         arg_conv.is_owned = false;
34588         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34589         intptr_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
34590         return ret_val;
34591 }
34592
34593 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
34594         LDKRouteHintHop orig_conv;
34595         orig_conv.inner = (void*)(orig & (~1));
34596         orig_conv.is_owned = false;
34597         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34598         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
34599         uintptr_t ret_ref = 0;
34600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34603         ret_ref = (uintptr_t)ret_var.inner;
34604         if (ret_var.is_owned) {
34605                 ret_ref |= 1;
34606         }
34607         return ret_ref;
34608 }
34609
34610 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
34611         LDKRouteHintHop o_conv;
34612         o_conv.inner = (void*)(o & (~1));
34613         o_conv.is_owned = false;
34614         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34615         int64_t ret_val = RouteHintHop_hash(&o_conv);
34616         return ret_val;
34617 }
34618
34619 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
34620         LDKRouteHintHop a_conv;
34621         a_conv.inner = (void*)(a & (~1));
34622         a_conv.is_owned = false;
34623         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34624         LDKRouteHintHop b_conv;
34625         b_conv.inner = (void*)(b & (~1));
34626         b_conv.is_owned = false;
34627         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34628         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
34629         return ret_val;
34630 }
34631
34632 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
34633         LDKRouteHintHop obj_conv;
34634         obj_conv.inner = (void*)(obj & (~1));
34635         obj_conv.is_owned = false;
34636         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34637         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
34638         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34639         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34640         CVec_u8Z_free(ret_var);
34641         return ret_arr;
34642 }
34643
34644 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
34645         LDKu8slice ser_ref;
34646         ser_ref.datalen = ser->arr_len;
34647         ser_ref.data = ser->elems /* XXX ser leaks */;
34648         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
34649         *ret_conv = RouteHintHop_read(ser_ref);
34650         return (uintptr_t)ret_conv;
34651 }
34652
34653 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) {
34654         LDKPublicKey our_node_pubkey_ref;
34655         CHECK(our_node_pubkey->arr_len == 33);
34656         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
34657         LDKRouteParameters params_conv;
34658         params_conv.inner = (void*)(params & (~1));
34659         params_conv.is_owned = false;
34660         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
34661         LDKNetworkGraph network_conv;
34662         network_conv.inner = (void*)(network & (~1));
34663         network_conv.is_owned = false;
34664         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
34665         LDKCVec_ChannelDetailsZ first_hops_constr;
34666         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
34667         if (first_hops != 0) {
34668                 first_hops_constr.datalen = first_hops->arr_len;
34669                 if (first_hops_constr.datalen > 0)
34670                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
34671                 else
34672                         first_hops_constr.data = NULL;
34673                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
34674                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
34675                         uint32_t first_hops_conv_16 = first_hops_vals[q];
34676                         LDKChannelDetails first_hops_conv_16_conv;
34677                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
34678                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
34679                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
34680                         first_hops_constr.data[q] = first_hops_conv_16_conv;
34681                 }
34682                 first_hops_ptr = &first_hops_constr;
34683         }
34684         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
34685         CHECK_ACCESS(logger_ptr);
34686         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34687         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
34688         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
34689         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
34690         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
34691         *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
34692         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
34693         return (uintptr_t)ret_conv;
34694 }
34695
34696 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
34697         if ((this_ptr & 1) != 0) return;
34698         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34699         CHECK_ACCESS(this_ptr_ptr);
34700         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
34701         FREE((void*)this_ptr);
34702         Score_free(this_ptr_conv);
34703 }
34704
34705 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
34706         if ((this_ptr & 1) != 0) return;
34707         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
34708         CHECK_ACCESS(this_ptr_ptr);
34709         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
34710         FREE((void*)this_ptr);
34711         LockableScore_free(this_ptr_conv);
34712 }
34713
34714 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
34715         LDKMultiThreadedLockableScore this_obj_conv;
34716         this_obj_conv.inner = (void*)(this_obj & (~1));
34717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34719         MultiThreadedLockableScore_free(this_obj_conv);
34720 }
34721
34722 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
34723         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
34724         CHECK_ACCESS(score_ptr);
34725         LDKScore score_conv = *(LDKScore*)(score_ptr);
34726         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
34727         uintptr_t ret_ref = 0;
34728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34731         ret_ref = (uintptr_t)ret_var.inner;
34732         if (ret_var.is_owned) {
34733                 ret_ref |= 1;
34734         }
34735         return ret_ref;
34736 }
34737
34738 void  __attribute__((export_name("TS_ScoringParameters_free"))) TS_ScoringParameters_free(uint32_t this_obj) {
34739         LDKScoringParameters this_obj_conv;
34740         this_obj_conv.inner = (void*)(this_obj & (~1));
34741         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34743         ScoringParameters_free(this_obj_conv);
34744 }
34745
34746 int64_t  __attribute__((export_name("TS_ScoringParameters_get_base_penalty_msat"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
34747         LDKScoringParameters this_ptr_conv;
34748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34749         this_ptr_conv.is_owned = false;
34750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34751         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
34752         return ret_val;
34753 }
34754
34755 void  __attribute__((export_name("TS_ScoringParameters_set_base_penalty_msat"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
34756         LDKScoringParameters this_ptr_conv;
34757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34758         this_ptr_conv.is_owned = false;
34759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34760         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
34761 }
34762
34763 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_msat"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
34764         LDKScoringParameters this_ptr_conv;
34765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34766         this_ptr_conv.is_owned = false;
34767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34768         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
34769         return ret_val;
34770 }
34771
34772 void  __attribute__((export_name("TS_ScoringParameters_set_failure_penalty_msat"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
34773         LDKScoringParameters this_ptr_conv;
34774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34775         this_ptr_conv.is_owned = false;
34776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34777         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
34778 }
34779
34780 int16_t  __attribute__((export_name("TS_ScoringParameters_get_overuse_penalty_start_1024th"))) TS_ScoringParameters_get_overuse_penalty_start_1024th(uint32_t this_ptr) {
34781         LDKScoringParameters this_ptr_conv;
34782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34783         this_ptr_conv.is_owned = false;
34784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34785         int16_t ret_val = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
34786         return ret_val;
34787 }
34788
34789 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) {
34790         LDKScoringParameters this_ptr_conv;
34791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34792         this_ptr_conv.is_owned = false;
34793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34794         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
34795 }
34796
34797 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) {
34798         LDKScoringParameters this_ptr_conv;
34799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34800         this_ptr_conv.is_owned = false;
34801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34802         int64_t ret_val = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
34803         return ret_val;
34804 }
34805
34806 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) {
34807         LDKScoringParameters this_ptr_conv;
34808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34809         this_ptr_conv.is_owned = false;
34810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34811         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
34812 }
34813
34814 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_half_life"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
34815         LDKScoringParameters this_ptr_conv;
34816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34817         this_ptr_conv.is_owned = false;
34818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34819         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
34820         return ret_val;
34821 }
34822
34823 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) {
34824         LDKScoringParameters this_ptr_conv;
34825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34826         this_ptr_conv.is_owned = false;
34827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34828         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
34829 }
34830
34831 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) {
34832         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);
34833         uintptr_t ret_ref = 0;
34834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34837         ret_ref = (uintptr_t)ret_var.inner;
34838         if (ret_var.is_owned) {
34839                 ret_ref |= 1;
34840         }
34841         return ret_ref;
34842 }
34843
34844 int8_tArray  __attribute__((export_name("TS_ScoringParameters_write"))) TS_ScoringParameters_write(uint32_t obj) {
34845         LDKScoringParameters obj_conv;
34846         obj_conv.inner = (void*)(obj & (~1));
34847         obj_conv.is_owned = false;
34848         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34849         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
34850         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34851         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34852         CVec_u8Z_free(ret_var);
34853         return ret_arr;
34854 }
34855
34856 uint32_t  __attribute__((export_name("TS_ScoringParameters_read"))) TS_ScoringParameters_read(int8_tArray ser) {
34857         LDKu8slice ser_ref;
34858         ser_ref.datalen = ser->arr_len;
34859         ser_ref.data = ser->elems /* XXX ser leaks */;
34860         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
34861         *ret_conv = ScoringParameters_read(ser_ref);
34862         return (uintptr_t)ret_conv;
34863 }
34864
34865 uint32_t  __attribute__((export_name("TS_ScoringParameters_default"))) TS_ScoringParameters_default() {
34866         LDKScoringParameters ret_var = ScoringParameters_default();
34867         uintptr_t ret_ref = 0;
34868         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34869         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34871         ret_ref = (uintptr_t)ret_var.inner;
34872         if (ret_var.is_owned) {
34873                 ret_ref |= 1;
34874         }
34875         return ret_ref;
34876 }
34877